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:org.rhq.plugins.jbossas.AbstractMessagingComponent.java

protected void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests, String pattern) {

    Set<MeasurementScheduleRequest> others = new HashSet<MeasurementScheduleRequest>();

    for (MeasurementScheduleRequest request : requests) {

        // Handle stuff for the generic Messaging MBeans ourselves. Pass the remainder
        // to our parent later.
        if (request.getName().startsWith(pattern)) {
            Matcher m = PROPERTY_PATTERN.matcher(request.getName());
            if (m.matches() && (m.group(1) != null)) {
                EmsBean eBean = getEmsConnection().getBean(m.group(1));

                List<String> attributes = new ArrayList<String>(1);
                attributes.add(m.group(2));
                eBean.refreshAttributes(attributes);
                EmsAttribute emsAtt = eBean.getAttribute(m.group(2));
                Object value = emsAtt.getValue();
                if ((request.getDataType() == DataType.MEASUREMENT) && (value instanceof Number)) {
                    report.addData(new MeasurementDataNumeric(request, ((Number) value).doubleValue()));
                } else if (request.getDataType() == DataType.TRAIT) {
                    String displayValue = null;
                    if ((value != null) && value.getClass().isArray()) {
                        displayValue = Arrays.deepToString((Object[]) value);
                    } else {
                        displayValue = String.valueOf(value);
                    }// w w  w.j  av a 2  s . c om

                    report.addData(new MeasurementDataTrait(request, displayValue));
                }
            }
        } else
            others.add(request);
    }

    super.getValues(report, others);
}

From source file:org.apache.rya.mongodb.document.util.DocumentVisibilityUtilTest.java

@Test
public void testBadExpressions() {
    int count = 1;
    for (final String booleanExpression : INVALID_BOOLEAN_EXPRESSIONS) {
        log.info("Invalid Test: " + count);
        try {//from ww w  .j a  v  a  2s .co  m
            log.info("Original: " + booleanExpression);
            // Convert to multidimensional array
            final DocumentVisibility dv = new DocumentVisibility(booleanExpression);
            final Object[] multidimensionalArray = DocumentVisibilityUtil.toMultidimensionalArray(dv);
            log.info("Array   : " + Arrays.deepToString(multidimensionalArray));

            // Convert multidimensional array back to string
            final String booleanString = DocumentVisibilityUtil
                    .multidimensionalArrayToBooleanString(multidimensionalArray);
            log.info("Result  : " + booleanString);

            // Compare results
            final String expected = new String(dv.flatten(), Charsets.UTF_8);
            assertEquals(expected, booleanString);
            fail("Bad expression passed.");
        } catch (final Exception e) {
            // Expected
        }
        log.info("===========================");
        count++;
    }
}

From source file:webreduce.indexing.datasetTools.java

public static void printTFMatrix(boolean[][] tfMatrix) {
    System.out.println(Arrays.deepToString(tfMatrix));
}

From source file:org.richfaces.tests.metamer.ftest.richTree.AbstractTestTreeSelection.java

protected void testSubNodesSelectionEvents() {
    expandAll();/*  w  ww.  ja v  a 2s . c om*/
    Integer[] old = null;
    for (Integer[] path : selectionPaths) {
        treeNode = null;
        for (int index : path) {
            treeNode = (treeNode == null) ? tree.getNode(index) : treeNode.getNode(index);
        }
        treeNode.select();
        assertEquals(getClientId(), "richTree");
        assertEquals(getSelection(), path,
                SimplifiedFormat.format("Actual Selection ({0}) doesn't correspond to expected ({1})",
                        Arrays.deepToString(getSelection()), Arrays.deepToString(path)));
        assertEquals(getNewSelection(), path,
                SimplifiedFormat.format("Actual New selection ({0}) doesn't correspond to expected ({1})",
                        Arrays.deepToString(getNewSelection()), Arrays.deepToString(path)));
        if (old != null) {
            assertEquals(getOldSelection(), old,
                    SimplifiedFormat.format("Actual Old selection ({0}) doesn't correspond to expected ({1})",
                            Arrays.deepToString(getOldSelection()), Arrays.deepToString(old)));
        } else {
            assertEquals(selenium.getText(oldSelection), "[]");
        }
        old = getNewSelection();
    }
}

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

