Package jnode.report

Examples of jnode.report.ReportBuilder$FieldFormatter


        ConnectionStatData data = new ConnectionStatData(path);
        logger.l5("get ConnectionStatData " + data);
        List<ConnectionStatData.ConnectionStatDataElement> elements = reset ? data.loadAndDrop() : data.load();
        logger.l5(MessageFormat.format("has {0} elements", elements != null ? elements.size() : 0));

        ReportBuilder builder = new ReportBuilder();
        builder.setColumns(Arrays.asList("Link", "I_OK", "I_FA", "O_OK", "O_FA", "BR", "BS"));
        builder.setColLength(Arrays.asList(19,    5,      5,     5,     5,    9,   9));

        Collections.sort(elements, new Comparator<ConnectionStatData.ConnectionStatDataElement>() {

            @Override
            public int compare(ConnectionStatData.ConnectionStatDataElement arg0,
                               ConnectionStatData.ConnectionStatDataElement arg1) {
                FtnAddress a1 = arg0.linkStr != null ? new FtnAddress(arg0.linkStr) : null;
                FtnAddress a2 = arg1.linkStr != null ? new FtnAddress(arg1.linkStr) : null;
                if (a1 == null && a2 != null) {
                    return 1;
                } else if (a2 == null && a1 != null) {
                    return -1;
                } else if (a1 == null && a2 == null) {
                    return 0;
                } else {
                    return new FtnTools.Ftn4DComparator().compare(a1, a2);
                }
            }

        });


        int iOkT = 0;
        int iFaT = 0;
        int oOkT = 0;
        int oFaT = 0;
        int bsT = 0;
        int brT = 0;
        for (ConnectionStatData.ConnectionStatDataElement element : elements) {
            FtnAddress link = element.linkStr != null ? new FtnAddress(element.linkStr) : null;
            String linkName = (link != null) ? link.toString()
                    : "Unknown";
            iOkT += element.incomingOk;
            iFaT += element.incomingFailed;
            oOkT += element.outgoingOk;
            oFaT += element.outgoingFailed;
            bsT += element.bytesSended;
            brT += element.bytesReceived;

            builder.printLine(
                    linkName,
                    String.valueOf(element.incomingOk),
                    String.valueOf(element.incomingFailed),
                    String.valueOf(element.outgoingOk),
                    String.valueOf(element.outgoingFailed),
                    b2s(element.bytesReceived),
                    b2s(element.bytesSended)
                    );

        }

        if (elements.size() > 0){
            builder.printHorLine();
        }

        builder.printLine(
                "Summary",
                String.valueOf(iOkT),
                String.valueOf(iFaT),
                String.valueOf(oOkT),
                String.valueOf(oFaT),
                b2s(brT),
                b2s(bsT)
        );

        return builder.getText().toString();
    }
View Full Code Here


            .format("SELECT a.name,a.description,count(e.id) AS count FROM echomail e"
                + " LEFT JOIN echoarea a ON (e.echoarea_id=a.id) WHERE e.date >= %d AND e.date <= %d"
                + " GROUP BY a.name,a.description ORDER BY count DESC",
                before, after));

    ReportBuilder builder = new ReportBuilder();
    builder.setColumns(Arrays.asList("Area", "Count", "Description"));
    builder.setColLength(Arrays.asList(35, 5, 35));

    for (String[] res : results) {

      builder.printLine(res[0], res[2], res[1]);

    }
    return builder.getText().toString();
  }
View Full Code Here

    if (res == null || res.size() == 0) {
      return;
    }

    ReportBuilder builder = new ReportBuilder();
    builder.setColumns(headers, DELIM);
    builder.setColLength(colLen, DELIM);
    if (formats != null && formats.length() != 0) {
      builder.setFormats(formats, DELIM);
    }

    for (String[] items : res) {
      builder.printLine(items);
    }

    String text = builder.getText().toString();
    if (text.length() != 0) {
      Echoarea area = FtnTools.getAreaByName(echoarea, null);
      FtnTools.writeEchomail(area, subject, text);
      logger.l5("send message to " + echoarea);
    }
View Full Code Here

TOP

Related Classes of jnode.report.ReportBuilder$FieldFormatter

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.