Example usage for java.lang Object toString

List of usage examples for java.lang Object toString

Introduction

In this page you can find the example usage for java.lang Object toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.alkacon.opencms.registration.CmsRegistrationFormHandler.java

/**
 * As test case.<p>/*from   w  w w . j a  v  a 2  s  .  co  m*/
 * 
 * @param args not used
 */
public static void main(String[] args) {

    CmsUser user = new CmsUser(null, "/mylongouname/m.moossen@alkacon.com", "", "", "", "", 0, 0, 0, null);
    String code = getActivationCode(user);
    System.out.println(code);
    System.out.println(getUserName(code));

    CmsMacroResolver macroResolver = CmsMacroResolver.newInstance();
    macroResolver.setKeepEmptyMacros(true);
    // create macros for getters 
    Method[] methods = CmsUser.class.getDeclaredMethods();
    for (int i = 0; i < methods.length; i++) {
        Method method = methods[i];
        if (method.getReturnType() != String.class) {
            continue;
        }
        if (method.getParameterTypes().length > 0) {
            continue;
        }
        if (!method.getName().startsWith("get") || (method.getName().length() < 4)
                || method.getName().equals("getPassword")) {
            continue;
        }
        String label = ("" + method.getName().charAt(3)).toLowerCase();
        if (method.getName().length() > 4) {
            label += method.getName().substring(4);
        }
        try {
            Object value = method.invoke(user, new Object[] {});
            if (value == null) {
                value = "";
            }
            macroResolver.addMacro(label, value.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // add addinfo values as macros
    Iterator itFields = user.getAdditionalInfo().entrySet().iterator();
    while (itFields.hasNext()) {
        Map.Entry entry = (Map.Entry) itFields.next();
        if ((entry.getValue() instanceof String) && (entry.getKey() instanceof String)) {
            macroResolver.addMacro(entry.getKey().toString(), entry.getValue().toString());
        }
    }
    // add login
    macroResolver.addMacro(FIELD_LOGIN, user.getSimpleName());

}

From source file:net.sf.maltcms.chromaui.charts.GradientPaintScale.java

/**
 *
 * @param args//  w w  w.j  a v  a2s .  c o  m
 */
public static void main(String[] args) {
    double[] st = ImageTools.createSampleTable(256);
    Logger.getLogger(GradientPaintScale.class.getName()).info(Arrays.toString(st));
    double min = 564.648;
    double max = 24334.234;
    GradientPaintScale gps = new GradientPaintScale(st, min, max,
            new Color[] { Color.BLACK, Color.RED, Color.orange, Color.yellow, Color.white });
    double val = min;
    double incr = (max - min) / (st.length - 1);
    Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Increment: {0}", incr);
    for (int i = 0; i < st.length; i++) {
        Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Value: {0}", val);
        gps.getPaint(val);
        val += incr;
    }
    Logger.getLogger(GradientPaintScale.class.getName()).info("Printing min and max values");
    Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Min: {0} gps min: {1}",
            new Object[] { min, gps.getPaint(min) });
    Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Max: {0} gps max: {1}",
            new Object[] { max, gps.getPaint(max) });
    JList jl = new JList();
    DefaultListModel dlm = new DefaultListModel();
    jl.setModel(dlm);
    jl.setCellRenderer(new ListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            if (value instanceof JLabel) {
                // Border b =
                // BorderFactory.createCompoundBorder(BorderFactory
                // .createEmptyBorder(0, 0, 5, 0), BorderFactory
                // .createLineBorder(Color.BLACK, 1));
                // ((JLabel) value).setBorder(b);
                return (Component) value;
            }
            return new JLabel(value.toString());
        }
    });
    JFrame jf = new JFrame();
    jf.add(new JScrollPane(jl));
    jf.setVisible(true);
    jf.setSize(200, 400);
    for (int alpha = -10; alpha <= 10; alpha++) {
        for (int beta = 1; beta <= 20; beta++) {
            gps.setAlphaBeta(alpha, beta);
            // System.out.println(Arrays.toString(gps.st));
            // System.out.println(Arrays.toString(gps.sampleTable));
            BufferedImage bi = gps.getLookupImage();
            ImageIcon ii = new ImageIcon(bi);
            dlm.addElement(new JLabel(ii));
        }
    }

}