@Test
public void hasActionOptionListInventoryWithJobId() {
    final String[] newArgs = Arrays.copyOf(args, args.length + 2);
    newArgs[newArgs.length - 2] = "--list-inventory";
    newArgs[newArgs.length - 1] = "inventory-job-id";

    final OptionSet optionSet = optionsParser.parse(newArgs);
    assertTrue("Option 'list-inventory' not found in " + Arrays.deepToString(optionSet.specs().toArray()),
            optionSet.has("list-inventory"));
    if (optionSet.hasArgument(optionsParser.INVENTORY_LISTING)) {
        assertEquals(/*from  w w w  . j ava2s.co  m*/
                "Value of option 'list-inventory' not found in "
                        + Arrays.deepToString(optionSet.specs().toArray()),
                "inventory-job-id", optionSet.valueOf("list-inventory"));
    }
}

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

/**
 * Bolt get saved and reloaded, this to redo the configurations.
 *//*from w  ww.java2s  . c  om*/
private void init() {
    log = Logger.getLogger(SiddhiBolt.class);

    inputThroughputProbe = new ThroughputProbe(logPrefix + "-IN", 10);
    emitThroughputProbe = new ThroughputProbe(logPrefix + " -EMIT", 10);

    inputThroughputProbe.startSampling();
    emitThroughputProbe.startSampling();

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

    for (String outputStreamDefinition : outputStreamDefinitions) {
        final StreamDefinition outputSiddhiDefinition = SiddhiCompiler
                .parseStreamDefinition(outputStreamDefinition);
        if (log.isDebugEnabled()) {
            log.debug(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()) {
                        log.debug(logPrefix + "Emitted Event:" + outputSiddhiDefinition.getId() + ":"
                                + Arrays.deepToString(eventData) + "@" + event.getTimestamp());
                    }

                    emitThroughputProbe.update();
                }
            }
        });
    }
    executionPlanRuntime.start();
}

From source file:io.fouad.jtb.core.beans.ReplyKeyboardMarkup.java

@Override
public String toString() {
    return "ReplyKeyboardMarkup{" + "keyboard=" + Arrays.deepToString(keyboard) + ", resizeKeyboard="
            + resizeKeyboard + ", oneTimeKeyboard=" + oneTimeKeyboard + ", selective=" + selective + '}';
}

From source file:fr.pasteque.data.loader.ServerLoader.java

public Response write(String api, String action, String... params)
        throws SocketTimeoutException, URLTextGetter.ServerException, IOException {
    logger.log(Level.INFO, "Writing " + api + " action " + action + " " + Arrays.deepToString(params));
    String resp = URLTextGetter.getText(this.url, null, this.params(api, action, params));
    logger.log(Level.INFO, "Server response: " + resp);
    try {/* w w w . j  a  v a2 s  .  com*/
        return new Response(new JSONObject(resp));
    } catch (JSONException e) {
        throw new URLTextGetter.ServerException(e.getMessage());
    }
}

From source file:com.moilioncircle.redis.replicator.RedisSocketReplicator.java

/**
 * PSYNC//  w  w  w . j a  v  a 2 s.  com
 *
 * @throws IOException when read timeout or connect timeout
 */
