Java Code Examples for java.util.Arrays#toString()

The following examples show how to use java.util.Arrays#toString() .
Example 1
Project: pinpoint   File: AutoBindingObjectFactory.java    License: Apache License 2.0 6 votes vote down vote up
private Object byConstructor(Class<?> type, ArgumentsResolver argumentsResolver) {
    final ConstructorResolver resolver = new ConstructorResolver(type, argumentsResolver);
    
    if (!resolver.resolve()) {
        throw new PinpointException("Cannot find suitable constructor for " + type.getName());
    }
    
    final Constructor<?> constructor = resolver.getResolvedConstructor();
    final Object[] resolvedArguments = resolver.getResolvedArguments();
    
    if (isDebug) {
        logger.debug("Create instance by constructor {}, with arguments {}", constructor, Arrays.toString(resolvedArguments));
    }
    
    try {
        return constructor.newInstance(resolvedArguments);
    } catch (Exception e) {
        throw new PinpointException("Fail to invoke constructor: " + constructor + ", arguments: " + Arrays.toString(resolvedArguments), e);
    }
}
 
Example 2
Project: phoebus   File: NumberScanSample.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String toString()
{
    if (size() == 1)
        return super.toString() + " " + values[0].toString();
    return super.toString() + " " + Arrays.toString(values);
}
 
Example 3
Project: ytk-learn   File: ApproximateQuantile.java    License: MIT License 5 votes vote down vote up
@Override
public String toString() {
    return "capacity:" + capacity + ", cursor:" + cursor + ", B:" + B + ", exact:" + exact + "\n" +
            ", value:" + Arrays.toString(value) + "\n" +
            ", rmin:" + Arrays.toString(rmin) + "\n" +
            ", rmax:" + Arrays.toString(rmax);
}
 
Example 4
Project: ClassAnalyzer   File: InnerClasses.java    License: MIT License 5 votes vote down vote up
@Override
public String toString() {
    return "InnerClasses{" +
            "attributeNameIndex=" + getAttributeNameIndex() +
            " [attribute name = " + ((ConstantUtf8Info) (constantPool.getCpInfo()[getAttributeNameIndex() - 1])).getValue() + "]" +
            ", attributeLength=" + getAttributeLength() +
            ", numberOfClasses=" + numberOfClasses +
            ", innerClasses=" + Arrays.toString(innerClasses) +
            '}';
}
 
Example 5
Project: spring-cloud-contract   File: StubRunnerProperties.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
	return "StubRunnerProperties{" + "minPort=" + this.minPort + ", maxPort="
			+ this.maxPort + ", repositoryRoot=" + this.repositoryRoot + ", ids="
			+ Arrays.toString(this.ids) + ", classifier='" + this.classifier + '\''
			+ ", setStubsPerConsumer='" + this.stubsPerConsumer + "', consumerName='"
			+ this.consumerName + '\'' + ", stubsMode='" + this.stubsMode + '\''
			+ ", size of properties=" + this.properties.size() + '}';
}
 
Example 6
Project: lucene-solr   File: Algorithm.java    License: Apache License 2.0 5 votes vote down vote up
private Class<?> taskClass(Config config, String taskName)
    throws ClassNotFoundException {
  for (String pkg : taskPackages) {
    try {
      return Class.forName(pkg+'.'+taskName+"Task");
    } catch (ClassNotFoundException e) {
      // failed in this package, might succeed in the next one... 
    }
  }
  // can only get here if failed to instantiate
  throw new ClassNotFoundException(taskName+" not found in packages "+Arrays.toString(taskPackages));
}
 
Example 7
Project: Trebuchet   File: PackageItemInfo.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public String toString() {
    return "PackageItemInfo(title=" + title + " id=" + this.id
            + " type=" + this.itemType + " container=" + this.container
            + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
            + " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos)
            + " user=" + user + ")";
}
 
Example 8
Project: openjdk-jdk8u-backup   File: VisibleMethods.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void verifyContains(List<String> methods, int matches,
        String... sigs) throws Exception {
    if (countMatches(methods, sigs) != matches) {
        throw new Exception("visibleMethods() should have contained "
                + matches + " entry/entries from " + Arrays.toString(sigs));
    }
}
 
Example 9
Project: hol-streams   File: TestUtil.java    License: Apache License 2.0 5 votes vote down vote up
static void printContent(Object actual) {
    final String s;
    if (actual.getClass().isArray()) {
        s = Arrays.toString((Object[]) actual);
    } else {
        s = actual.toString();
    }

    System.out.format("The content was %s%n", s);
}
 