From source file:edu.usc.goffish.gofs.tools.GoFSDeployGraph.java

@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException {
    if (args.length < REQUIRED_ARGS) {
        PrintUsageAndQuit(null);//  w w w .  j  a  va 2s.c  o m
    }

    if (args.length == 1 && args[0].equals("-help")) {
        PrintUsageAndQuit(null);
    }

    // optional arguments
    boolean overwriteGraph = false;
    PartitionerMode partitionerMode = PartitionerMode.METIS;
    ComponentizerMode componentizerMode = ComponentizerMode.WCC;
    MapperMode mapperMode = MapperMode.ROUNDROBIN;
    PartitionedFileMode partitionedFileMode = PartitionedFileMode.DEFAULT;
    DistributerMode distributerMode = DistributerMode.SCP;
    int instancesGroupingSize = 1;
    int numSubgraphBins = -1;

    // optional sub arguments
    Path metisBinaryPath = null;
    String[] extraMetisOptions = null;
    Path partitioningPath = null;
    Path partitionedGMLFilePath = null;

    // parse optional arguments
    int i = 0;
    OptArgLoop: for (i = 0; i < args.length - REQUIRED_ARGS; i++) {

        switch (args[i]) {
        case "-overwriteGraph":
            overwriteGraph = true;
            break;
        case "-partitioner":
            i++;

            if (args[i].equals("stream")) {
                partitionerMode = PartitionerMode.STREAM;
            } else if (args[i].startsWith("metis")) {
                String[] subargs = parseSubArgs('=', args[i]);
                if (subargs[0].equals("metis")) {
                    partitionerMode = PartitionerMode.METIS;
                    if (subargs.length > 1) {
                        try {
                            metisBinaryPath = Paths.get(subargs[1]);
                            if (!metisBinaryPath.isAbsolute()) {
                                throw new InvalidPathException(metisBinaryPath.toString(),
                                        "metis binary path must be absolute");
                            }
                        } catch (InvalidPathException e) {
                            PrintUsageAndQuit("metis binary - " + e.getMessage());
                        }

                        if (subargs.length > 2) {
                            extraMetisOptions = parseSubArgs(' ', subargs[2]);
                        }
                    }
                } else {
                    PrintUsageAndQuit(null);
                }
            } else if (args[i].startsWith("predefined")) {
                String[] subargs = parseSubArgs('=', args[i]);
                if (subargs[0].equals("predefined")) {
                    partitionerMode = PartitionerMode.PREDEFINED;
                    if (subargs.length < 2) {
                        PrintUsageAndQuit(null);
                    }

                    try {
                        partitioningPath = Paths.get(subargs[1]);
                    } catch (InvalidPathException e) {
                        PrintUsageAndQuit("partitioning file - " + e.getMessage());
                    }
                } else {
                    PrintUsageAndQuit(null);
                }
            } else {
                PrintUsageAndQuit(null);
            }

            break;
        case "-intermediategml":
            if (args[i + 1].startsWith("save")) {
                i++;
                String[] subargs = parseSubArgs('=', args[i]);
                if (subargs[0].equals("save")) {
                    if (subargs.length < 2) {
                        PrintUsageAndQuit(null);
                    }

                    partitionedFileMode = PartitionedFileMode.SAVE;
                    try {
                        partitionedGMLFilePath = Paths.get(subargs[1]);
                    } catch (InvalidPathException e) {
                        PrintUsageAndQuit("partitioned gml file  - " + e.getMessage());
                    }
                }
            } else {
                partitionedFileMode = PartitionedFileMode.READ;
            }
            break;
        case "-componentizer":
            i++;

            switch (args[i]) {
            case "single":
                componentizerMode = ComponentizerMode.SINGLE;
                break;
            case "wcc":
                componentizerMode = ComponentizerMode.WCC;
                break;
            default:
                PrintUsageAndQuit(null);
            }

            break;
        case "-distributer":
            i++;

            switch (args[i]) {
            case "scp":
                distributerMode = DistributerMode.SCP;
                break;
            case "write":
                distributerMode = DistributerMode.WRITE;
                break;
            default:
                PrintUsageAndQuit(null);
            }

            break;
        case "-mapper":
            i++;

            if (args[i].equalsIgnoreCase("roundrobin")) {
                mapperMode = MapperMode.ROUNDROBIN;
            } else {
                PrintUsageAndQuit(null);
            }

            break;
        case "-serializer:instancegroupingsize":
            i++;

            try {
                if (args[i].equalsIgnoreCase("ALL")) {
                    instancesGroupingSize = Integer.MAX_VALUE;
                } else {
                    instancesGroupingSize = Integer.parseInt(args[i]);
                    if (instancesGroupingSize < 1) {
                        PrintUsageAndQuit("Serialization instance grouping size must be greater than zero");
                    }
                }
            } catch (NumberFormatException e) {
                PrintUsageAndQuit("Serialization instance grouping size - " + e.getMessage());
            }

            break;
        case "-serializer:numsubgraphbins":
            i++;

            try {
                numSubgraphBins = Integer.parseInt(args[i]);
                if (instancesGroupingSize < 1) {
                    PrintUsageAndQuit("Serialization number of subgraph bins must be greater than zero");
                }
            } catch (NumberFormatException e) {
                PrintUsageAndQuit("Serialization number of subgraph bins - " + e.getMessage());
            }

            break;
        default:
            break OptArgLoop;
        }
    }

    if (args.length - i < REQUIRED_ARGS) {
        PrintUsageAndQuit(null);
    }

    // required arguments
    IInternalNameNode nameNode = null;
    Class<? extends IInternalNameNode> nameNodeType = null;
    URI nameNodeLocation = null;
    String graphId = null;
    int numPartitions = 0;
    Path gmlTemplatePath = null;
    List<Path> gmlInstancePaths = new LinkedList<>();

    // parse required arguments

    try {
        nameNodeType = NameNodeProvider.loadNameNodeType(args[i]);
        i++;
    } catch (ReflectiveOperationException e) {
        PrintUsageAndQuit("name node type - " + e.getMessage());
    }

    try {
        nameNodeLocation = new URI(args[i]);
        i++;
    } catch (URISyntaxException e) {
        PrintUsageAndQuit("name node location - " + e.getMessage());
    }

    try {
        nameNode = NameNodeProvider.loadNameNode(nameNodeType, nameNodeLocation);
    } catch (ReflectiveOperationException e) {
        PrintUsageAndQuit("error loading name node - " + e.getMessage());
    }

    graphId = args[i++];

    try {
        numPartitions = Integer.parseInt(args[i]);
        i++;
    } catch (NumberFormatException e) {
        PrintUsageAndQuit("number of partitions - " + e.getMessage());
    }

    Path gmlInputFile = null;
    try {
        gmlInputFile = Paths.get(args[i]);
        i++;
    } catch (InvalidPathException e) {
        PrintUsageAndQuit(e.getMessage());
    }

    // finished parsing args
    if (i < args.length) {
        PrintUsageAndQuit("Unrecognized argument \"" + args[i] + "\"");
    }

    // ensure name node is available
    if (!nameNode.isAvailable()) {
        throw new IOException("Name node at " + nameNode.getURI() + " is not available");
    }

    // ensure there are data nodes available
    Set<URI> dataNodes = nameNode.getDataNodes();
    if (dataNodes == null || dataNodes.isEmpty()) {
        throw new IllegalArgumentException("name node does not have any data nodes available for deployment");
    }

    // ensure graph id does not exist (unless to be overwritten)
    IntCollection partitions = nameNode.getPartitionDirectory().getPartitions(graphId);
    if (partitions != null) {
        if (!overwriteGraph) {
            throw new IllegalArgumentException(
                    "graph id \"" + graphId + "\" already exists in name node partition directory");
        } else {
            for (int partitionId : partitions) {
                nameNode.getPartitionDirectory().removePartitionMapping(graphId, partitionId);
            }
        }
    }

    IGraphLoader loader = null;
    IPartitioner partitioner = null;
    if (partitionedFileMode != PartitionedFileMode.READ) {
        XMLConfiguration configuration;
        try {
            configuration = new XMLConfiguration(gmlInputFile.toFile());
            configuration.setDelimiterParsingDisabled(true);

            //read the template property
            gmlTemplatePath = Paths.get(configuration.getString("template"));

            //read the instance property
            for (Object instance : configuration.getList("instances.instance")) {
                gmlInstancePaths.add(Paths.get(instance.toString()));
            }
        } catch (ConfigurationException | InvalidPathException e) {
            PrintUsageAndQuit("gml input file - " + e.getMessage());
        }

        // create loader
        loader = new GMLGraphLoader(gmlTemplatePath);

        // create partitioner
        switch (partitionerMode) {
        case METIS:
            if (metisBinaryPath == null) {
                partitioner = new MetisPartitioner();
            } else {
                partitioner = new MetisPartitioner(metisBinaryPath, extraMetisOptions);
            }
            break;
        case STREAM:
            partitioner = new StreamPartitioner(new LDGObjectiveFunction());
            break;
        case PREDEFINED:
            partitioner = new PredefinedPartitioner(
                    MetisPartitioning.read(Files.newInputStream(partitioningPath)));
            break;
        default:
            PrintUsageAndQuit(null);
        }
    }

    // create componentizer
    IGraphComponentizer graphComponentizer = null;
    switch (componentizerMode) {
    case SINGLE:
        graphComponentizer = new SingleComponentizer();
        break;
    case WCC:
        graphComponentizer = new WCCComponentizer();
        break;
    default:
        PrintUsageAndQuit(null);
    }

    // create mapper
    IPartitionMapper partitionMapper = null;
    switch (mapperMode) {
    case ROUNDROBIN:
        partitionMapper = new RoundRobinPartitionMapper(nameNode.getDataNodes());
        break;
    default:
        PrintUsageAndQuit(null);
    }

    // create serializer
    ISliceSerializer serializer = nameNode.getSerializer();
    if (serializer == null) {
        throw new IOException("name node at " + nameNode.getURI() + " returned null serializer");
    }

    // create distributer
    IPartitionDistributer partitionDistributer = null;
    switch (distributerMode) {
    case SCP:
        partitionDistributer = new SCPPartitionDistributer(serializer, instancesGroupingSize, numSubgraphBins);
        break;
    case WRITE:
        partitionDistributer = new DirectWritePartitionDistributer(serializer, instancesGroupingSize,
                numSubgraphBins);
        break;
    }

    GMLPartitionBuilder partitionBuilder = null;
    try {
        System.out.print("Executing command: DeployGraph");
        for (String arg : args) {
            System.out.print(" " + arg);
        }
        System.out.println();

        // perform deployment
        long time = System.currentTimeMillis();
        switch (partitionedFileMode) {
        case DEFAULT:
            partitionBuilder = new GMLPartitionBuilder(graphComponentizer, gmlTemplatePath, gmlInstancePaths);
            deploy(nameNode.getPartitionDirectory(), graphId, numPartitions, loader, partitioner,
                    partitionBuilder, null, partitionMapper, partitionDistributer);
            break;
        case SAVE:
            //save partitioned gml files 
            partitionBuilder = new GMLPartitionBuilder(partitionedGMLFilePath, graphComponentizer,
                    gmlTemplatePath, gmlInstancePaths);
            //partitioned gml input file name format as graphid_numpartitions_paritioningtype_serializer
            String intermediateGMLInputFile = new StringBuffer().append(graphId).append("_")
                    .append(numPartitions).append("_").append(partitionerMode.name().toLowerCase()).append("_")
                    .append(serializer.getClass().getSimpleName().toLowerCase()).toString();
            deploy(nameNode.getPartitionDirectory(), graphId, numPartitions, loader, partitioner,
                    partitionBuilder, intermediateGMLInputFile, partitionMapper, partitionDistributer);
            break;
        case READ:
            //read partitioned gml files
            partitionBuilder = new GMLPartitionBuilder(graphComponentizer);
            partitionBuilder.new XMLConfigurationBuilder(gmlInputFile.toFile().getAbsolutePath())
                    .readIntermediateGMLFile();
            deploy(nameNode.getPartitionDirectory(), graphId, numPartitions, partitionBuilder, partitionMapper,
                    partitionDistributer);
            break;
        }

        System.out.println("finished [total " + (System.currentTimeMillis() - time) + "ms]");
    } finally {
        if (partitionBuilder != null)
            partitionBuilder.close();
    }
}

