Example usage for java.util Arrays deepToString

List of usage examples for java.util Arrays deepToString

Introduction

In this page you can find the example usage for java.util Arrays deepToString.

Prototype

public static String deepToString(Object[] a) 

Source Link

Document

Returns a string representation of the "deep contents" of the specified array.

Usage

From source file:uk.ac.gla.terrier.probos.cli.qsub.java

/** Populates a job from the commandline arguments to Qsub */
public PBSJob createJob(String[] _args) throws Exception {
    CommandLine cmd = JobUtils.parseJobSubmission(_args);
    if (cmd.hasOption("help") || cmd.hasOption('h')) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("qsub", JobUtils.getOptions());
        return null;
    }/*from   ww w . j  ava 2s  .  c om*/
    if (cmd.hasOption('z'))
        quiet = true;
    if (cmd.hasOption('L')) {
        luaOnly = true;
        if (cmd.hasOption("withLuaHeaders"))
            luaHeaders = true;
        if (cmd.hasOption("np"))
            noProbos = true;
    }

    String[] args = cmd.getArgs();
    if (args.length > 1) {
        //System.err.println(cmd.hasOption("N"));
        throw new IllegalArgumentException("Only one file allowed, but received " + Arrays.deepToString(_args)
                + ", found " + Arrays.deepToString(args));
    }
    //System.err.println("received "+
    //         Arrays.deepToString(_args) +", found " + Arrays.deepToString(args));
    String jobName;
    String jobFilename;
    if (cmd.hasOption('I')) {
        interactive = true;
        //we dont read files
        jobName = "Interactive";
        jobFilename = "Interactive";
    } else if (args.length == 0 || args[0].equals("-")) {
        File tempJobFile = File.createTempFile("jobScript", ".pbs");
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempJobFile));
        BufferedInputStream bis = new BufferedInputStream(System.in);
        IOUtils.copyBytes(bis, bos, 4096);
        bis.close();
        bos.close();
        jobFilename = tempJobFile.toString();
        jobName = "STDIN";

    } else {
        jobFilename = args[0];
        jobName = new File(jobFilename).getName();
    }
    PBSJob job = JobUtils.createNewJob(jobName);

    String directivePrefix = Constants.DIRECTIVE_PREFIX;
    if (System.getenv("PBS_DPREFIX") != null) {
        directivePrefix = System.getenv("PBS_DPREFIX").trim();
    }
    if (cmd.hasOption('C')) {
        directivePrefix = cmd.getOptionValue('C').trim();
    }
    if (!interactive && directivePrefix.length() > 0 && !directivePrefix.equalsIgnoreCase("null")) {
        String[] file = Utils.slurpString(new File(jobFilename));
        int i = 0;
        for (String line : file) {
            if (i == 0 && (line.startsWith(":") || line.startsWith("#!")))
                continue;
            if (line.startsWith(directivePrefix + " ")) {
                String[] lineargs = line.replaceFirst("^" + directivePrefix + " ", "").split(" ");
                CommandLine cmdLine = JobUtils.parseJobSubmission(lineargs);
                JobUtils.parseArgs(cmdLine, job);
            }
            //Scanning will continue until the first executable line, that is a 
            //line that is not blank, not a directive line, nor a line whose first 
            //non white space character is "#". If directives occur on subsequent 
            //lines, they will be ignored.
            else if (!line.replaceFirst("^\\s+", "").startsWith("#"))
                break;
            i++;
        }
    }
    //commandline arguments overrule 
    JobUtils.parseArgs(cmd, job);

    job.setCommand(new File(jobFilename).getCanonicalPath());
    JobUtils.finaliseJob(job);
    JobUtils.verifyJob(job);
    return job;
}

From source file:org.eclipse.virgo.ide.management.remote.StandardBundleAdmin.java

