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:edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.por.PORFileReader.java

private void decodeSec2(BufferedReader reader) throws IOException {
    dbgLog.fine("decodeSec2(): start");
    if (reader == null) {
        throw new IllegalArgumentException("decodeSec2: stream == null!");
    }//from w  w  w .  j a va 2  s .  com

    // Because a 64-bit machine may not save the first 40
    // bytes of a POR file in a way as a 32-bit machine does,
    // the first 5 lines of a POR file is excluded from the read-back
    // file and the new 1st line contains the format mark "SPSSPORT"
    // somewhere in it.

    // mark the start position for the later rewind
    if (reader.markSupported()) {
        reader.mark(100000);
    }

    char[] sixthLineCharArray = new char[80];
    int nbytes_sixthLine = reader.read(sixthLineCharArray);

    String sixthLine = new String(sixthLineCharArray);
    dbgLog.fine("sixthLineCharArray=" + Arrays.deepToString(ArrayUtils.toObject(sixthLineCharArray)));
    int signatureLocation = sixthLine.indexOf(POR_MARK);

    if (signatureLocation >= 0) {
        dbgLog.fine("format signature was found at:" + signatureLocation);
    } else {
        dbgLog.severe("signature string was not found");
        throw new IOException("signature string was not found");
    }

    // rewind the position to the beginning
    reader.reset();

    // skip bytes up to the signature string
    long skippedBytes = reader.skip(signatureLocation);

    char[] sec2_leader = new char[POR_MARK.length()];
    int nbytes_sec2_leader = reader.read(sec2_leader);

    String leader_string = new String(sec2_leader);

    dbgLog.fine("format signature [SPSSPORT] detected=" + leader_string);

    if (leader_string.equals("SPSSPORT")) {
        dbgLog.fine("signature was correctly detected");

    } else {
        dbgLog.severe("the format signature is not found at the previously located column");
        throw new IOException("decodeSec2: failed to find the signature string");
    }

    int length_section_2 = LENGTH_SECTION_2;

    char[] Sec2_bytes = new char[length_section_2];

    int nbytes_sec2 = reader.read(Sec2_bytes);

    if (nbytes_sec2 == 0) {
        dbgLog.severe("decodeSec2: reading error");
        throw new IOException("decodeSec2: reading error");
    } else {
        dbgLog.fine("bytes read=" + nbytes_sec2);
    }

    String sec2 = new String(Sec2_bytes);
    dbgLog.fine("sec2[creation date/time]=" + sec2);

    // sec2
    //       0123456789012345678
    //       A8/YYYYMMDD6/HHMMSS
    // thus
    // section2 should has 3 elements

    String[] section2 = StringUtils.split(sec2, '/');

    dbgLog.fine("section2=" + StringUtils.join(section2, "|"));

    String fileCreationDate = null;
    String fileCreationTime = null;
    if ((section2.length == 3) && (section2[0].startsWith("A"))) {
        fileCreationDate = section2[1].substring(0, 7);
        fileCreationTime = section2[2];
    } else {
        dbgLog.severe("decodeSec2: file creation date/time were not correctly detected");
        throw new IOException("decodeSec2: file creation date/time were not correctly detected");
    }
    dbgLog.fine("fileCreationDate=" + fileCreationDate);
    dbgLog.fine("fileCreationTime=" + fileCreationTime);
    ///smd.getFileInformation().put("fileCreationDate", fileCreationDate);
    ///smd.getFileInformation().put("fileCreationTime", fileCreationTime);
    ///smd.getFileInformation().put("varFormat_schema", "SPSS");
    dbgLog.fine("decodeSec2(): end");
}

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

/**
 * Appends a value to the message.//www  .  j  a v a  2 s .  c  o  m
 * The type of the value is read from a D-Bus signature and used to marshall
 * the value.
 * 
 * @param sigb
 *            A buffer of the D-Bus signature.
 * @param sigofs
 *            The offset into the signature corresponding to this value.
 * @param data
 *            The value to marshall.
 * @return The offset into the signature of the end of this value's type.
 */
