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.xproduct.server.core.Game.java

/**
 * The processRequest method consumes the incoming packet from the provided
 * WebSocket, and takes the socket identifier.
 *
 * @param packetData packetData from the socket
 * @param webSocket the socket/*from  ww  w . j a va 2 s .c  om*/
 * @return the response back to the user (immediate) if any
 * @throws GameProtocolException
 */
public void processRequest(String packetData, ServerWebSocket webSocket) {
    Object[] incomingObject = new Gson().fromJson(packetData, Object[].class);

    int packetTypeIdentifier = Converters.getInteger(0, incomingObject);
    C2SPacketType packetType = C2SPacketType.valueOf(packetTypeIdentifier);

    PacketController handler = null;

    switch (packetType) {
    case LOGIN:
        log.trace("Received LOGIN packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new LoginController(incomingObject, this, webSocket);
        break;
    case START_GAME:
        log.trace("Received START_GAME packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new StartGameController(incomingObject, this, webSocket);
        break;
    case POSITION:
        log.trace("Received POSITION packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new PositionController(incomingObject, this, webSocket);
        break;
    case CLOCK_SYNC:
        log.trace("Received CLOCK_SYNC packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new ClockSyncController(incomingObject, this, webSocket);
        break;
    case PLAYER_DIED:
        log.trace("Received PLAYER_DIED packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new PlayerDiedController(incomingObject, this, webSocket);
        break;
    case CHAT_MESSAGE:
        log.trace("Received CHAT_MESSAGE packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new ChatMessageController(incomingObject, this, webSocket);
        break;
    case SHIP_CHANGE:
        log.trace("Received SHIP_CHANGE packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new ShipChangeController(incomingObject, this, webSocket);
        break;
    case QUERY_NAME:
        log.trace("Received QUERY_NAME packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new QueryNameController(incomingObject, this, webSocket);
        break;
    case REGISTER_NAME:
        log.trace("Received REGISTER_NAME packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new RegisterNameController(incomingObject, this, webSocket);
        break;
    case PRIZE_COLLECTED:
        log.trace("Received PRIZE_COLLECTED packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new PrizeCollectedController(incomingObject, this, webSocket);
        break;
    case SET_PRESENCE:
        log.trace("Received SET_PRESENCE packet: " + Arrays.deepToString(incomingObject) + " from socket: "
                + webSocket.textHandlerID);
        handler = new SetPresenceController(incomingObject, this, webSocket);
        break;
    }
    try {
        handler.process();
    } catch (GameProtocolException ex) {
        log.error("Error", ex);
    }
}

From source file:org.alfresco.util.exec.RuntimeExecBeansTest.java

public void testSplitArgumentsAsSingleValue() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(APP_CONTEXT_XML);
    try {//  w w  w.  j  a va  2 s.c  o m
        RuntimeExec splitExec = (RuntimeExec) ctx.getBean("commandSplitArgumentsAsSingleValue");
        assertNotNull(splitExec);
        String[] splitCommand = splitExec.getCommand();
        assertTrue(
                "Command arguments not split into 'dir', '.' and '..' : " + Arrays.deepToString(splitCommand),
                Arrays.deepEquals(new String[] { "dir", ".", ".." }, splitCommand));
    } finally {
        ctx.close();
    }
}

From source file:org.ops4j.pax.url.commons.handler.HandlerActivator.java

/**
 * Performs cleanup:<br/>/*from w w  w .j ava2s .c  o  m*/
 * * Unregister handler;<br/>
 * * Unregister managed service;<br/>
 * * Release bundle context.
 *
 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
 */
public void stop(final BundleContext bundleContext) {
    NullArgumentException.validateNotNull(bundleContext, "Bundle context");
    if (m_handlerReg != null) {
        m_handlerReg.unregister();
    }
    if (m_managedServiceReg != null) {
        m_managedServiceReg.unregister();
    }
    m_bundleContext = null;
    LOG.debug("Handler for protocols " + Arrays.deepToString(m_protocols) + " stopped");
}

From source file:org.wso2.carbon.event.output.adaptor.logger.LoggerEventAdaptorType.java

/**
 * @param outputEventAdaptorMessageConfiguration
 *                 - topic name to publish messages
 * @param message  - is and Object[]{Event, EventDefinition}
 * @param outputEventAdaptorConfiguration
 *
 * @param tenantId/*from w  w w.  j a  va 2 s .c  o  m*/
 */
public void publish(OutputEventAdaptorMessageConfiguration outputEventAdaptorMessageConfiguration,
        Object message, OutputEventAdaptorConfiguration outputEventAdaptorConfiguration, int tenantId) {

    if (message instanceof Object[]) {
        log.info("Unique ID : "
                + outputEventAdaptorMessageConfiguration.getOutputMessageProperties()
                        .get(LoggerEventAdaptorConstants.ADAPTOR_MESSAGE_UNIQUE_ID)
                + " , Event : " + Arrays.deepToString((Object[]) message));
    } else {
        log.info(
                "Unique ID : "
                        + outputEventAdaptorMessageConfiguration.getOutputMessageProperties()
                                .get(LoggerEventAdaptorConstants.ADAPTOR_MESSAGE_UNIQUE_ID)
                        + " , Event : " + message);
    }
}

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

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

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

From source file:com.celements.pagetype.service.PageTypeService.java

private Set<PageTypeReference> getAllPageTypeRefs() {
    HashSet<PageTypeReference> pageTypeRefSet = new HashSet<PageTypeReference>();
    for (IPageTypeProviderRole pageTypeProvider : pageTypeProviders.values()) {
        for (PageTypeReference pageTypeRef : pageTypeProvider.getPageTypes()) {
            pageTypeRefSet.add(pageTypeRef);
        }//w w w .ja  v a  2  s  . c  om
    }
    LOGGER.debug("getAllPageTypeRefs: return " + Arrays.deepToString(pageTypeRefSet.toArray()));
    return pageTypeRefSet;
}

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

public Response read(String api, String action, String... params)
        throws SocketTimeoutException, URLTextGetter.ServerException, IOException {
    logger.log(Level.INFO, "Reading " + api + " action " + action + " " + Arrays.deepToString(params));
    String resp = URLTextGetter.getText(this.url, this.params(api, action, params));
    logger.log(Level.INFO, "Server response: " + resp);
    try {//from   www.java  2  s .c o m
        return new Response(new JSONObject(resp));
    } catch (JSONException e) {
        throw new URLTextGetter.ServerException(e.getMessage());
    }
}

From source file:com.celements.web.token.TokenLDAPAuthServiceImpl.java

public String getUsernameForToken(String userToken, XWikiContext context) throws XWikiException {

    String hashedCode = encryptString("hash:SHA-512:", userToken);
    String userDoc = "";

    if ((userToken != null) && (userToken.trim().length() > 0)) {

        String hql = ", BaseObject as obj, Classes.TokenClass as token where ";
        hql += "doc.space='XWiki' ";
        hql += "and obj.name=doc.fullName ";
        hql += "and token.tokenvalue=? ";
        hql += "and token.validuntil>=? ";
        hql += "and obj.id=token.id ";

        List<Object> parameterList = new Vector<Object>();
        parameterList.add(hashedCode);// ww  w .  j  a  va 2s .  c  om
        parameterList.add(new Date());

        XWikiStoreInterface storage = context.getWiki().getStore();
        List<String> users = storage.searchDocumentsNames(hql, 0, 0, parameterList, context);
        LOGGER.debug("searching token in db [" + context.getDatabase() + "] and found " + users.size()
                + " with parameters " + Arrays.deepToString(parameterList.toArray()));
        if (users == null || users.size() == 0) {
            String db = context.getDatabase();
            context.setDatabase("xwiki");
            users = storage.searchDocumentsNames(hql, 0, 0, parameterList, context);
            LOGGER.debug("searching token in db [" + context.getDatabase() + "] and found " + users.size()
                    + " with parameters " + Arrays.deepToString(parameterList.toArray()));
            if (users != null && users.size() == 1) {
                users.add("xwiki:" + users.remove(0));
            }
            context.setDatabase(db);
        }
        int usersFound = 0;
        for (String tmpUserDoc : users) {
            if (!tmpUserDoc.trim().equals("")) {
                usersFound++;
                userDoc = tmpUserDoc;
            }
        }
        if (usersFound > 1) {
            LOGGER.warn("Found more than one user for token '" + userToken + "'");
            return null;
        }
    } else {
        LOGGER.warn("No valid token given");
    }
    LOGGER.info("getUsernameForToken: returning user [" + userDoc + "].");
    return userDoc;
}

From source file:maltcms.ui.nb.pipelineRunner.actions.RunMaltcmsPipelinesAction.java

private Action[] buildActions(Lookup lookup) {
    final IChromAUIProject project = LookupUtils.ensureSingle(lookup, IChromAUIProject.class);
    Collection<Action> topLevelActions = new ArrayList<>();
    File projectPipelinesPath = new File(FileUtil.toFile(project.getLocation()), "pipelines");
    File[] maltcmsVersions = projectPipelinesPath.listFiles(new FileFilter() {
        @Override/*from ww  w.  j a  v a 2 s.  c  o m*/
        public boolean accept(File f) {
            return f.isDirectory();
        }
    });
    if (maltcmsVersions == null) {
        return new Action[0];
    }
    Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE, "Found maltcms versions: {0}",
            Arrays.deepToString(maltcmsVersions));
    for (File maltcmsVersion : maltcmsVersions) {
        Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                "Checking pipelines below {0}", maltcmsVersion);
        List<File> c = new ArrayList<>(FileUtils.listFiles(maltcmsVersion, new String[] { "mpl" }, true));
        Collections.sort(c, new Comparator<File>() {

            @Override
            public int compare(File o1, File o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                "Found {0} pipeline definitions!", c.size());
        Collection<Action> actions = new ArrayList<>();
        for (File pipelineFile : c) {
            FileObject fo = FileUtil.toFileObject(pipelineFile);
            Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE, "Adding pipeline {0}",
                    pipelineFile.getName());
            DataObject dobj;
            try {
                dobj = DataObject.find(fo);
                if (dobj instanceof MaltcmsPipelineFormatDataObject) {
                    final MaltcmsPipelineFormatDataObject mpfdo = (MaltcmsPipelineFormatDataObject) dobj;
                    AbstractAction pipelineRunAction = new AbstractAction(fo.getName()) {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            SwingUtilities.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                                            "Creating PipelineRunOpenSupport");
                                    PipelineRunOpenSupport pos = new PipelineRunOpenSupport(
                                            mpfdo.getPrimaryEntry());
                                    Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                                            "Calling pos.open()!");
                                    pos.open();
                                    Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                                            "Done!");
                                }
                            });
                        }
                    };
                    Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                            "Adding dataobject action");
                    actions.add(pipelineRunAction);
                    //                  subMenu.add(new JMenuItem(pipelineRunAction));
                }
            } catch (DataObjectNotFoundException ex) {
                Exceptions.printStackTrace(ex);
            }

        }
        Logger.getLogger(RunMaltcmsPipelinesAction.class.getName()).log(Level.FINE,
                "Adding {0} Pipeline specific actions!", actions.size());
        topLevelActions.add(Lookup.getDefault().lookup(INodeFactory.class)
                .createMenuItem(maltcmsVersion.getName(), actions.toArray(new Action[actions.size()])));
    }
    return topLevelActions.toArray(new Action[topLevelActions.size()]);
}

From source file:Methods.CalculusBisection.java

private static void datasetPointsBisection() {// Method used to retrieve data from stack and copy it in an array uset for the dataset

    data = new double[2][(S.size())];

    int i = (S.size() - 1);

    while (!S.isEmpty()) {//While used to retrieve data from stack
        data[0][i] = Double.parseDouble(S.popElement1().toString());
        data[1][i] = Double.parseDouble(S.popElement2().toString());
        i--;//  w  w  w.  j av  a2s . com
    }

    System.out.println("TEST DEEP ARRAY BISECTION: " + Arrays.deepToString(data));
    datasetPoints.addSeries("Iteration points", data);

}