@Override
public void open() throws IOException {
    worker.start();
    for (int i = 0; i < configuration.getRetries() || configuration.getRetries() <= 0; i++) {
        try {
            connect();

            if (configuration.getAuthPassword() != null)
                auth(configuration.getAuthPassword());

            sendSlavePort();

            sendSlaveIp();

            sendSlaveCapa();

            //reset retries
            i = 0;

            logger.info("PSYNC " + configuration.getMasterRunId() + " "
                    + String.valueOf(configuration.getOffset()));
            send("PSYNC".getBytes(), configuration.getMasterRunId().getBytes(),
                    String.valueOf(configuration.getOffset()).getBytes());
            final String reply = (String) reply();

            SyncMode syncMode = trySync(reply);
            //bug fix.
            if (syncMode == SyncMode.PSYNC && connected.get()) {
                //heart beat send REPLCONF ACK ${slave offset}
                synchronized (this) {
                    heartBeat = new Timer("heart beat");
                    //bug fix. in this point closed by other thread. multi-thread issue
                    heartBeat.schedule(new TimerTask() {
                        @Override
                        public void run() {
                            try {
                                send("REPLCONF".getBytes(), "ACK".getBytes(),
                                        String.valueOf(configuration.getOffset()).getBytes());
                            } catch (IOException e) {
                                //NOP
                            }
                        }
                    }, configuration.getHeartBeatPeriod(), configuration.getHeartBeatPeriod());
                    logger.info("heart beat started.");
                }
            }
            //sync command
            while (connected.get()) {
                Object obj = replyParser.parse(new OffsetHandler() {
                    @Override
                    public void handle(long len) {
                        configuration.addOffset(len);
                    }
                });
                //command
                if (obj instanceof Object[]) {
                    if (configuration.isVerbose() && logger.isDebugEnabled())
                        logger.debug(Arrays.deepToString((Object[]) obj));

                    Object[] command = (Object[]) obj;
                    CommandName cmdName = CommandName.name((String) command[0]);
                    Object[] params = new Object[command.length - 1];
                    System.arraycopy(command, 1, params, 0, params.length);

                    final CommandParser<? extends Command> operations;
                    //if command do not register. ignore
                    if ((operations = commands.get(cmdName)) == null)
                        continue;

                    //do command replyParser
                    Command parsedCommand = operations.parse(cmdName, params);

                    //submit event
                    this.submitEvent(parsedCommand);
                } else {
                    if (logger.isInfoEnabled())
                        logger.info("Redis reply:" + obj);
                }
            }
            //connected = false
            break;
        } catch (/*bug fix*/IOException | InterruptedException e) {
            //close socket manual
            if (!connected.get()) {
                break;
            }
            logger.error("socket error", e);
            //connect refused
            //connect timeout
            //read timeout
            //connect abort
            //server disconnect connection EOFException
            close();
            //retry psync in next loop.
            logger.info("reconnect to redis-server. retry times:" + (i + 1));
            try {
                Thread.sleep(configuration.getRetryTimeInterval());
            } catch (InterruptedException e1) {
                //non interrupted
                logger.error("error", e1);
            }
        }
    }
    //
    if (worker != null && !worker.isClosed())
        worker.close();
}

From source file:org.richfaces.tests.metamer.ftest.richTree.TestTreeSelection.java

@Test
@Use(field = "selectionType", value = "eventEnabledSelectionTypes")
public void testSubNodesSelectionEvents() {
    expandAll();/*from   ww  w  .  j av  a2 s  . com*/
    Integer[] old = null;
    for (Integer[] path : selectionPaths) {
        treeNode = null;
        for (int index : path) {
            treeNode = (treeNode == null) ? tree.getNode(index) : treeNode.getNode(index);
        }
        treeNode.select();
        assertEquals(getClientId(), "richTree");
        assertEquals(getSelection(), path,
                SimplifiedFormat.format("Actual Selection ({0}) doesn't correspond to expected ({1})",
                        Arrays.deepToString(getSelection()), Arrays.deepToString(path)));
        assertEquals(getNewSelection(), path,
                SimplifiedFormat.format("Actual New selection ({0}) doesn't correspond to expected ({1})",
                        Arrays.deepToString(getNewSelection()), Arrays.deepToString(path)));
        if (old != null) {
            assertEquals(getOldSelection(), old,
                    SimplifiedFormat.format("Actual Old selection ({0}) doesn't correspond to expected ({1})",
                            Arrays.deepToString(getOldSelection()), Arrays.deepToString(old)));
        } else {
            assertEquals(selenium.getText(oldSelection), "[]");
        }
        old = getNewSelection();
    }
}