@ManagedOperation(description = "Returns the current OSGi Bundles")
public Map<Long, Bundle> retrieveBundles() {
    Map<Long, Bundle> bundles = new HashMap<Long, Bundle>();
    for (org.osgi.framework.Bundle b : this.bundleContext.getBundles()) {

        Object version = b.getHeaders().get("Bundle-Version");
        Bundle bundle = new Bundle(Long.toString(b.getBundleId()), b.getSymbolicName(),
                version != null ? version.toString() : "0", getState(b), b.getLocation());

        Dictionary<?, ?> headers = b.getHeaders();
        Enumeration<?> keys = headers.keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = headers.get(key);
            bundle.addHeader(key.toString(), value.toString());
        }//www .  j  a  va 2  s  . com

        BundleDescription bundleDescription = this.platformAdmin.getState(false).getBundle(b.getBundleId());

        ExportPackageDescription[] exportedPackages = bundleDescription.getExportPackages();

        if (exportedPackages != null) {
            for (ExportPackageDescription exportedPackage : exportedPackages) {
                PackageExport packageExport = new PackageExport(exportedPackage.getName(),
                        exportedPackage.getVersion() != null ? exportedPackage.getVersion().toString() : "0");
                bundle.addPackageExport(packageExport);
            }
        }

        ExportPackageDescription[] visiblePackages = this.platformAdmin.getStateHelper()
                .getVisiblePackages(bundleDescription);

        if (visiblePackages != null) {
            for (ExportPackageDescription visiblePackage : visiblePackages) {
                PackageImport packageImport = new PackageImport(visiblePackage.getName(),
                        visiblePackage.getVersion() != null ? visiblePackage.getVersion().toString() : "0",
                        Long.toString(visiblePackage.getSupplier().getBundleId()));
                bundle.addPackageImport(packageImport);
            }
        }

        if (b.getRegisteredServices() != null) {
            for (ServiceReference ref : b.getRegisteredServices()) {
                org.eclipse.virgo.ide.management.remote.ServiceReference reference = new org.eclipse.virgo.ide.management.remote.ServiceReference(
                        Type.REGISTERED, ref.getBundle().getBundleId(),
                        OsgiServiceReferenceUtils.getServiceObjectClasses(ref));
                Map<?, ?> props = OsgiServiceReferenceUtils.getServicePropertiesAsMap(ref);
                for (Object key : props.keySet()) {
                    String value = props.get(key).toString();
                    if (props.get(key).getClass().isArray()) {
                        value = Arrays.deepToString((Object[]) props.get(key));
                    }
                    reference.addProperty(key.toString(), value);
                }

                if (ref.getUsingBundles() != null) {
                    for (org.osgi.framework.Bundle usingBundle : ref.getUsingBundles()) {
                        reference.addUsingBundle(usingBundle.getBundleId());
                    }
                }
                bundle.addRegisteredService(reference);
            }
        }

        if (b.getServicesInUse() != null) {
            for (ServiceReference ref : b.getServicesInUse()) {
                org.eclipse.virgo.ide.management.remote.ServiceReference reference = new org.eclipse.virgo.ide.management.remote.ServiceReference(
                        Type.IN_USE, ref.getBundle().getBundleId(),
                        OsgiServiceReferenceUtils.getServiceObjectClasses(ref));
                Map<?, ?> props = OsgiServiceReferenceUtils.getServicePropertiesAsMap(ref);
                for (Object key : props.keySet()) {
                    String value = props.get(key).toString();
                    if (props.get(key).getClass().isArray()) {
                        value = Arrays.deepToString((Object[]) props.get(key));
                    }
                    reference.addProperty(key.toString(), value);
                }

                if (ref.getUsingBundles() != null) {
                    for (org.osgi.framework.Bundle usingBundle : ref.getUsingBundles()) {
                        reference.addUsingBundle(usingBundle.getBundleId());
                    }
                }
                bundle.addUsingService(reference);
            }
        }

        bundles.put(Long.valueOf(bundle.getId()), bundle);
    }
    return bundles;
}

From source file:de.hybris.platform.test.InvalidationSetTest.java