From source file:com.techmahindra.vehicletelemetry.chart.CarEventServlet.java

public static void main(String[] args) throws TypeMismatchException {

    List<CarEvent> carData = new LinkedList<>();
    /*carData.add(new CarEvent("city1","model1",41));
    carData.add(new CarEvent("city1","model2",17));
            /* w w w . j  a  v  a2s  .c o m*/
    carData.add(new CarEvent("city2","model1",31));
    carData.add(new CarEvent("city2","model2",39));
            
    carData.add(new CarEvent("Bellevue","model1",47));*/

    /*carData.add(new CarEvent("Seattle","MediumSUV",1038)); 
    carData.add(new CarEvent("Seattle","LargeSUV",2415));
    carData.add(new CarEvent("Seattle","FamilySaloon",2388));
    carData.add(new CarEvent("Seattle","SportsCar",1626)); 
    //aggDrivers.add(new CarEvent("Seattle","sports car",276)); 
    carData.add(new CarEvent("Seattle","Compactcar",204)); 
    carData.add(new CarEvent("Seattle","SmallSUV",1133)); 
    carData.add(new CarEvent("Seattle","StationWagon",1769)); 
    carData.add(new CarEvent("Seattle","CompactCar",839)); 
    carData.add(new CarEvent("Seattle","Hybrid",2603)); 
    carData.add(new CarEvent("Seattle","Coupe",1081)); 
    carData.add(new CarEvent("Seattle","Sedan",2603));
    carData.add(new CarEvent("Seattle","Convertible",1608));
            
    carData.add(new CarEvent("Redmond","MediumSUV",590));
    carData.add(new CarEvent("Redmond","LargeSUV",1407)); 
    carData.add(new CarEvent("Redmond","FamilySaloon",1535)); 
    carData.add(new CarEvent("Redmond","SportsCar",1115)); 
            
    //aggDrivers.add(new CarEvent("Redmond","sports car",102)); 
    carData.add(new CarEvent("Redmond","Compactcar",102)); 
    carData.add(new CarEvent("Redmond","SmallSUV",637)); 
    carData.add(new CarEvent("Redmond","StationWagon",1079));
    carData.add(new CarEvent("Redmond","CompactCar",606));
    carData.add(new CarEvent("Redmond","Hybrid",1635));
    carData.add(new CarEvent("Redmond","Coupe",605)); 
    carData.add(new CarEvent("Redmond","Sedan",1568)); 
    carData.add(new CarEvent("Redmond","Convertible",955)); 
            
    carData.add(new CarEvent("ammamish","SportsCar",1)); 
    carData.add(new CarEvent("ammamish","Sedan",21)); 
            
    carData.add(new CarEvent("ellevue","MediumSUV",778));
    carData.add(new CarEvent("ellevue","LargeSUV",2035));
    carData.add(new CarEvent("ellevue","FamilySaloon",1952)); 
    carData.add(new CarEvent("ellevue","SportsCar",1226));
    carData.add(new CarEvent("ellevue","Compactcar",162));
    //aggDrivers.add(new CarEvent("ellevue","sports car",192)); 
    carData.add(new CarEvent("ellevue","SmallSUV",895));
    carData.add(new CarEvent("ellevue","StationWagon",1469));
    carData.add(new CarEvent("ellevue","CompactCar",629));
    carData.add(new CarEvent("ellevue","Hybrid",1989)); 
    carData.add(new CarEvent("ellevue","Coupe",811)); 
    carData.add(new CarEvent("ellevue","Sedan",2004));
    carData.add(new CarEvent("ellevue","Convertible",1122));*/

    Map<String, List<Map<String, String>>> cityModelsMap = new LinkedHashMap<>();
    for (CarEvent carEvent1 : carData) {
        Map<String, String> modelMap = new HashMap<>();
        List<Map<String, String>> modelCountsList = new ArrayList<>();
        if (!cityModelsMap.containsKey(carEvent1.getCity())) {
            modelMap.put(carEvent1.getModel(), carEvent1.getCount());
            modelCountsList.add(modelMap);
            cityModelsMap.put(carEvent1.getCity(), modelCountsList);
        } else {
            List<Map<String, String>> existingModelCountsList = cityModelsMap.get(carEvent1.getCity());

            modelMap.put(carEvent1.getModel(), carEvent1.getCount());
            modelCountsList.add(modelMap);
            existingModelCountsList.addAll(modelCountsList);
            cityModelsMap.put(carEvent1.getCity(), existingModelCountsList);
        }
    }
    System.out.println("CityModelMap:" + cityModelsMap);
    //CityModelMap:{city1=[{model1=41}, {model11=17}, {model12=36}], city2=[{model2=31}, {model22=37}], city3=[{model3=47}, {model33=31}]}
    DataTable data = new DataTable();
    data.addColumn(new ColumnDescription(CITY_COLUMN, ValueType.TEXT, "city"));
    for (String cityKey : cityModelsMap.keySet()) {
        List<Map<String, String>> existingModelCountsList = cityModelsMap.get(cityKey);
        for (Map existingModelCountMap : existingModelCountsList) {
            Set set = existingModelCountMap.keySet();
            for (Object objModel : set) {
                String model = objModel.toString();
                if (!(data.containsColumn(model))) {
                    data.addColumn(new ColumnDescription(model, ValueType.NUMBER, model));
                    System.out.println("Column added:" + model);
                }
            }
        }
    }

    for (String cityKey : cityModelsMap.keySet()) {
        TableRow row = new TableRow();
        for (ColumnDescription selectionColumn : data.getColumnDescriptions()) {
            String columnName = selectionColumn.getId();
            if (columnName.equals(CITY_COLUMN)) {
                row.addCell(cityKey);
                continue;
            }
            List<Map<String, String>> existingModelCountsList = cityModelsMap.get(cityKey);
            for (Map existingModelCountMap : existingModelCountsList) {
                for (Object objModel : existingModelCountMap.keySet()) {
                    String model = objModel.toString();
                    Integer count = Integer.parseInt(existingModelCountMap.get(objModel).toString());
                    System.out.println("Model :" + model + " Count:" + count);
                    if (columnName.equals(model)) {
                        row.addCell(count);
                        continue;
                    }
                }
            }
        }
        data.addRow(row);
        System.out.println("Adding row");
    }
    System.out.println("Data is now:" + data.toString());

}

