Java Arrays.toString Examples

Java Arrays.toString - 30 examples found. These are the top rated real world Java examples of java.util.Arrays.toString extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /** @tests java.util.Arrays#toString(short[]) */
 public void test_toString$S() {
   assertEquals("null", Arrays.toString((short[]) null));
   assertEquals("[]", Arrays.toString(new short[] {}));
   assertEquals("[0]", Arrays.toString(new short[] {0}));
   assertEquals("[-1, 0]", Arrays.toString(new short[] {-1, 0}));
   assertEquals("[-1, 0, 1]", Arrays.toString(new short[] {-1, 0, 1}));
 }
Example #2
0
 public void assertAll(Iterable<Diagnostic> asserted, DiagnosticPredicate predicates[]) {
   HashMap<DiagnosticPredicate, Boolean> consumed = new HashMap<DiagnosticPredicate, Boolean>();
   for (DiagnosticPredicate p : predicates) consumed.put(p, Boolean.FALSE);
   for (Diagnostic d : asserted) {
     boolean found = false;
     for (Entry<DiagnosticPredicate, Boolean> e : consumed.entrySet())
       if ((!e.getValue() || e.getKey().isGreedy()) && e.getKey().apply(d)) {
         consumed.put(e.getKey(), Boolean.TRUE);
         found = true;
         break;
       }
     if (!found) {
       if (predicates.length == 1)
         throw new ComparisonFailure(
             "Predicate does not match", predicates[0].toString(), diagnosticsToString(d));
       throw new ComparisonFailure(
           "No predicate in expected matches",
           Arrays.toString(predicates),
           diagnosticsToString(d));
     }
   }
   ArrayList<DiagnosticPredicate> unconsumed = new ArrayList<DiagnosticPredicate>();
   for (Entry<DiagnosticPredicate, Boolean> e : consumed.entrySet())
     if (!e.getValue() && e.getKey().isRequired()) unconsumed.add(e.getKey());
   if (unconsumed.size() != 0)
     throw new ComparisonFailure(
         "Missing diagnostics for required predicates",
         Arrays.toString(unconsumed.toArray()),
         diagnosticsToString(asserted));
 }
 public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) {
   List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
   Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
   if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
     int[] suitableFPSRange = null;
     for (int[] fpsRange : supportedPreviewFpsRanges) {
       int thisMin = fpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
       int thisMax = fpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
       if (thisMin >= minFPS * 1000 && thisMax <= maxFPS * 1000) {
         suitableFPSRange = fpsRange;
         break;
       }
     }
     if (suitableFPSRange == null) {
       Log.i(TAG, "No suitable FPS range?");
     } else {
       int[] currentFpsRange = new int[2];
       parameters.getPreviewFpsRange(currentFpsRange);
       if (Arrays.equals(currentFpsRange, suitableFPSRange)) {
         Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange));
       } else {
         Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange));
         parameters.setPreviewFpsRange(
             suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
             suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
       }
     }
   }
 }
  private void assertProposedMethods(
      String finderName,
      String[] properties,
      String[] superProperties,
      String[] expectedMethodProposalNames)
      throws JavaModelException {
    String superName = null;
    if (superProperties != null) {
      superName = "SearchSuper";
      createDomainClass(
          "SearchSuper", createDomainTextWithSuper(null, null, true, superProperties));
    }
    String contents = createDomainTextWithSuper(finderName, superName, false, properties);
    // ensure this is executed in a static context
    GroovyCompilationUnit unit = createDomainClass("Search", contents);
    DynamicFinderValidator validator =
        new FinderValidatorFactory()
            .createValidator(GrailsWorkspaceCore.get().create(project).getDomainClass(unit));
    List<AnnotatedNode> proposed = validator.findProposals(finderName);
    String[] actualMethodProposalNames = getProposalNames(proposed);
    Arrays.sort(expectedMethodProposalNames);
    Arrays.sort(actualMethodProposalNames);

    assertTrue(
        "Actual and expected proposals not the same.\nExpected: "
            + Arrays.toString(expectedMethodProposalNames)
            + "\nActual: "
            + Arrays.toString(actualMethodProposalNames),
        testSameElements(expectedMethodProposalNames, actualMethodProposalNames));
  }
Example #5
0
 @Override
 public String toString() {
   return "foodArea="
       + foodArea
       + "\n"
       + "woodArea="
       + woodArea
       + "\n"
       + "copperArea="
       + copperArea
       + "\n"
       + "stoneArea="
       + stoneArea
       + "\n"
       + "goldArea="
       + goldArea
       + "\n"
       + "hutArea="
       + hutArea
       + "\n"
       + "farmArea="
       + farmArea
       + "\n"
       + "factoryArea="
       + factoryArea
       + "\n"
       + "buildingAreas="
       + Arrays.toString(buildingAreas)
       + "\n"
       + "civilisationAreas="
       + Arrays.toString(civilisationAreas);
 }
  @Override
  public String toString() {
    final StringBuilder builder = new StringBuilder();

    builder.append(getClass().getSimpleName());
    builder.append('[');
    builder.append(standard);
    builder.append(',');
    if (hasPayee()) {
      builder.append(payeeName);
      if (payeeVerifiedBy != null) builder.append("/").append(payeeVerifiedBy);
      builder.append(',');
    }
    builder.append(hasOutputs() ? Arrays.toString(outputs) : "null");
    builder.append(',');
    builder.append(paymentUrl);
    if (payeeData != null) {
      builder.append(',');
      builder.append(Arrays.toString(payeeData));
    }
    if (paymentRequestUrl != null) {
      builder.append(",paymentRequestUrl=");
      builder.append(paymentRequestUrl);
    }
    builder.append(']');

    return builder.toString();
  }