private void assertInvalidated(final InvalidationSet set, final Object... key) {
    final Object[] keys = asKey(key);
    assertTrue("key " + Arrays.deepToString(keys) + " is not invalidated", set.isInvalidated(keys));
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.java

@Override
public String toString() {
    return "LoginProcessBean(" + hashCode() + ")[state=" + currentState + ", message=" + message
            + ", messageArguments=" + Arrays.deepToString(messageArguments) + ", username=" + username
            + ", loginPageUrl=" + loginPageUrl + ", afterLoginUrl=" + afterLoginUrl + "]";
}

From source file:de.kopis.glacier.parsers.GlacierUploaderOptionParserTest.java

@Test
public void hasActionOptionDeleteVault() {
    final String[] newArgs = Arrays.copyOf(args, args.length + 1);
    newArgs[newArgs.length - 1] = "--delete-vault";

    final OptionSet optionSet = optionsParser.parse(newArgs);
    assertTrue("Option 'delete-vault' not found in " + Arrays.deepToString(optionSet.specs().toArray()),
            optionSet.has("delete-vault"));
}

From source file:org.graphwalker.machines.ExtendedFiniteStateMachine.java

/**
 * Walks the data space, and returns all data as an json object.
 * /* ww  w. j av a  2  s  .  co m*/
 * @param dataName
 * @return json object of the data space
 */
@SuppressWarnings("unchecked")
public ArrayList<JSONObject> getDataAsJSON() {
    ArrayList<JSONObject> data = new ArrayList<JSONObject>();

    if (beanShellEngine != null) {
        Hashtable<String, Object> dataTable = getCurrentBeanShellData();
        Enumeration<String> enumKey = dataTable.keys();
        while (enumKey.hasMoreElements()) {
            JSONObject jsonObj = new JSONObject();
            String key = enumKey.nextElement();
            String value = null;
            if (dataTable.get(key) instanceof Object[]) {
                value = Arrays.deepToString((Object[]) dataTable.get(key));
            } else {
                value = dataTable.get(key).toString();
            }
            jsonObj.put("name", key);
            jsonObj.put("value", value);
            data.add(jsonObj);
        }
    }
    return data;
}

From source file:org.wso2.carbon.event.processor.common.storm.component.EventPublisherBolt.java

private void init() {
    try {/*from   w  ww  .ja  v  a  2 s. c  om*/
        log = Logger.getLogger(EventPublisherBolt.class);
        initialized = true;
        //Adding functionality to support query execution at publisher level for future use cases.
        if (query != null && (!query.isEmpty())) {
            siddhiManager = new SiddhiManager();
            eventCount = 0;
            batchStartTime = System.currentTimeMillis();
            log = Logger.getLogger(SiddhiBolt.class);

            String fullQueryExpression = Utils.constructQueryExpression(inputStreamDefinitions,
                    outputStreamDefinitions, query);
            executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(fullQueryExpression);

            for (String outputStreamDefinition : outputStreamDefinitions) {
                final StreamDefinition outputSiddhiDefinition = SiddhiCompiler
                        .parseStreamDefinition(outputStreamDefinition);
                log.info(logPrefix + "Adding callback for stream:" + outputSiddhiDefinition.getId());
                executionPlanRuntime.addCallback(outputSiddhiDefinition.getId(), new StreamCallback() {

                    @Override
                    public void receive(Event[] events) {
                        for (Event event : events) {
                            Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1);
                            eventData[event.getData().length] = event.getTimestamp();
                            collector.emit(outputSiddhiDefinition.getId(), Arrays.asList(eventData));
                            if (log.isDebugEnabled()) {
                                if (++eventCount % 10000 == 0) {
                                    double timeSpentInSecs = (System.currentTimeMillis() - batchStartTime)
                                            / 1000.0D;
                                    double throughput = 10000 / timeSpentInSecs;
                                    log.debug(logPrefix + "Processed 10000 events in " + timeSpentInSecs + " "
                                            + "seconds, throughput : " + throughput + " events/sec. Stream : "
                                            + outputSiddhiDefinition.getId());
                                    eventCount = 0;
                                    batchStartTime = System.currentTimeMillis();
                                }
                                log.debug(logPrefix + "Emitted Event:" + outputSiddhiDefinition.getId() + ":"
                                        + Arrays.deepToString(eventData) + "@" + event.getTimestamp());
                            }
                        }
                    }
                });

            }
            executionPlanRuntime.start();
        }
        streamIdToDefinitionMap = new HashMap<String, StreamDefinition>();
        StreamDefinition siddhiDefinition;
        for (String outputStreamDefinition : outputStreamDefinitions) {
            siddhiDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition);
            streamIdToDefinitionMap.put(siddhiDefinition.getId(), siddhiDefinition);
        }

        asyncEventPublisher = new AsyncEventPublisher(AsyncEventPublisher.DestinationType.CEP_PUBLISHER,
                new HashSet<StreamDefinition>(streamIdToDefinitionMap.values()),
                stormDeploymentConfig.getManagers(), executionPlanName, tenantId, stormDeploymentConfig, null);

        asyncEventPublisher.initializeConnection(false);
    } catch (Throwable e) {
        log.error(logPrefix + "Error starting event publisher bolt: " + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.event.simulator.csvFeedSimulation.core.CSVFeedEventSimulator.java

/**
 * This method must be called within a synchronized block to avoid multiple file simulators from running simultaneously.
 * Read the values from uploaded CSV file and convert those values into event and send those events to
 * input handler//from   w ww  .j  a v a 2s .c  om
 * <p>
 * <p>
 * To read the CSV file It uses CSV parser Library.
 * {@link <a href="https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVParser.html">CSVParser</a>}
 * </p>
 * <p>
 * <p>
 * CSV file can be separated by one of these fallowing character , , ; , \t by default
 * It has capability to have user defined delimiter
 * Any field may be quoted (with double quotes)
 * Fields with embedded commas or delimiter characters must be double quoted.
 * </p>
 * <p>
 * Initialize CSVParser
 *
 * @param executionPlanDto ExecutionPlanDto
 * @param csvFileConfig    CSVFileSimulationDto
 */
private void sendEvent(ExecutionPlanDto executionPlanDto, CSVFileSimulationDto csvFileConfig) {

    /*
      return no of events read from CSV file during ever iteration
     */
    long noOfEvents = 0;
    int delay = csvFileConfig.getDelay();
    /*
    Reader for reading character streams from file
     */
    Reader in = null;
    /*
    CSVParser to read CSV Values
     */
    CSVParser csvParser = null;
    if (delay <= 0) {
        log.warn("Events will be sent continuously since the delay between events are set to " + delay
                + "milliseconds");
        delay = 0;
    }

    try {
        /*
        Initialize Reader
         */
        in = new FileReader(String.valueOf(Paths.get(System.getProperty("java.io.tmpdir"),
                csvFileConfig.getFileDto().getFileInfo().getFileName())));

        /*
        Initialize CSVParser with appropriate CSVFormat according to delimiter
         */

        switch (csvFileConfig.getDelimiter()) {
        case ",":
            csvParser = CSVParser.parse(in, CSVFormat.DEFAULT);
            break;
        case ";":
            csvParser = CSVParser.parse(in, CSVFormat.EXCEL);
            break;
        case "\\t":
            csvParser = CSVParser.parse(in, CSVFormat.TDF);
            break;
        default:
            csvParser = CSVParser.parse(in, CSVFormat.newFormat(csvFileConfig.getDelimiter().charAt(0)));
        }

        int attributeSize = executionPlanDto.getInputStreamDtoMap().get(csvFileConfig.getStreamName())
                .getStreamAttributeDtos().size();

        /*
        Iterate through the CSV file line by line
         */

        for (CSVRecord record : csvParser) {
            try {
                synchronized (this) {
                    if (isStopped) {
                        isStopped = false;
                        break;
                    }
                    if (isPaused) {
                        this.wait();
                    }
                }

                if (record.size() != attributeSize) {
                    log.warn("No of attribute is not equal to attribute size: " + attributeSize + " is needed"
                            + "in Row no:" + noOfEvents + 1);
                }
                String[] attributes = new String[attributeSize];
                noOfEvents = csvParser.getCurrentLineNumber();

                for (int i = 0; i < record.size(); i++) {
                    attributes[i] = record.get(i);
                }

                //convert Attribute values into event
                Event event = EventConverter.eventConverter(csvFileConfig.getStreamName(), attributes,
                        executionPlanDto);
                // TODO: 13/12/16 delete sout
                System.out.println("Input Event " + Arrays.deepToString(event.getEventData()));
                //

                //send the event to input handler
                send(csvFileConfig.getStreamName(), event);

                //delay between two events
                if (delay > 0) {
                    Thread.sleep(delay);
                }
            } catch (EventSimulationException e) {
                log.error("Event dropped due to Error occurred during generating an event" + e.getMessage());
            } catch (InterruptedException e) {
                log.error("Error occurred during send event" + e.getMessage());
            }
        }

    } catch (IllegalArgumentException e) {
        // TODO: 02/12/16 proper error message
        throw new EventSimulationException("File Parameters are null" + e.getMessage());
    } catch (FileNotFoundException e) {
        throw new EventSimulationException(
                "File not found :" + csvFileConfig.getFileDto().getFileInfo().getFileName());
    } catch (IOException e) {
        throw new EventSimulationException("Error occurred while reading the file");
    } finally {
        try {
            if (in != null && csvParser != null)
                in.close();
            csvParser.close();
        } catch (IOException e) {
            throw new EventSimulationException("Error occurred during closing the file");
        }
    }
}

From source file:de.hybris.platform.test.InvalidationSetTest.java

private void assertNotInvalidated(final InvalidationSet set, final Object... key) {
    final Object[] keys = asKey(key);
    assertFalse("key " + Arrays.deepToString(keys) + " is wrongly invalidated", set.isInvalidated(keys));
}

From source file:com.jivesoftware.os.upena.uba.service.InstancePath.java

@Override
public String toString() {
    return "InstancePath{" + "root=" + root + ", path=" + Arrays.deepToString(path) + '}';
}