Package org.hyperic.sigar.util

Examples of org.hyperic.sigar.util.PrintfFormat$ConversionSpecification


        ShellCommandHandler handler;
        PrintStream out = this.getOutStream();
        int useArgs;

        if (args.length == 0) {
            PrintfFormat fmt = new PrintfFormat("\t%-14s - %s");
            Object[] fArgs = new Object[2];
            ArrayList cmdNamesList = new ArrayList();
            String[] cmdNames;
            Iterator i;

            i = itsShell.getCommandNameIterator();
            while (i.hasNext()) {
                cmdNamesList.add(i.next());
            }
           
            cmdNames = (String[])cmdNamesList.toArray(new String[0]);
            Arrays.sort(cmdNames);
           
           
            out.println("Available commands:");

            for (int j=0; j<cmdNames.length; j++) {
                handler = itsShell.getHandler(cmdNames[j]);
                fArgs[0] = cmdNames[j];
                fArgs[1] = handler.getUsageShort();
                out.println(fmt.sprintf(fArgs));
            }

            return;
        }
View Full Code Here


        String[] subArgs;

        if (args.length == 0) {
            StringBuffer res = new StringBuffer();
            Object[] fArgs = new Object[2];
            PrintfFormat fmt;
            String fmtStr;
            int maxLen;

            res.append("    " + this.getUsageShort());
            res.append(".\n    For further help on each subcommand, ");
            res.append("type 'help ");
            res.append(this.getCommandName() + " <subcommand>'\n\n");

            maxLen = 0;
            for (Iterator i=this.getHandlerNames().iterator(); i.hasNext();) {
                String cmdName = (String)i.next();
               
                if (cmdName.length() > maxLen)
                    maxLen = cmdName.length();
            }

            fmtStr = "      %-" + (maxLen + 1) + "s %s";
            fmt = new PrintfFormat(fmtStr);
            for (Iterator i=this.getHandlerNames().iterator(); i.hasNext();) {
                String cmdName = (String)i.next();
                ShellCommandHandler sub = this.getSubHandler(cmdName);

                fArgs[0] = cmdName + ":";
                fArgs[1] = sub.getUsageShort();

                res.append(fmt.sprintf(fArgs));
                if (i.hasNext())
                    res.append("\n");
            }
            return res.toString();
        }
View Full Code Here

        this(new Shell());
        this.shell.setPageSize(PageControl.SIZE_UNLIMITED);
    }

    public void setOutputFormat(String format) {
        this.formatter = new PrintfFormat(format);
    }
View Full Code Here

    public PrintfFormat getFormatter() {
        return this.formatter;
    }

    public String sprintf(String format, Object[] items) {
        return new PrintfFormat(format).sprintf(items);
    }
View Full Code Here

    public void printf(String format, Object[] items) {
        println(sprintf(format, items));
    }

    public void printf(Object[] items) {
        PrintfFormat formatter = getFormatter();
        if (formatter == null) {
            //see flushPrintfItems
            this.printfItems.add(items);
        }
        else {
            println(formatter.sprintf(items));
        }
    }
View Full Code Here

        ShellCommandHandler handler;
        PrintStream out = this.getOutStream();
        int useArgs;

        if (args.length == 0) {
            PrintfFormat fmt = new PrintfFormat("\t%-14s - %s");
            Object[] fArgs = new Object[2];
            ArrayList cmdNamesList = new ArrayList();
            String[] cmdNames;
            Iterator i;

            i = itsShell.getCommandNameIterator();
            while (i.hasNext()) {
                cmdNamesList.add(i.next());
            }
           
            cmdNames = (String[])cmdNamesList.toArray(new String[0]);
            Arrays.sort(cmdNames);
           
           
            out.println("Available commands:");

            for (int j=0; j<cmdNames.length; j++) {
                handler = itsShell.getHandler(cmdNames[j]);
                fArgs[0] = cmdNames[j];
                fArgs[1] = handler.getUsageShort();
                out.println(fmt.sprintf(fArgs));
            }

            return;
        }
View Full Code Here

        String[] subArgs;

        if (args.length == 0) {
            StringBuffer res = new StringBuffer();
            Object[] fArgs = new Object[2];
            PrintfFormat fmt;
            String fmtStr;
            int maxLen;

            res.append("    " + this.getUsageShort());
            res.append(".\n    For further help on each subcommand, ");
            res.append("type 'help ");
            res.append(this.getCommandName() + " <subcommand>'\n\n");

            maxLen = 0;
            for (Iterator i=this.getHandlerNames().iterator(); i.hasNext();) {
                String cmdName = (String)i.next();
               
                if (cmdName.length() > maxLen)
                    maxLen = cmdName.length();
            }

            fmtStr = "      %-" + (maxLen + 1) + "s %s";
            fmt = new PrintfFormat(fmtStr);
            for (Iterator i=this.getHandlerNames().iterator(); i.hasNext();) {
                String cmdName = (String)i.next();
                ShellCommandHandler sub = this.getSubHandler(cmdName);

                fArgs[0] = cmdName + ":";
                fArgs[1] = sub.getUsageShort();

                res.append(fmt.sprintf(fArgs));
                if (i.hasNext())
                    res.append("\n");
            }
            return res.toString();
        }
View Full Code Here

        this(new Shell());
        this.shell.setPageSize(PageControl.SIZE_UNLIMITED);
    }

    public void setOutputFormat(String format) {
        this.formatter = new PrintfFormat(format);
    }
View Full Code Here

    public PrintfFormat getFormatter() {
        return this.formatter;
    }

    public String sprintf(String format, Object[] items) {
        return new PrintfFormat(format).sprintf(items);
    }
View Full Code Here

    public void printf(String format, Object[] items) {
        println(sprintf(format, items));
    }

    public void printf(Object[] items) {
        PrintfFormat formatter = getFormatter();
        if (formatter == null) {
            //see flushPrintfItems
            this.printfItems.add(items);
        }
        else {
            println(formatter.sprintf(items));
        }
    }
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.util.PrintfFormat$ConversionSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.