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:com.gs.obevo.db.impl.core.changetypes.CsvStaticDataDeployer.java

/**
 * Note - we still need the PhysicalSchema object, as the schema coming from sybase may still have "dbo" there.
 * Until we abstract this in the metadata API, we go w/ the signature as is
 *
 * Also - this can be overridable in case we want to support bulk-inserts for specific database types,
 * e.g. Sybase IQ//from   w w w . ja v a2s .c  om
 *
 * We only use batching for "executeInserts" as that is the 90% case of the performance
 * (updates may vary the kinds of sqls that are needed, and deletes I'd assume are rare)
 */
protected void executeInserts(Connection conn, StaticDataChangeRows changeRows) {
    if (changeRows.getInsertRows().isEmpty()) {
        return;
    }

    StaticDataInsertRow changeFormat = changeRows.getInsertRows().getFirst();

    String[] paramValMarkers = new String[changeFormat.getInsertColumns().size()];
    Arrays.fill(paramValMarkers, "?");
    MutableList<String> insertValues = Lists.mutable.with(paramValMarkers);

    String sql = "INSERT INTO " + dbPlatform.getSchemaPrefix(changeRows.getSchema())
            + changeRows.getTable().getName() + changeFormat.getInsertColumns().makeString("(", ", ", ")")
            + " VALUES " + insertValues.makeString("(", ", ", ")");
    LOG.info("Executing the insert " + sql);

    // TODO parameterize this chunk value - sybase sometimes cannot take a large chunk
    for (RichIterable<StaticDataInsertRow> chunkInsertRows : changeRows.getInsertRows().chunk(25)) {
        final Object[][] paramArrays = new Object[chunkInsertRows.size()][];
        chunkInsertRows.forEachWithIndex(new ObjectIntProcedure<StaticDataInsertRow>() {
            @Override
            public void value(StaticDataInsertRow insert, int i) {
                MutableList<Object> paramVals = insert.getParamVals();
                paramArrays[i] = paramVals.toArray(new Object[0]);
            }
        });

        if (LOG.isDebugEnabled()) {
            LOG.debug("for " + paramArrays.length + " rows with params: " + Arrays.deepToString(paramArrays));
        }
        try {
            this.jdbcTemplate.batchUpdate(conn, sql, paramArrays);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }
}

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

@Override
public String toString() {
    return "Message{" + "messageId=" + messageId + ", from=" + from + ", date=" + date + ", chat=" + chat
            + ", forwardFrom=" + forwardFrom + ", forwardFromChat=" + forwardFromChat + ", forwardDate="
            + forwardDate + ", replyToMessage=" + replyToMessage + ", editDate=" + editDate + ", text='" + text
            + '\'' + ", entities=" + Arrays.deepToString(entities) + ", audio=" + audio + ", document="
            + document + ", photo=" + Arrays.deepToString(photo) + ", sticker=" + sticker + ", video=" + video
            + ", voice=" + voice + ", caption='" + caption + '\'' + ", contact=" + contact + ", location="
            + location + ", venue=" + venue + ", newChatMember=" + newChatMember + ", leftChatMember="
            + leftChatMember + ", newChatTitle='" + newChatTitle + '\'' + ", newChatPhoto="
            + Arrays.deepToString(newChatPhoto) + ", deleteChatPhoto=" + deleteChatPhoto + ", groupChatCreated="
            + groupChatCreated + ", superGroupChatCreated=" + superGroupChatCreated + ", channelChatCreated="
            + channelChatCreated + ", migrateToChatId=" + migrateToChatId + ", migrateFromChatId="
            + migrateFromChatId + ", pinnedMessage=" + pinnedMessage + '}';
}

From source file:org.freedesktop.dbus.Message.java

/**
 * Formats the message in a human-readable format.
 *//*from w  ww .  j  a v  a2  s.  c  om*/
@Override
public String toString() {
    StringBuffer sb = new StringBuffer();
    sb.append(getClass().getSimpleName());
    sb.append('(');
    sb.append(this.flags);
    sb.append(',');
    sb.append(this.serial);
    sb.append(')');
    sb.append(' ');
    sb.append('{');
    sb.append(' ');
    if (this.headers.size() == 0)
        sb.append('}');
    else {
        for (Byte field : this.headers.keySet()) {
            sb.append(getHeaderFieldName(field));
            sb.append('=');
            sb.append('>');
            sb.append(this.headers.get(field).toString());
            sb.append(',');
            sb.append(' ');
        }
        sb.setCharAt(sb.length() - 2, ' ');
        sb.setCharAt(sb.length() - 1, '}');
    }
    sb.append(' ');
    sb.append('{');
    sb.append(' ');
    Object[] params = null;
    try {
        params = getParameters();
    } catch (DBusException DBe) {
        log.warn("Failed to get parameters", DBe);
    }
    if (null == params || 0 == params.length)
        sb.append('}');
    else {
        for (Object o : params) {
            if (o instanceof Object[])
                sb.append(Arrays.deepToString((Object[]) o));
            else if (o instanceof byte[])
                sb.append(Arrays.toString((byte[]) o));
            else if (o instanceof int[])
                sb.append(Arrays.toString((int[]) o));
            else if (o instanceof short[])
                sb.append(Arrays.toString((short[]) o));
            else if (o instanceof long[])
                sb.append(Arrays.toString((long[]) o));
            else if (o instanceof boolean[])
                sb.append(Arrays.toString((boolean[]) o));
            else if (o instanceof double[])
                sb.append(Arrays.toString((double[]) o));
            else if (o instanceof float[])
                sb.append(Arrays.toString((float[]) o));
            else
                sb.append(o.toString());
            sb.append(',');
            sb.append(' ');
        }
        sb.setCharAt(sb.length() - 2, ' ');
        sb.setCharAt(sb.length() - 1, '}');
    }
    return sb.toString();
}

From source file:com.celements.calendar.Event.java

public List<List<String>> getEditableProperties(String lang) throws XWikiException {
    Set<String> confIndep = new HashSet<String>();
    Set<String> confDep = new HashSet<String>();
    splitLanguageDependentFields(confIndep, confDep, splitIntoPropertyNames(getCalendar().getOverviewFields()));
    splitLanguageDependentFields(confIndep, confDep,
            splitIntoPropertyNames(getCalendar().getDetailviewFields()));
    if (getCalendar().isSubscribable()) {
        confIndep.add(CelementsCalendarPlugin.PROPERTY_EVENT_IS_SUBSCRIBABLE);
    }// w ww .  j ava 2  s . c  o  m
    Element[] allProps = getProperties(lang);
    LOGGER.debug("getEditableProperties: allProps - " + Arrays.deepToString(allProps));
    LOGGER.debug("getEditableProperties: confIndep - " + Arrays.deepToString(confIndep.toArray()));
    LOGGER.debug("getEditableProperties: confDep - " + Arrays.deepToString(confDep.toArray()));
    List<String> lIndependantProps = getProps(allProps, confIndep);
    List<String> lDependantProps = getProps(allProps, confDep);
    List<List<String>> editProp = new ArrayList<List<String>>();
    editProp.add(lIndependantProps);
    editProp.add(lDependantProps);
    LOGGER.debug("getEditableProperties: return editProp - " + Arrays.deepToString(editProp.toArray()));
    return editProp;
}

From source file:net.sourceforge.seqware.pipeline.plugins.BatchMetadataInjectionTest.java

private void runFileLinkerPlugin(String fileLinkerPath, String wfaccession) throws IOException {

    String[] fileLinkerParams = { "--file-list-file", fileLinkerPath, "--workflow-accession", wfaccession,
            "--csv-separator", "," };
    PluginRunner p = new PluginRunner();
    List<String> a = new ArrayList<String>();
    a.add("--plugin");
    a.add(FileLinker.class.getCanonicalName());
    a.add("--");//ww w. j a va2s.  c  om
    a.addAll(Arrays.asList(fileLinkerParams));
    System.out.println(Arrays.deepToString(a.toArray()));

    p.run(a.toArray(new String[a.size()]));

}

From source file:de.icongmbh.oss.maven.plugin.javassist.JavassistTransformerExecutor.java

private void debugClassFile(final ClassFile classFile) {
    if (!LOGGER.isDebugEnabled()) {
        return;//from   w w w  .  ja v  a2  s. c o  m
    }
    LOGGER.debug(" - class: {}", classFile.getName());
    LOGGER.debug(" -- Java version: {}.{}", classFile.getMajorVersion(), classFile.getMinorVersion());
    LOGGER.debug(" -- interface: {} abstract: {} final: {}", classFile.isInterface(), classFile.isAbstract(),
            classFile.isFinal());
    LOGGER.debug(" -- extends class: {}", classFile.getSuperclass());
    LOGGER.debug(" -- implements interfaces: {}", Arrays.deepToString(classFile.getInterfaces()));
}

From source file:com.celements.navigation.service.TreeNodeService.java

TreeNode getSiblingMenuItem(DocumentReference docRef, boolean previous) throws XWikiException {
    XWikiDocument doc = getContext().getWiki().getDocument(docRef, getContext());
    BaseObject menuItem = doc.getXObject(getRef("Celements2", "MenuItem"));
    if (menuItem != null) {
        try {/*  w w w.j  a va2 s .c  om*/
            EntityReference parent = getParentEntityRef(docRef);
            List<TreeNode> subMenuItems = getSubNodesForParent(parent, menuItem.getStringValue("part_name"));
            LOGGER.debug("getPrevMenuItem: " + subMenuItems.size() + " subMenuItems found for parent '" + parent
                    + "'. " + Arrays.deepToString(subMenuItems.toArray()));
            int pos = getMenuItemPos(docRef, menuItem.getStringValue("part_name"));
            if (previous && (pos > 0)) {
                return subMenuItems.get(pos - 1);
            } else if (!previous && (pos < (subMenuItems.size() - 1))) {
                return subMenuItems.get(pos + 1);
            }
            LOGGER.info("getPrevMenuItem: no previous MenuItem found for " + getParentKey(docRef, true));
        } catch (XWikiException e) {
            LOGGER.error(e);
        }
    } else {
        LOGGER.debug("getPrevMenuItem: no MenuItem Object found on doc " + getParentKey(docRef, true));
    }
    return null;
}

From source file:de.icongmbh.oss.maven.plugin.javassist.JavassistTransformerExecutor.java

private void debugClassLoader(final ClassPool classPool) {
    if (!LOGGER.isDebugEnabled()) {
        return;/*ww  w . j  av a2  s. co  m*/
    }
    LOGGER.debug(" - classPool: {}", classPool.toString());
    ClassLoader classLoader = classPool.getClassLoader();
    while (classLoader != null) {
        LOGGER.debug(" -- {}: {}", classLoader.getClass().getName(), classLoader.toString());
        if (classLoader instanceof URLClassLoader) {
            LOGGER.debug(" --- urls: {}", Arrays.deepToString(((URLClassLoader) classLoader).getURLs()));
        }
        classLoader = classLoader.getParent();
    }
}

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

/**
 * Executes the statement that this instance was constructed with an optional
 * timeout after which the command is asked to 
 * /*from   www . ja v a 2  s.  c o  m*/
 * @param properties the properties that the command might be executed with.
 * <code>null</code> properties will be treated as an empty string for substitution
 * purposes.
 * @param timeoutMs a timeout after which {@link Process#destroy()} is called.
 *        ignored if less than or equal to zero. Note this method does not guarantee
 *        to terminate the process (it is not a kill -9).
 * 
 * @return Returns the full execution results
 */
public ExecutionResult execute(Map<String, String> properties, final long timeoutMs) {
    int defaultFailureExitValue = errCodes.size() > 0 ? ((Integer) errCodes.toArray()[0]) : 1;

    // check that the command has been set
    if (command == null) {
        throw new AlfrescoRuntimeException("Runtime command has not been set: \n" + this);
    }

    // create the properties
    Runtime runtime = Runtime.getRuntime();
    Process process = null;
    String[] commandToExecute = null;
    try {
        // execute the command with full property replacement
        commandToExecute = getCommand(properties);
        final Process thisProcess = runtime.exec(commandToExecute, processProperties, processDirectory);
        process = thisProcess;
        if (timeoutMs > 0) {
            final String[] command = commandToExecute;
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    // Only try to kill the process if it is still running
                    try {
                        thisProcess.exitValue();
                    } catch (IllegalThreadStateException stillRunning) {
                        if (transformerDebugLogger.isDebugEnabled()) {
                            transformerDebugLogger.debug("Process has taken too long (" + (timeoutMs / 1000)
                                    + " seconds). Killing process " + Arrays.deepToString(command));
                        }
                        thisProcess.destroy();
                    }
                }
            }, timeoutMs);
        }
    } catch (IOException e) {
        // The process could not be executed here, so just drop out with an appropriate error state
        String execOut = "";
        String execErr = e.getMessage();
        int exitValue = defaultFailureExitValue;
        ExecutionResult result = new ExecutionResult(null, commandToExecute, errCodes, exitValue, execOut,
                execErr);
        logFullEnvironmentDump(result);
        return result;
    }

    // create the stream gobblers
    InputStreamReaderThread stdOutGobbler = new InputStreamReaderThread(process.getInputStream(), charset);
    InputStreamReaderThread stdErrGobbler = new InputStreamReaderThread(process.getErrorStream(), charset);

    // start gobbling
    stdOutGobbler.start();
    stdErrGobbler.start();

    // wait for the process to finish
    int exitValue = 0;
    try {
        if (waitForCompletion) {
            exitValue = process.waitFor();
        }
    } catch (InterruptedException e) {
        // process was interrupted - generate an error message
        stdErrGobbler.addToBuffer(e.toString());
        exitValue = defaultFailureExitValue;
    }

    if (waitForCompletion) {
        // ensure that the stream gobblers get to finish
        stdOutGobbler.waitForCompletion();
        stdErrGobbler.waitForCompletion();
    }

    // get the stream values
    String execOut = stdOutGobbler.getBuffer();
    String execErr = stdErrGobbler.getBuffer();

    // construct the return value
    ExecutionResult result = new ExecutionResult(process, commandToExecute, errCodes, exitValue, execOut,
            execErr);

    // done
    logFullEnvironmentDump(result);
    return result;
}