@SuppressWarnings("unchecked")
private int appendone(byte[] sigb, int sigofs, Object data) throws DBusException {
    try {
        int i = sigofs;
        if (log.isTraceEnabled()) {
            log.trace(this.bytecounter);
            log.trace("Appending type: " + ((char) sigb[i]) + " value: " + data);
        }

        // pad to the alignment of this type.
        pad(sigb[i]);
        switch (sigb[i]) {
        case ArgumentType.BYTE:
            appendByte(((Number) data).byteValue());
            break;
        case ArgumentType.BOOLEAN:
            appendint(((Boolean) data).booleanValue() ? 1 : 0, 4);
            break;
        case ArgumentType.DOUBLE:
            long l = Double.doubleToLongBits(((Number) data).doubleValue());
            appendint(l, 8);
            break;
        case ArgumentType.FLOAT:
            int rf = Float.floatToIntBits(((Number) data).floatValue());
            appendint(rf, 4);
            break;
        case ArgumentType.UINT32:
            appendint(((Number) data).longValue(), 4);
            break;
        case ArgumentType.INT64:
            appendint(((Number) data).longValue(), 8);
            break;
        case ArgumentType.UINT64:
            if (this.big) {
                appendint(((UInt64) data).top(), 4);
                appendint(((UInt64) data).bottom(), 4);
            } else {
                appendint(((UInt64) data).bottom(), 4);
                appendint(((UInt64) data).top(), 4);
            }
            break;
        case ArgumentType.INT32:
            appendint(((Number) data).intValue(), 4);
            break;
        case ArgumentType.UINT16:
            appendint(((Number) data).intValue(), 2);
            break;
        case ArgumentType.INT16:
            appendint(((Number) data).shortValue(), 2);
            break;
        case ArgumentType.STRING:
        case ArgumentType.OBJECT_PATH:
            // Strings are marshalled as a UInt32 with the length,
            // followed by the String, followed by a null byte.
            String payload = data.toString();
            byte[] payloadbytes = null;
            try {
                payloadbytes = payload.getBytes("UTF-8");
            } catch (UnsupportedEncodingException UEe) {
                throw new DBusException("System does not support UTF-8 encoding", UEe);
            }
            if (log.isTraceEnabled()) {
                log.trace("Appending String of length " + payloadbytes.length);
            }
            appendint(payloadbytes.length, 4);
            appendBytes(payloadbytes);
            appendBytes(padding[1]);
            // pad(ArgumentType.STRING);? do we need this?
            break;
        case ArgumentType.SIGNATURE:
            // Signatures are marshalled as a byte with the length,
            // followed by the String, followed by a null byte.
            // Signatures are generally short, so preallocate the array
            // for the string, length and null byte.
            if (data instanceof Type[])
                payload = Marshalling.getDBusType((Type[]) data);
            else
                payload = (String) data;
            byte[] pbytes = payload.getBytes();
            preallocate(2 + pbytes.length);
            appendByte((byte) pbytes.length);
            appendBytes(pbytes);
            appendByte((byte) 0);
            break;
        case ArgumentType.ARRAY:
            // Arrays are given as a UInt32 for the length in bytes,
            // padding to the element alignment, then elements in
            // order. The length is the length from the end of the
            // initial padding to the end of the last element.

            if (log.isTraceEnabled()) {
                if (data instanceof Object[])
                    log.trace("Appending array: " + Arrays.deepToString((Object[]) data));
            }

            byte[] alen = new byte[4];
            appendBytes(alen);
            pad(sigb[++i]);
            long c = this.bytecounter;

            // optimise primatives
            if (data.getClass().isArray() && data.getClass().getComponentType().isPrimitive()) {
                byte[] primbuf;
                int algn = getAlignment(sigb[i]);
                int len = Array.getLength(data);
                switch (sigb[i]) {
                case ArgumentType.BYTE:
                    primbuf = (byte[]) data;
                    break;
                case ArgumentType.INT16:
                case ArgumentType.INT32:
                case ArgumentType.INT64:
                    primbuf = new byte[len * algn];
                    for (int j = 0, k = 0; j < len; j++, k += algn)
                        marshallint(Array.getLong(data, j), primbuf, k, algn);
                    break;
                case ArgumentType.BOOLEAN:
                    primbuf = new byte[len * algn];
                    for (int j = 0, k = 0; j < len; j++, k += algn)
                        marshallint(Array.getBoolean(data, j) ? 1 : 0, primbuf, k, algn);
                    break;
                case ArgumentType.DOUBLE:
                    primbuf = new byte[len * algn];
                    if (data instanceof float[])
                        for (int j = 0, k = 0; j < len; j++, k += algn)
                            marshallint(Double.doubleToRawLongBits(((float[]) data)[j]), primbuf, k, algn);
                    else
                        for (int j = 0, k = 0; j < len; j++, k += algn)
                            marshallint(Double.doubleToRawLongBits(((double[]) data)[j]), primbuf, k, algn);
                    break;
                case ArgumentType.FLOAT:
                    primbuf = new byte[len * algn];
                    for (int j = 0, k = 0; j < len; j++, k += algn)
                        marshallint(Float.floatToRawIntBits(((float[]) data)[j]), primbuf, k, algn);
                    break;
                default:
                    throw new MarshallingException("Primative array being sent as non-primative array.");
                }
                appendBytes(primbuf);
            } else if (data instanceof List) {
                Object[] contents = ((List<Object>) data).toArray();
                int diff = i;
                ensureBuffers(contents.length * 4);
                for (Object o : contents)
                    diff = appendone(sigb, i, o);
                i = diff;
            } else if (data instanceof Map) {
                int diff = i;
                ensureBuffers(((Map<Object, Object>) data).size() * 6);
                for (Map.Entry<Object, Object> o : ((Map<Object, Object>) data).entrySet())
                    diff = appendone(sigb, i, o);
                if (i == diff) {
                    // advance the type parser even on 0-size arrays.
                    Vector<Type> temp = new Vector<>();
                    byte[] temp2 = new byte[sigb.length - diff];
                    System.arraycopy(sigb, diff, temp2, 0, temp2.length);
                    String temp3 = new String(temp2);
                    int temp4 = Marshalling.getJavaType(temp3, temp, 1);
                    diff += temp4;
                }
                i = diff;
            } else {
                Object[] contents = (Object[]) data;
                ensureBuffers(contents.length * 4);
                int diff = i;
                for (Object o : contents)
                    diff = appendone(sigb, i, o);
                i = diff;
            }
            if (log.isTraceEnabled()) {
                log.trace("start: " + c + " end: " + this.bytecounter + " length: " + (this.bytecounter - c));
            }
            marshallint(this.bytecounter - c, alen, 0, 4);
            break;
        case ArgumentType.STRUCT1:
            // Structs are aligned to 8 bytes
            // and simply contain each element marshalled in order
            Object[] contents;
            if (data instanceof Container)
                contents = ((Container) data).getParameters();
            else
                contents = (Object[]) data;
            ensureBuffers(contents.length * 4);
            int j = 0;
            for (i++; sigb[i] != ArgumentType.STRUCT2; i++)
                i = appendone(sigb, i, contents[j++]);
            break;
        case ArgumentType.DICT_ENTRY1:
            // Dict entries are the same as structs.
            if (data instanceof Map.Entry) {
                i++;
                i = appendone(sigb, i, ((Map.Entry<Object, Object>) data).getKey());
                i++;
                i = appendone(sigb, i, ((Map.Entry<Object, Object>) data).getValue());
                i++;
            } else {
                contents = (Object[]) data;
                j = 0;
                for (i++; sigb[i] != ArgumentType.DICT_ENTRY2; i++)
                    i = appendone(sigb, i, contents[j++]);
            }
            break;
        case ArgumentType.VARIANT:
            // Variants are marshalled as a signature
            // followed by the value.
            if (data instanceof Variant) {
                Variant<?> var = (Variant<?>) data;
                appendone(new byte[] { ArgumentType.SIGNATURE }, 0, var.getSig());
                appendone((var.getSig()).getBytes(), 0, var.getValue());
            } else if (data instanceof Object[]) {
                contents = (Object[]) data;
                appendone(new byte[] { ArgumentType.SIGNATURE }, 0, contents[0]);
                appendone(((String) contents[0]).getBytes(), 0, contents[1]);
            } else {
                String sig = Marshalling.getDBusType(data.getClass())[0];
                appendone(new byte[] { ArgumentType.SIGNATURE }, 0, sig);
                appendone((sig).getBytes(), 0, data);
            }
            break;
        }
        return i;
    } catch (ClassCastException CCe) {
        throw new MarshallingException(
                String.format("Trying to marshall to unconvertable type (from %s to %s).",
                        data.getClass().getName(), sigb[sigofs]),
                CCe);
    }
}

