Package org.rhq.bindings.output

Examples of org.rhq.bindings.output.TabularWriter


    TabularWriter writer;

    @BeforeMethod
    public void initFixture() {
        stringWriter = new StringWriter();
        writer = new TabularWriter(new PrintWriter(stringWriter));
    }
View Full Code Here


        //these are generic and don't require an RHQ facade...
        put(UNLIMITED_PC, pc);
        put(PAGE_CONTROL, PageControl.getUnlimitedInstance());
        put(EXPORTER, new Exporter());
        put(PRETTY, new TabularWriter(output));
        put(ASSERT, new ScriptAssert());

        setFacade(output, rhqFacade);
    }
View Full Code Here

        }
    }


    private void printConfiguration(Configuration configuration) {
        TabularWriter tw = new TabularWriter(writer);
        tw.print(configuration);
    }
View Full Code Here

            Object result = client.getScriptEngine().eval(script.toString());
            inMultilineScript = false;
            script = new StringBuilder();
            if (result != null) {
                //                client.getPrintWriter().print("result: ");
                TabularWriter writer = new TabularWriter(client.getPrintWriter());

                if (client.isInteractiveMode()) {
                    writer.setWidth(client.getConsoleWidth());
                }
                writer.print(result);
            }
        } catch (ScriptException e) {

            if (client.isInteractiveMode()) {
            String message = client.getUsefulErrorMessage(e);
View Full Code Here

    private boolean executeScriptFile( Reader reader, ClientMain client) {
        try {
            Object result = client.getScriptEngine().eval(reader);
            if (result != null) {
                if (client.isInteractiveMode()) {
                    new TabularWriter(client.getPrintWriter()).print(result);
                }
            }
        } catch (ScriptException e) {
            if (client.isInteractiveMode()) {
                client.getPrintWriter().println(e.getMessage());
View Full Code Here

            newWriterNeeded = false;

            try {
                fileWriter = new PrintWriter(new FileWriter(this.file));
                tabularWriter = new TabularWriter(fileWriter, format);
                tabularWriter.setExportMode(true);
            } catch (IOException e) {
                if (fileWriter != null) {
                    fileWriter.close();
                }
View Full Code Here

                ClientCommand command = commands.get(name);
                data[i][0] = name;
                data[i++][1] = command.getHelp();
            }

            TabularWriter tw = new TabularWriter(client.getPrintWriter(), "Command", "Description");
            tw.setWidth(client.getConsoleWidth());
            tw.setHideRowCount(true);
            tw.print(data);
        } else if ("api".equals(args[1])) {
            Map<RhqManager, Object> services = client.getRemoteClient().getScriptingAPI();
            if (args.length == 2) {
                TabularWriter tw = new TabularWriter(client.getPrintWriter(), "API", "Package");
                tw.setWidth(client.getConsoleWidth());

                String[][] data = new String[services.size()][2];
                int i = 0;
                for (RhqManager api : services.keySet()) {
                    data[i][0] = api.name();
                    Object service = services.get(api);
                    data[i][1] = service.getClass().getInterfaces()[0].getPackage().getName();
                    i++;
                }
                tw.print(data);
            } else if (args.length == 3) {
                Object service = services.get(args[2]);
                if (service != null) {
                    Class<?> intf = service.getClass().getInterfaces()[0];
                    Method[] methods = intf.getMethods();
                    Arrays.sort(methods, new Comparator<Method>() {
                        public int compare(Method o1, Method o2) {
                            return o1.getName().compareTo(o2.getName());
                        }
                    });
                    String[][] data = new String[methods.length][2];
                    for (int i = 0; i < methods.length; i++) {

                        Type returnType = methods[i].getGenericReturnType();

                        data[i][0] = ReflectionUtility.getSimpleTypeString(returnType);

                        Class<?>[] paramTypes = methods[i].getParameterTypes();
                        StringBuilder buf = new StringBuilder();

//                        buf.append(methods[i].getReturnType().getSimpleName());
//                        buf.append(" ");
                        buf.append(methods[i].getName());
                        buf.append("(");

                        Annotation[][] annotations = methods[i].getParameterAnnotations();


                        boolean secondary = false;
                        for (int j = 0; (j < paramTypes.length); ++j) {
                            String typeName = paramTypes[j].getSimpleName();


                            if (annotations != null && annotations.length >= i) {
                                Annotation[] as = annotations[j];
                                for (Annotation a : as) {
                                    if (a instanceof WebParam) {
                                        typeName += " " + ((WebParam) a).name();
                                    }
                                }
                            }

                            if (secondary)
                                buf.append(", ");
                            secondary = true;
                            buf.append(typeName);
                        }
                        buf.append(")");
                        data[i][1] = buf.toString();
                    }

                    TabularWriter tw = new TabularWriter(client.getPrintWriter(), "Returns", "Signature");
                    tw.setWidth(client.getConsoleWidth());

                    tw.print(data);
                } else {
                    client.getPrintWriter().println(
                            "Unknown service [" + args[2] + "] - try 'help api' for a listing of services");
                }
View Full Code Here

TOP

Related Classes of org.rhq.bindings.output.TabularWriter

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.