Example 10
Project: openjdk-jdk8u   File: Path2DCopyConstructor.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void testEqual(Path2D pathA, Path2D pathB) {
    final PathIterator itA = pathA.getPathIterator(null);
    final PathIterator itB = pathB.getPathIterator(null);

    float[] coordsA = new float[6];
    float[] coordsB = new float[6];

    int n = 0;
    for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) {
        int typeA = itA.currentSegment(coordsA);
        int typeB = itB.currentSegment(coordsB);

        if (typeA != typeB) {
            throw new IllegalStateException("Path-segment[" + n + "] "
                + " type are not equals [" + typeA + "|" + typeB + "] !");
        }
        if (!equalsArray(coordsA, coordsB, getLength(typeA))) {
            throw new IllegalStateException("Path-segment[" + n + "] coords"
                + " are not equals [" + Arrays.toString(coordsA) + "|"
                + Arrays.toString(coordsB) + "] !");
        }
    }
    if (!itA.isDone() || !itB.isDone()) {
        throw new IllegalStateException("Paths do not have same lengths !");
    }
    log("testEqual: " + n + " segments.");
}
 
Example 11
Project: nopol   File: NopolContext.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
	return "Config{" +
			"synthesisDepth=" + synthesisDepth +
			", collectStaticMethods=" + collectStaticMethods +
			", collectStaticFields=" + collectStaticFields +
			", collectLiterals=" + collectLiterals +
			", onlyOneSynthesisResult=" + onlyOneSynthesisResult +
			", sortExpressions=" + sortExpressions +
			", maxLineInvocationPerTest=" + maxLineInvocationPerTest +
			", timeoutMethodInvocation=" + timeoutMethodInvocation +
			", dataCollectionTimeoutInSecondForSynthesis=" + dataCollectionTimeoutInSecondForSynthesis +
			", addWeight=" + addWeight +
			", subWeight=" + subWeight +
			", mulWeight=" + mulWeight +
			", divWeight=" + divWeight +
			", andWeight=" + andWeight +
			", orWeight=" + orWeight +
			", eqWeight=" + eqWeight +
			", nEqWeight=" + nEqWeight +
			", lessEqWeight=" + lessEqWeight +
			", lessWeight=" + lessWeight +
			", methodCallWeight=" + methodCallWeight +
			", fieldAccessWeight=" + fieldAccessWeight +
			", constantWeight=" + constantWeight +
			", variableWeight=" + variableWeight +
			", mode=" + mode +
			", type=" + type +
			", synthesis=" + synthesis +
			", oracle=" + oracle +
			", solver=" + solver +
			", solverPath='" + solverPath + '\'' +
			", projectSources=" + Arrays.toString(projectSources) +
			", projectClasspath='" + projectClasspath + '\'' +
			", projectTests=" + Arrays.toString(projectTests) +
			", complianceLevel=" + complianceLevel +
			", outputFolder=" + outputFolder +
			", json=" + json +
			'}';
}
 
Example 12
Project: ThinkJavaCode   File: Deck.java    License: MIT License 4 votes vote down vote up
/**
 * Returns a string representation of the deck.
 */
public String toString() {
    return Arrays.toString(this.cards);
}
 
Example 13
Project: TelePlus-Android   File: DataSpec.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public String toString() {
  return "DataSpec[" + uri + ", " + Arrays.toString(postBody) + ", " + absoluteStreamPosition
      + ", "  + position + ", " + length + ", " + key + ", " + flags + "]";
}
 
Example 14
Project: gsc-core   File: SlidingWindowCounter.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String toString() {
    return Arrays.toString(slotCounter);
}
 
Example 15
Project: jtransc   File: InetAddress.java    License: Apache License 2.0 4 votes vote down vote up
private static UnknownHostException badAddressLength(byte[] bytes) throws UnknownHostException {
	throw new UnknownHostException("Address is neither 4 or 16 bytes: " + Arrays.toString(bytes));
}
 
Example 16
Project: openjdk-8   File: MetaInf.java    License: GNU General Public License v2.0 4 votes vote down vote up
static void run(String ... args) {
    if (! new Main(System.out, System.err, "jar").run(args))
        throw new Error("jar failed: args=" + Arrays.toString(args));
}
 
Example 17
Project: edx-app-android   File: Tls12SocketFactory.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Enables TLS v1.2 protocol on Pre-Lollipop devices for server sockets.
 *
 * @param client The builder object of OkHttpClient.
 * @return Updated builder object of OkHttpClient with TLS v1.2 enabled on it.
 */
