Example usage for org.apache.commons.lang ArrayUtils toString

List of usage examples for org.apache.commons.lang ArrayUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toString.

Prototype

public static String toString(Object array) 

Source Link

Document

Outputs an array as a String, treating null as an empty array.

Usage

From source file:nl.intercommit.weaves.components.EnhancedSelect.java

@SuppressWarnings({ "unchecked" })
@Override//from ww w . j ava 2 s  .  c om
protected void processSubmission(String controlName) {
    String submittedValue = null;
    // my multivalue hack
    if (multiple) {
        submittedValue = ArrayUtils.toString(request.getParameters(controlName));

        System.err.println("submittewd:" + submittedValue);

        System.err.println("SEPARATER: '" + multiSeparator + "'");

        submittedValue = submittedValue.replace(",", multiSeparator);
        submittedValue = submittedValue.substring(1, submittedValue.length() - 1);
    } else {
        submittedValue = request.getParameter(controlName);
    }

    tracker.recordInput(this, submittedValue);

    Object selectedValue = toValue(submittedValue);

    putPropertyNameIntoBeanValidationContext("value");

    try {
        fieldValidationSupport.validate(selectedValue, resources, validate);

        value = selectedValue;
    } catch (ValidationException ex) {
        tracker.recordError(this, ex.getMessage());
    }

    removePropertyNameFromBeanValidationContext();
}

From source file:nl.strohalm.cyclos.webservices.payments.PaymentParameters.java

@Override
public String toString() {
    return "PaymentParameters [credentials=****" + ", customValues=" + customValues + ", fromMemberFields= "
            + ArrayUtils.toString(fromMemberFieldsToReturn) + ", toMemberFields= "
            + ArrayUtils.toString(toMemberFieldsToReturn) + ", fromSystem=" + fromSystem + ", returnStatus="
            + returnStatus + ", toSystem=" + toSystem + ", transferTypeId=" + transferTypeId + ", "
            + super.toString() + "]";
}

From source file:nl.strohalm.cyclos.webservices.sms.SendSmsParameters.java

@Override
public String toString() {
    return "SendSmsParameters [traceData=" + traceData + ", smsTypeCode=" + smsTypeCode + ", smsTypeArgs="
            + ArrayUtils.toString(smsTypeArgs) + ", targetPrincipal=" + targetPrincipal
            + ", targetPrincipalType=" + targetPrincipalType + ", text=" + text + ", toChargePrincipal="
            + toChargePrincipal + ", toChargePrincipalType=" + toChargePrincipalType + "]";
}

From source file:ocr.sapphire.image.EdgeBasedImagePreprocessor.java

public static void main(String[] args) throws IOException {
    BufferedImage image = ImageIO.read(new File("a.png"));
    EdgeBasedImagePreprocessor preprocessor = new EdgeBasedImagePreprocessor();
    double[][][] coefficients = preprocessor.process(image);
    BufferedImage[] reversedImages = preprocessor.reverse();
    for (int c = 0; c < preprocessor.getComponentCount(); c++) {
        System.out.println("component " + (c + 1));
        System.out.println("\treal(a): " + ArrayUtils.toString(coefficients[c][0]));
        System.out.println("\timagine(a): " + ArrayUtils.toString(coefficients[c][1]));
        System.out.println("\treal(b): " + ArrayUtils.toString(coefficients[c][2]));
        System.out.println("\timagine(b): " + ArrayUtils.toString(coefficients[c][3]));
        ImageIO.write(reversedImages[c], "PNG", new File("reverse" + c + ".png"));
    }//  w w w .j av a 2  s.c om
    ImageIO.write(preprocessor.getContourImage(), "PNG", new File("edge.png"));
}

From source file:ocr.sapphire.test.NetworkTest.java

@Test
public void identityFunction() {
    Network network = new Network(3, 3, 3);
    double[][] data = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 },
            { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 1.0 }, { 1.0, 0.0, 1.0 }, { 1.0, 1.0, 1.0 }, };
    for (int k = 0; k < 5000; k++) {
        for (int i = 0; i < data.length; i++) {
            network.train(data[i], data[i]);
        }//from w  w  w  .j a  va2  s  .  c  o  m
    }
    for (int i = 0; i < data.length; i++) {
        double[] output = network.recognize(data[i]);
        System.out.println(ArrayUtils.toString(output));
        Assert.assertArrayEquals(data[i], output, 0.5);
    }
}

From source file:ocr.sapphire.test.NetworkTest.java

@Test
public void identityFunction2() {
    // This is the test in the book.
    Network network = new Network(8, 3, 8);
    network.setRate(0.3);//from   w  ww .  j  a va  2s  .co m

    double[][] data = { { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
            { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 },
            { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 },
            { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 } };

    for (int k = 0; k < 5000; k++) {
        for (int i = 0; i < data.length; i++) {
            network.train(data[i], data[i]);
        }
    }

    for (int i = 0; i < data.length; i++) {
        double[] output = network.recognize(data[i]);
        System.out.println(ArrayUtils.toString(output));
        Assert.assertArrayEquals(data[i], output, 0.5);
    }
}

From source file:ocr.sapphire.test.NetworkTest.java

@Test
public void simplestNetwork() throws YamlException {
    Network network = new Network(1, 1, 1);
    double[][] data = { { 1.0 } };
    for (int k = 0; k < 20; k++) {
        for (int i = 0; i < data.length; i++) {
            System.out.println("************* (" + k + ", " + i + ") ***********");
            System.out.println(Utils.toYaml(network));
            network.train(data[i], data[i]);
            System.out.println("output: " + Arrays.toString(network.getOutput()));
        }//from www .  j av  a2 s. c  o m
    }

    System.out.println(Utils.toYaml(network));
    for (int i = 0; i < data.length; i++) {
        double[] output = network.recognize(data[i]);
        System.out.println(ArrayUtils.toString(output));
        Assert.assertArrayEquals(data[i], output, 0.5);
    }
}

From source file:org.acoustid.FingerprintTest.java

@Test
public void testDecodeFingerprint() throws IOException, IncompatibleFingerprintVersion {
    int[] decodedFp = FingerprintUtils.decodeFingerprint(ENCODED_FINGERPRINT, 0);
    assertEquals(ArrayUtils.toString(FINGERPRINT), ArrayUtils.toString(decodedFp));
}

From source file:org.acoustid.util.BitStreamWriterTest.java

public void testOneByte() throws IOException {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    DataOutputStream dataOutput = new DataOutputStream(output);

    BitStreamWriter writer = new BitStreamWriter(dataOutput);
    writer.write(0, 2);/* w  w w.  j a  va2 s.  c  o  m*/
    writer.write(1, 2);
    writer.write(2, 2);
    writer.write(3, 2);
    writer.flush();

    byte[] expected = { -28 };
    assertEquals(ArrayUtils.toString(expected), ArrayUtils.toString(output.toByteArray()));
}

From source file:org.acoustid.util.BitStreamWriterTest.java

public void testTwoBytesIncomplete() throws IOException {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    DataOutputStream dataOutput = new DataOutputStream(output);

    BitStreamWriter writer = new BitStreamWriter(dataOutput);
    writer.write(0, 2);//from www. j a v  a  2 s.c  o m
    writer.write(1, 2);
    writer.write(2, 2);
    writer.write(3, 2);
    writer.write(1, 2);
    writer.flush();

    byte[] expected = { -28, 1 };
    assertEquals(ArrayUtils.toString(expected), ArrayUtils.toString(output.toByteArray()));
}