Package org.apache.karaf.shell.table

Examples of org.apache.karaf.shell.table.ShellTable


        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testShrink() {
        ShellTable table = new ShellTable().size(10);
        table.column(new Col("1").maxSize(5));
        table.column(new Col("2").alignRight());

        table.addRow().addContent("quite long", "and here an even longer text");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out, true);
        out.flush();
        String expected = //
                  "1     |  2\n" //
                + "----------\n" //
                + "quite |  a\n";
View Full Code Here


        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testTooSmall() {
        ShellTable table = new ShellTable().size(2);
        table.column(new Col("1").maxSize(5));
        table.column(new Col("2").alignRight());

        table.addRow().addContent("quite long", "and here an even longer text");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out, true);
        out.flush();
        String expected = //
                  "1     | \n" + //
                  "--------\n" + //
                  "quite | \n";
View Full Code Here

        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testNoFormat() {
        ShellTable table = new ShellTable();
        table.column(new Col("first"));
        table.column(new Col("second"));

        table.addRow().addContent("first column", "second column");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out, false);
        out.flush();
        String expected = "first column\tsecond column\n";
        Assert.assertEquals(expected, getString(writer));
    }
View Full Code Here

        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testNoFormatWithCustomSeparator() {
        ShellTable table = new ShellTable();
        table.separator(";");
        table.column(new Col("first"));
        table.column(new Col("second"));

        table.addRow().addContent("first column", "second column");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out, false);
        out.flush();
        String expected = "first column;second column\n";
        Assert.assertEquals(expected, getString(writer));
    }
View Full Code Here

        this.packageService = packageService;
    }

    protected Object doExecute() throws Exception {
        SortedMap<String, PackageRequirement> imports = packageService.getImports();
        ShellTable table = new ShellTable();
        table.column(new Col(onlyPackage ? "Package name" : "Filter"));
        table.column(new Col("Optional"));
        table.column(new Col("ID"));
        table.column(new Col("Bundle Name"));
        table.column(new Col("Resolveable"));
       
        for (String filter : imports.keySet()) {
            PackageRequirement req = imports.get(filter);
            Bundle bundle = req.getBundle();
            String firstCol = onlyPackage ? req.getPackageName() : req.getFilter();
            table.addRow().addContent(firstCol, req.isOptional() ? "optional" : "", bundle.getBundleId(), bundle.getSymbolicName(), req.isResolveable());
        }
        table.print(System.out, !noFormat);
        return null;
    }
View Full Code Here

        return null;
    }

  private void showExports() {
    SortedMap<String, PackageVersion> exports = packageService.getExports();
        ShellTable table = new ShellTable();
        table.column(new Col("Package Name"));
        table.column(new Col("Version"));
        table.column(new Col("ID"));
        table.column(new Col("Bundle Name"));
       
        for (String key : exports.keySet()) {
            PackageVersion pVer = exports.get(key);
            for (Bundle bundle : pVer.getBundles()) {
                table.addRow().addContent(pVer.getPackageName(),pVer.getVersion().toString(), bundle.getBundleId(), bundle.getSymbolicName());
            }
        }
        table.print(System.out, !noFormat);
  }
View Full Code Here

        this.servletService = servletService;
    }

    @Override
    protected Object doExecute() throws Exception {
        ShellTable table = new ShellTable();
        table.column(new Col("ID"));
        table.column(new Col("Servlet"));
        table.column(new Col("Servlet-Name"));
        table.column(new Col("State"));
        table.column(new Col("Alias"));
        table.column(new Col("Url"));

        for (ServletInfo info : servletService.getServlets()) {
            table.addRow().addContent(info.getBundle().getBundleId(), info.getClassName(), info.getName(),
                                      info.getStateString(), info.getAlias(), Arrays.toString(info.getUrls()));
        }
        table.print(System.out, !noFormat);
        return null;
    }
View Full Code Here

    @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false)
    String password = "karaf";

    public Object doExecute() throws Exception {
        ShellTable table = new ShellTable();
        table.column("Property");
        table.column("Value");

        Map<String, String> info = getJmsService().info(connectionFactory, username, password);
        for (String key : info.keySet()) {
            table.addRow().addContent(key, info.get(key));
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

    @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false)
    String password = "karaf";

    public Object doExecute() throws Exception {
        ShellTable table = new ShellTable();

        table.column("JMS Queues");

        for (String queue : getJmsService().queues(connectionFactory, username, password)) {
            table.addRow().addContent(queue);
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

    @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false)
    String password = "karaf";

    public Object doExecute() throws Exception {
        ShellTable table = new ShellTable();

        table.column("Messages Count");

        table.addRow().addContent(getJmsService().count(connectionFactory, queue, username, password));

        table.print(System.out);
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.karaf.shell.table.ShellTable

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.