From source file:org.jahia.services.versioning.VersioningTest.java

private void displayVersions(JCRSessionWrapper editSession, JCRNodeWrapper subPageEditNode,
        JCRSessionWrapper liveSession) throws RepositoryException {
    // Display versions
    VersionManager versionManager;// ww  w .j  av  a 2s  .  co m
    VersionHistory versionHistory;
    versionManager = editSession.getWorkspace().getVersionManager();
    logger.info("Versions of " + subPageEditNode.getPath() + " in edit ws :");
    try {
        logger.info("Base version in edit ws is : "
                + versionManager.getBaseVersion(subPageEditNode.getPath()).getName());
        logger.info("Base version in live ws is : " + liveSession.getWorkspace().getVersionManager()
                .getBaseVersion(subPageEditNode.getPath()).getName());
    } catch (RepositoryException e) {
        logger.debug(e.getMessage(), e);
    }
    try {
        versionHistory = versionManager.getVersionHistory(subPageEditNode.getPath());
        VersionIterator allVersions = versionHistory.getAllVersions();
        while (allVersions.hasNext()) {
            Version version = allVersions.nextVersion();
            StringBuilder builder = new StringBuilder();

            builder.append(version.getName());
            String[] strings = versionHistory.getVersionLabels(version);
            if (strings != null && strings.length > 0) {
                builder.append(" ").append(Arrays.deepToString(strings));
            }
            Version[] versions = version.getPredecessors();
            for (Version version1 : versions) {
                builder.append(" <- ").append(version1.getName());
                strings = versionHistory.getVersionLabels(version1);
                if (strings != null && strings.length > 0) {
                    builder.append(" ").append(Arrays.deepToString(strings));
                }
            }
            logger.info(builder.toString());
        }
    } catch (RepositoryException e) {
        logger.debug(e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.siddhi.editor.core.internal.EditorMicroservice.java

@POST
@Produces("application/json")
@Path("/{siddhiAppName}/{streamId}/send")
public Response mock(String data, @PathParam("siddhiAppName") String siddhiAppName,
        @PathParam("streamId") String streamId) {
    Gson gson = new Gson();
    Object[] event = gson.fromJson(data, Object[].class);
    executorService.execute(() -> {//from   w w w.j a  va2  s. c  o  m
        try {
            EditorDataHolder.getDebugProcessorService().getSiddhiAppRuntimeHolder(siddhiAppName)
                    .getInputHandler(streamId).send(event);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
    });
    return Response.status(Response.Status.OK).entity(new GeneralResponse(Status.SUCCESS, "Event "
            + Arrays.deepToString(event) + " sent to stream " + streamId + " of runtime " + siddhiAppName))
            .build();
}

From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.dta.DTAFileReader.java

private void decodeDescriptorVarTypeList(BufferedInputStream stream, int nvar) throws IOException {
    byte[] typeList = new byte[nvar];

    // note: the offset param of read() is relative to
    // the current position, not absolute position
    int nbytes = stream.read(typeList, 0, nvar);
    //printHexDump(typeList, "variable type list");
    if (nbytes == 0) {
        throw new IOException("reading the descriptior: no byte was read");
    }//from   w  w w .  java2s  .c o m
    /*
    111 type
    Type:   b   i   l   f   d (byte, int, long, float, double)
    byte:  -5  -4  -3  -2  -1 (signed byte = java's byte type)
    byte: 251 252 253 254 255 (unsigned byte)
    HEX:  FB  FC  FD  FE  FF
            
    105 type(type chars correspond to their hex/decimal expressions
    Type:   b   i   l   f   d (byte, int, long, float, double)
    byte:  98 105 108 102 100 (signed byte = java's byte type)
    byte:  98 105 108 102 100 (unsigned byte)
    HEX:  62  69  6C  66  64
     */
    if (dbgLog.isLoggable(Level.FINE))
        dbgLog.fine("type_offset_table:\n" + typeOffsetTable);

    bytes_per_row = 0;
    for (int i = 0; i < typeList.length; i++) {
        if (dbgLog.isLoggable(Level.FINE))
            dbgLog.fine(i + "-th value=" + typeList[i]);

        if (byteLengthTable.containsKey(typeList[i])) {
            bytes_per_row += byteLengthTable.get(typeList[i]);
            variableTypelList[i] = variableTypeTable.get(typeList[i]);
        } else {
            // pre-111 string type
            if (releaseNumber < 111) {
                int stringType = 256 + typeList[i];
                if (stringType >= typeOffsetTable.get("STRING")) {
                    int string_var_length = stringType - typeOffsetTable.get("STRING");
                    if (dbgLog.isLoggable(Level.FINE))
                        dbgLog.fine("string_var_length=" + string_var_length);
                    bytes_per_row += string_var_length;

                    variableTypelList[i] = "String";
                    StringVariableTable.put(i, string_var_length);

                } else if ((256 + typeList[i]) < typeOffsetTable.get("STRING")) {
                    throw new IOException("unknown variable type was detected: reading errors?");
                }
            } else if (releaseNumber >= 111) {
                // post-111 string type
                if (dbgLog.isLoggable(Level.FINE))
                    dbgLog.fine("DTA reader: typeList[" + i + "]=" + typeList[i]);

                // if the size of strXXX type is less than 128,
                // the value of typeList[i] will be equal to that;
                // if however it is >= 128, typeList[i] = (size - 256)
                // i.e. it'll be a negative value:

                int stringType = ((typeList[i] > 0) && (typeList[i] <= 127)) ? typeList[i] : 256 + typeList[i];

                if (stringType >= typeOffsetTable.get("STRING")) {
                    int string_var_length = stringType - typeOffsetTable.get("STRING");
                    if (dbgLog.isLoggable(Level.FINE))
                        dbgLog.fine("DTA reader: string_var_length=" + string_var_length);
                    bytes_per_row += string_var_length;

                    variableTypelList[i] = "String";
                    StringVariableTable.put(i, string_var_length);

                } else if (stringType < typeOffsetTable.get("STRING")) {
                    throw new IOException("unknown variable type was detected: reading errors?");
                }
            } else {
                throw new IOException("uknown release number ");
            }

        }
        if (dbgLog.isLoggable(Level.FINE))
            dbgLog.fine(i + "=th\t sum=" + bytes_per_row);
    }
    if (dbgLog.isLoggable(Level.FINE)) {
        dbgLog.fine("bytes_per_row(final)=" + bytes_per_row);
        dbgLog.fine("variableTypelList:\n" + Arrays.deepToString(variableTypelList));
        dbgLog.fine("StringVariableTable=" + StringVariableTable);
    }
    variableTypelListFinal = new String[nvar];
    for (int i = 0; i < variableTypelList.length; i++) {
        variableTypelListFinal[i] = new String(variableTypelList[i]);
    }

}

From source file:edu.harvard.iq.dvn.ingest.dsb.AdvancedStatGUIdata.java

private String list2String(List lst) {
    String str;//  ww  w.  ja  v a2 s  .com
    if (lst.isEmpty()) {
        str = "";
    } else {
        Object[] obj = lst.toArray();
        str = Arrays.deepToString(obj);
    }
    return str;
}

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

/**
 * Append a series of values to the message.
 * /* ww  w.  j av  a 2s .  com*/
 * @param sig
 *            The signature(s) of the value(s).
 * @param data
 *            The value(s).
 */
public void append(String sig, Object... data) throws DBusException {
    if (log.isDebugEnabled()) {
        log.debug("Appending sig: " + sig + " data: " + Arrays.deepToString(data));
    }
    byte[] sigb = sig.getBytes();
    int j = 0;
    for (int i = 0; i < sigb.length; i++) {
        if (log.isTraceEnabled()) {
            log.trace("Appending item: " + i + " " + ((char) sigb[i]) + " " + j);
        }
        i = appendone(sigb, i, data[j++]);
    }
}

From source file:sim.module.broker.bo.BrokerAgent.java

/**
 * Forecast future deficit using linear regression forecast.
 * /*from  w w w. ja v a  2s.c o m*/
 * Forecast: Using the last 3 years data (36 months):
 *    1. Use linear regression to estimate linear trend line.
 *  2. Calculate seasonal index (monthly residual from trend line) 
 *  3. Use trend line to produce linear forecast
 *  4. Add seasonal (monthly) effects to forecast demand for each future month, t: forecast(t).
 *  
 * @param - recent historical demand over the last 36 months (inclusive of *this* month)
 * @return demand forecast list for the next [learning period = 36] months 
 */
public List<Double> getForecastDemandUsingLinearRegression(List<Double> historicDemand) {

    List<Double> forecastDemand = new ArrayList<Double>();
    List<Double> trendLine = new ArrayList<Double>();
    List<Double> residuals = new ArrayList<Double>();
    List<Double> monthlyResiduals = new ArrayList<Double>();

    if (historicDemand.size() != learningPeriod) {
        logger.warn("*** Historic data list is incorrect size. Returning zero forecast list. *** Size = "
                + historicDemand.size() + ", Size should be = " + learningPeriod + ", historicData: "
                + historicDemand);
        for (int i = 0; i < learningPeriod; i++) {
            forecastDemand.add(0.0);
        }
        return forecastDemand;
    } else {

        //convert List into 2d array
        double[][] historicDataArray = new double[historicDemand.size()][2];
        int index = 0;
        for (double h : historicDemand) {
            historicDataArray[index][0] = index;
            historicDataArray[index][1] = h;
            index++;
        }

        logger.debug("Historic array: " + Arrays.deepToString(historicDataArray));

        // now do the regression...
        SimpleRegression regression = new SimpleRegression();
        regression.addData(historicDataArray);
        logger.debug("Regression: m=" + regression.getSlope() + ", c=" + regression.getIntercept()
                + ", cStdErr=" + regression.getInterceptStdErr());

        // now get the trend line & residuals
        for (int i = 0; i < historicDemand.size(); i++) {
            trendLine.add((i * regression.getSlope()) + regression.getIntercept());
            residuals.add(historicDemand.get(i) - trendLine.get(i));
        }
        logger.debug("Trend line = " + trendLine);
        logger.debug("Residuals = " + residuals);

        // get mean residuals per month
        for (int i = 0; i < 12; i++) {
            logger.debug("We are assuming that learning period is 36 months. Make this generic code!!!");
            //TODO use %12 and iterate through to make this generic
            monthlyResiduals.add((residuals.get(i) + residuals.get(i + 12) + residuals.get(i + 24)) / 3);
        }

        logger.debug("mean monthly residuals: " + monthlyResiduals);

        // now forecast using monthly residuals and trend line
        // first set forecast using trendline
        for (double t : trendLine) {
            forecastDemand.add(t);
        }

        // forecast using trend line plus monthly adjustment
        for (int i = 0; i < 12; i++) {
            //TODO: Make this code generic not fixed to 36 months
            forecastDemand.set(i, trendLine.get(i) + monthlyResiduals.get(i));
            forecastDemand.set(i + 12, trendLine.get(i + 12) + monthlyResiduals.get(i));
            forecastDemand.set(i + 24, trendLine.get(i + 24) + monthlyResiduals.get(i));
        }

        // finally, multiply normalised demand by number of agents

        for (int i = 0; i < forecastDemand.size(); i++) {
            forecastDemand.set(i,
                    Math.floor(forecastDemand.get(i) * BrokerModuleRunner.getInstance().getNumEachAgent()));
        }

        logger.debug("final forecast with seasonal adjustment: " + forecastDemand);

        logger.debug("RForecastDemand: " + forecastDemand);
        logger.debug("Previous demand: " + historicDemand);

        return forecastDemand;
    }
}

From source file:org.ambraproject.annotation.service.AnnotationServiceTest.java

private void recursivelyCheckReplies(AnnotationView annotationView, Map<Long, List<Annotation>> fullReplyMap) {
    List<Annotation> expectedReplies = fullReplyMap.get(annotationView.getID());
    if (expectedReplies != null) {
        assertEquals(annotationView.getReplies().length, expectedReplies.size(),
                "Returned incorrect number of replies");
        for (AnnotationView actual : annotationView.getReplies()) {
            boolean foundMatch = false;

            for (Annotation expected : expectedReplies) {
                if (actual.getID().equals(expected.getID())) {
                    foundMatch = true;//from ww w.  jav a 2  s.c om
                    assertEquals(actual.getTitle(), expected.getTitle(), "Annotation view had incorrect title");
                    assertEquals(actual.getBody(), "<p>" + expected.getBody() + "</p>",
                            "Annotation view had incorrect body");
                    assertEquals(actual.getCompetingInterestStatement(),
                            expected.getCompetingInterestBody() == null ? ""
                                    : expected.getCompetingInterestBody(),
                            "Annotation view had incorrect ci statement");
                    assertEquals(actual.getAnnotationUri(), expected.getAnnotationUri(),
                            "Annotation view had incorrect annotation uri");
                }
            }
            assertTrue(foundMatch, "Returned unexpected reply: " + actual);
            //recursively check the replies
            recursivelyCheckReplies(actual, fullReplyMap);
        }
    } else {
        assertTrue(ArrayUtils.isEmpty(annotationView.getReplies()), "Returned replies when none were expected: "
                + Arrays.deepToString(annotationView.getReplies()));
    }
}

From source file:weave.servlets.GenericServlet.java

protected String methodToString(String name, Object[] params) {
    String str = name + Arrays.deepToString(params);
    int max = 1024;
    if (str.length() > max)
        str = str.substring(0, max) + "...";
    return str;/*from  w w w  .ja  v a2s.co m*/
}