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

The following examples show how to use java.util.Arrays#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoBindingObjectFactory.java    From pinpoint with 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
Source File: NumberScanSample.java    From phoebus with 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
Source File: NopolContext.java    From nopol with 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 4
Source File: Path2DCopyConstructor.java    From openjdk-jdk8u with 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 5
Source File: TestUtil.java    From hol-streams with 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 6
Source File: VisibleMethods.java    From openjdk-jdk8u-backup with 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 7
Source File: PackageItemInfo.java    From Trebuchet with 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
Source File: Algorithm.java    From lucene-solr with 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 9
Source File: StubRunnerProperties.java    From spring-cloud-contract with 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 10
Source File: InnerClasses.java    From ClassAnalyzer with 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 11
Source File: ApproximateQuantile.java    From ytk-learn with 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 12
Source File: SlidingWindowCounter.java    From gsc-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String toString() {
    return Arrays.toString(slotCounter);
}
 
Example 13
Source File: InetAddress.java    From jtransc with 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 14
Source File: DataSpec.java    From TelePlus-Android with 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 15
Source File: MetaInf.java    From openjdk-8 with 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 16
Source File: Tls12SocketFactory.java    From edx-app-android with 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 17
Source File: PKJoin.java    From Touchstone with 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 18
Source File: GradCheckReductions.java    From nd4j with 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 19
Source File: SDVariable.java    From deeplearning4j with 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): "") + ")";
}
 
Example 20
Source File: Deck.java    From ThinkJavaCode with MIT License 4 votes vote down vote up
/**
 * Returns a string representation of the deck.
 */
public String toString() {
    return Arrays.toString(this.cards);
}