From source file:com.jwm123.loggly.reporter.AppLauncher.java

public static void main(String args[]) throws Exception {
    try {/* www .j  a v a2 s .com*/
        CommandLine cl = parseCLI(args);
        try {
            config = new Configuration();
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("ERROR: Failed to read in persisted configuration.");
        }
        if (cl.hasOption("h")) {

            HelpFormatter help = new HelpFormatter();
            String jarName = AppLauncher.class.getProtectionDomain().getCodeSource().getLocation().getFile();
            if (jarName.contains("/")) {
                jarName = jarName.substring(jarName.lastIndexOf("/") + 1);
            }
            help.printHelp("java -jar " + jarName + " [options]", opts);
        }
        if (cl.hasOption("c")) {
            config.update();
        }
        if (cl.hasOption("q")) {
            Client client = new Client(config);
            client.setQuery(cl.getOptionValue("q"));
            if (cl.hasOption("from")) {
                client.setFrom(cl.getOptionValue("from"));
            }
            if (cl.hasOption("to")) {
                client.setTo(cl.getOptionValue("to"));
            }
            List<Map<String, Object>> report = client.getReport();

            if (report != null) {
                List<Map<String, String>> reportContent = new ArrayList<Map<String, String>>();
                ReportGenerator generator = null;
                if (cl.hasOption("file")) {
                    generator = new ReportGenerator(new File(cl.getOptionValue("file")));
                }
                byte reportFile[] = null;

                if (cl.hasOption("g")) {
                    System.out.println("Search results: " + report.size());
                    Set<Object> values = new TreeSet<Object>();
                    Map<Object, Integer> counts = new HashMap<Object, Integer>();
                    for (String groupBy : cl.getOptionValues("g")) {
                        for (Map<String, Object> result : report) {
                            if (mapContains(result, groupBy)) {
                                Object value = mapGet(result, groupBy);
                                values.add(value);
                                if (counts.containsKey(value)) {
                                    counts.put(value, counts.get(value) + 1);
                                } else {
                                    counts.put(value, 1);
                                }
                            }
                        }
                        System.out.println("For key: " + groupBy);
                        for (Object value : values) {
                            System.out.println("  " + value + ": " + counts.get(value));
                        }
                    }
                    if (cl.hasOption("file")) {
                        Map<String, String> reportAddition = new LinkedHashMap<String, String>();
                        reportAddition.put("Month", MONTH_FORMAT.format(new Date()));
                        reportContent.add(reportAddition);
                        for (Object value : values) {
                            reportAddition = new LinkedHashMap<String, String>();
                            reportAddition.put(value.toString(), "" + counts.get(value));
                            reportContent.add(reportAddition);
                        }
                        reportAddition = new LinkedHashMap<String, String>();
                        reportAddition.put("Total", "" + report.size());
                        reportContent.add(reportAddition);
                    }
                } else {
                    System.out.println("The Search [" + cl.getOptionValue("q") + "] yielded " + report.size()
                            + " results.");
                    if (cl.hasOption("file")) {
                        Map<String, String> reportAddition = new LinkedHashMap<String, String>();
                        reportAddition.put("Month", MONTH_FORMAT.format(new Date()));
                        reportContent.add(reportAddition);
                        reportAddition = new LinkedHashMap<String, String>();
                        reportAddition.put("Count", "" + report.size());
                        reportContent.add(reportAddition);
                    }
                }
                if (cl.hasOption("file")) {
                    reportFile = generator.build(reportContent);
                    File reportFileObj = new File(cl.getOptionValue("file"));
                    FileUtils.writeByteArrayToFile(reportFileObj, reportFile);
                    if (cl.hasOption("e")) {
                        ReportMailer mailer = new ReportMailer(config, cl.getOptionValues("e"),
                                cl.getOptionValue("s"), reportFileObj.getName(), reportFile);
                        mailer.send();
                    }
                }
            }
        }

    } catch (IllegalArgumentException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}

From source file:Main.java

public static String parseString(Object o) {
    return o.toString();
}

From source file:Main.java

public static String log(Object log) {
    return log.toString();
}

From source file:Main.java

public static void log(Object obj) {
    Log.d(TAG, obj.toString());
}

From source file:Main.java

/***These need to go away slowly ***/
public static String xmlResult(Object o) {
    return "<result>" + o.toString() + "</result>";
}

From source file:AIR.Common.Sql.DbHelper.java

public static Object isNullifyString(Object value) {
    if (value == null || value.toString().trim().equalsIgnoreCase("") || value.toString().length() < 1)
        return null;
    else/*from   w  w  w  .j ava 2 s. co m*/
        return value;
}