From source file:org.nextframework.persistence.GenericDAO.java

@SuppressWarnings("unchecked")
public List<BEAN> findBy(Object o, boolean forCombo, String... extraFields) {
    if (o == null) {
        return new ArrayList<BEAN>();
    }//from  w  w w  .jav  a 2 s. co  m
    Class<? extends Object> propertyClass = o.getClass();
    while (propertyClass.getName().contains("$$")) {
        propertyClass = propertyClass.getSuperclass();
    }
    String queryString = null;
    if ((extraFields != null && extraFields.length > 0)
            || (forCombo && (queryString = mapaQueryFindByForCombo.get(propertyClass)) == null)
            || (!forCombo && (queryString = mapaQueryFindBy.get(propertyClass)) == null)) {
        //inicializa a query para essa classe
        //System.out.println("\n\n\nLOADING CLASSE "+this.beanClass+"  PROPRIEDADE CLASSE: "+o.getClass());
        String[] propertiesForClass = findPropertiesForClass(propertyClass);
        if (propertiesForClass.length == 1) {// achou uma propriedade
            String alias = Util.strings.uncaptalize(this.beanClass.getSimpleName());
            String property = propertiesForClass[0];
            QueryBuilder qb = queryWithOrderBy();
            qb.where(alias + "." + property + " = ? ", o);
            updateFindByQuery(qb);
            if (forCombo) {
                if (extraFields != null && extraFields.length > 0) {
                    //verifcar se precisa fazer joins extras
                    int i = 0;
                    for (int j = 0; j < extraFields.length; j++) {
                        String extra = extraFields[j];
                        BeanDescriptor beanDescriptor = BeanDescriptorFactory.forClass(this.beanClass);
                        Type type = beanDescriptor.getPropertyDescriptor(extra).getType();
                        if (type instanceof Class) {
                            if (((Class) type).isAnnotationPresent(Entity.class)) {
                                extra += "." + BeanDescriptorFactory.forClass((Class) type)
                                        .getDescriptionPropertyName();
                            }
                        }
                        if (extra.contains(".")) {
                            int ultimoponto = extra.lastIndexOf(".");
                            String path = extra.substring(0, ultimoponto);
                            qb.join(alias + "." + path + " autojoin" + i);
                            extraFields[j] = "autojoin" + i + extra.substring(ultimoponto);
                        }
                        i++;
                    }
                    //se for com extraFields no pode usar o cache (no existe cache do select quando tem extra properties)                  
                    qb.select(getSelectClauseForIdAndDescription(extraFields));
                    //String hbquery = qb.getQuery();   
                    //queryString = hbquery;
                    return qb.list();
                } else {
                    qb.select(getSelectClauseForIdAndDescription());
                    String hbquery = qb.getQuery();
                    queryString = hbquery.replaceAll(":param0", "?");
                    mapaQueryFindByForCombo.put(propertyClass, queryString);
                }
            } else {
                String hbquery = qb.getQuery();
                queryString = hbquery.replaceAll(":param0", "?");
                ;
                mapaQueryFindByForCombo.put(propertyClass, queryString);
            }
        } else if (propertiesForClass.length > 1) {// mais de uma propriedade do mesmo tipo
            throw new RuntimeException(
                    "No foi possvel executar findBy(..). Existe mais de uma propriedade da classe "
                            + propertyClass.getName() + " na classe " + this.beanClass.getName() + "  "
                            + Arrays.deepToString(propertiesForClass));
        } else {//nenhuma propriedade do tipo fornecido
            throw new RuntimeException(
                    "No foi possvel executar findBy(..). No existe nenhuma propriedade da classe "
                            + propertyClass.getName() + " na classe " + this.beanClass.getName());
        }
    }

    List list = getHibernateTemplate().find(queryString, o);
    if (forCombo) {
        initQueryFindForCombo();
        list = translatorQueryFindForCombo.translate(list);
    }

    return list;
}