public static OkHttpClient.Builder enableTls12OnPreLollipop(OkHttpClient.Builder client) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
        try {
            /*
            OkHttpClient#sslSocketFactory(SSLSocketFactory) has been deprecated in favor of
            OkHttpClient#sslSocketFactory(SSLSocketFactory, X509TrustManager) which requires an
            X509TrustManager object.
            Ref: https://github.com/square/okhttp/issues/2372#issuecomment-277596841

            Inspiration for the fix and update to code:
            1 - https://github.com/square/okhttp/issues/2372#issuecomment-277677604
            2 - https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.Builder.html#sslSocketFactory-javax.net.ssl.SSLSocketFactory-javax.net.ssl.X509TrustManager-
             */
            final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
                    TrustManagerFactory.getDefaultAlgorithm());
            trustManagerFactory.init((KeyStore) null);
            final TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
            if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
                throw new IllegalStateException("Unexpected default trust managers:"
                        + Arrays.toString(trustManagers));
            }
            final X509TrustManager trustManager = (X509TrustManager) trustManagers[0];

            final SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(null, new TrustManager[]{trustManager}, null);
            client.sslSocketFactory(new Tls12SocketFactory(sslContext.getSocketFactory()), trustManager);

            final ConnectionSpec connectionSpec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
                    .tlsVersions(TlsVersion.TLS_1_2)
                    .build();

            final List<ConnectionSpec> specs = new ArrayList<>();
            specs.add(connectionSpec);
            specs.add(ConnectionSpec.COMPATIBLE_TLS);
            specs.add(ConnectionSpec.CLEARTEXT);

            client.connectionSpecs(specs);
        } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
            logger.error(e);
        }
    }

    return client;
}
 
Example 18
Project: Touchstone   File: PKJoin.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
	return "\n\tPKJoin [primakryKeys=" + Arrays.toString(primakryKeys) + ", canJoinNum=" + Arrays.toString(canJoinNum)
			+ ", cantJoinNum=" + Arrays.toString(cantJoinNum) + ", pkStr=" + pkStr + "]";
}
 
Example 19
Project: nd4j   File: GradCheckReductions.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testReduce3() {

    Nd4j.getRandom().setSeed(12345);

    int d0 = 3;
    int d1 = 4;
    int d2 = 5;

    List<String> allFailed = new ArrayList<>();
    for (int[] reduceDims : new int[][]{{Integer.MAX_VALUE}, {0, 1, 2}, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}}) {
        for (int i = 0; i < 6; i++) {

            SameDiff sd = SameDiff.create();
            sd.setLogExecution(false);


            SDVariable in = sd.var("in", new int[]{-1, d1, d2});
            SDVariable in2 = sd.var("in2", new int[]{-1, d1, d2});

            INDArray inArr = Nd4j.randn(new int[]{d0, d1, d2}).muli(100);
            INDArray in2Arr = Nd4j.randn(inArr.shape()).muli(100);

            SDVariable reduced;
            String name;
            switch (i) {
                case 0:
                    reduced = sd.manhattanDistance(in, in2, reduceDims);
                    name = "manhattan";
                    break;
                case 1:
                    reduced = sd.euclideanDistance(in, in2, reduceDims);
                    name = "euclidean";
                    break;
                case 2:
                    reduced = sd.cosineSimilarity(in, in2, reduceDims);
                    name = "cosine";
                    break;
                case 3:
                    reduced = sd.cosineDistance(in, in2, reduceDims);
                    name = "cosinedistance";
                    break;
                case 4:
                    reduced = sd.hammingDistance(in, in2, reduceDims);
                    name = "hamming";
                    break;
                case 5:
                    name = "jaccard";
                    reduced = sd.jaccardDistance(name, in, in2, reduceDims);
                    inArr.divi(100).addi(0.1);
                    in2Arr.divi(100).addi(0.1);
                    break;
                default:
                    throw new RuntimeException();
            }

            //Sum: note that this should be a no-op for the full array cases
            SDVariable sum = sd.sum(reduced, Integer.MAX_VALUE);


            String msg = "(test " + i + " - " + name + ", dimensions=" + Arrays.toString(reduceDims) + ")";
            log.info("*** Starting test: " + msg);

            sd.associateArrayWithVariable(inArr, in);
            sd.associateArrayWithVariable(in2Arr, in2);

            sd.execAndEndResult();

            // FIXME: we can't swallow exceptions here now, but once release out and stuff stabilized - we can
            //try {
                boolean ok = GradCheckUtil.checkGradients(sd, 1e-5, 1e-5, 1e-4, true, false);
                if (!ok) {
                    allFailed.add(msg);
                }
            /*
            } catch (Exception e) {
                e.printStackTrace();
                allFailed.add(msg + " - EXCEPTION");
            }
            */
        }
    }

    assertEquals("Failed: " + allFailed, 0, allFailed.size());
}
 
Example 20
Project: deeplearning4j   File: SDVariable.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return "SDVariable(name=\"" + varName + "\",variableType=" + variableType + ",dtype=" + dataType +
            (variableType == VariableType.PLACEHOLDER && shape != null ? ",shape=" + Arrays.toString(shape): "") + ")";
}