Example usage for java.util Arrays equals

List of usage examples for java.util Arrays equals

Introduction

In this page you can find the example usage for java.util Arrays equals.

Prototype

public static boolean equals(Object[] a, Object[] a2) 

Source Link

Document

Returns true if the two specified arrays of Objects are equal to one another.

Usage

From source file:com.moz.fiji.schema.filter.OperatorColumnFilter.java

/** {@inheritDoc} */
@Override//from w w w  . j  av a 2s.com
public boolean equals(Object other) {
    if ((null == other) || (other.getClass() != getClass())) {
        return false;
    }
    final OperatorColumnFilter that = (OperatorColumnFilter) other;
    return Objects.equal(this.mOperator, that.mOperator) && Arrays.equals(this.mFilters, that.mFilters);
}

From source file:com.opengamma.analytics.financial.model.volatility.smile.function.HestonModelData.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*from   www  . ja v  a 2s .  com*/
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final HestonModelData other = (HestonModelData) obj;
    if (!Arrays.equals(_parameters, other._parameters)) {
        return false;
    }
    return true;
}

From source file:com.norconex.importer.parser.impl.xfdl.XFDLParser.java

private void parse(BufferedReader reader, Writer out, ImporterMetadata metadata)
        throws IOException, ParserConfigurationException, SAXException {
    reader.mark(MAGIC_BASE64.length);//from  w  ww .j av  a  2s .co m
    char[] signature = new char[MAGIC_BASE64.length];
    int num = reader.read(signature);
    reader.reset();
    if (num == -1) {
        return;
    }

    //--- Create XML DOM ---
    DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document dom = null;
    if (Arrays.equals(signature, MAGIC_BASE64)) {
        // skip first line
        reader.readLine();

        // un-encode first
        byte[] compressedContent = Base64.decodeBase64(IOUtils.toString(reader));
        // deal with compression
        InputStream is = new GZIPInputStream(new ByteArrayInputStream(compressedContent));

        dom = docBuilder.parse(is);
        IOUtils.closeQuietly(is);
    } else {
        dom = docBuilder.parse(new InputSource(reader));
    }
    parseXML(dom, out, metadata);
}

From source file:eionet.meta.service.CSVVocabularyImportServiceTest.java

/**
 * {@inheritDoc} This method skips BOM character
 *///from   w w  w  . j a  v a 2 s. c  om
protected Reader getReaderFromResource(String resourceLoc) throws Exception {

    InputStream is = getClass().getClassLoader().getResourceAsStream(resourceLoc);
    byte[] firstThreeBytes = new byte[3];
    is.read(firstThreeBytes);

    if (!Arrays.equals(firstThreeBytes, VocabularyOutputHelper.getBomByteArray())) {
        is.close();
        is = getClass().getClassLoader().getResourceAsStream(resourceLoc);
    }
    InputStreamReader reader = new InputStreamReader(is);

    return reader;
}

From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.PackedMatrixTest.java

@Test
public void testBandedWithZeroRowNOZerosAllowedConstructor() {
    double[] expectedData = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    PackedMatrix M = new PackedMatrix(_bandedwithzerorow, allowZerosOn.none, 5, 5);
    assertTrue(Arrays.equals(M.getData(), expectedData));
}

From source file:com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountAddZeroSpreadCurve.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*w w w.j  a v a  2  s  .  c  o  m*/
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    YieldAndDiscountAddZeroSpreadCurve other = (YieldAndDiscountAddZeroSpreadCurve) obj;
    if (!Arrays.equals(_curves, other._curves)) {
        return false;
    }
    if (Double.doubleToLongBits(_sign) != Double.doubleToLongBits(other._sign)) {
        return false;
    }
    return true;
}

From source file:cc.arduino.plugins.wifi101.flashers.java.WINCFlasher.java

@Override
public void updateFirmware(String port) throws Exception {
    FlasherSerialClient client = null;/*from   w w  w  . java 2  s .  c  o m*/
    try {
        file = openFirmwareFile();
        progress(10, "Connecting to programmer...");
        client = new FlasherSerialClient();
        client.open(port, this.baudrate);
        client.hello();
        int maxPayload = client.getMaximumPayload();

        byte[] fwData = this.getData();
        int size = fwData.length;
        int address = 0x00000000;
        int written = 0;

        progress(20, "Erasing target...");
        client.eraseFlash(address, size);

        while (written < size) {
            progress(20 + written * 40 / size, "Programming " + size + " bytes ...");
            int len = maxPayload;
            if (written + len > size) {
                len = size - written;
            }
            client.writeFlash(address, Arrays.copyOfRange(fwData, written, written + len));
            written += len;
            address += len;
        }
        int readed = 0;
        address = 0x00000000;
        while (readed < size) {
            progress(60 + readed * 40 / size, "Verifying...");
            int len = maxPayload;
            if (readed + len > size) {
                len = size - readed;
            }
            byte[] data = client.readFlash(address, len);
            if (!Arrays.equals(data, Arrays.copyOfRange(fwData, readed, readed + len))) {
                throw new Exception("Error during verify at address " + address);
            }
            readed += len;
            address += len;
        }
        progress(100, "Done!");
    } finally {
        if (client != null) {
            client.close();
        }
    }
}

From source file:mitm.test.TestUtils.java

public static boolean isEqual(MimeMessage message1, MimeMessage message2)
        throws IOException, MessagingException {
    ByteArrayOutputStream bos1 = new ByteArrayOutputStream();

    MailUtils.writeMessage(message1, bos1);

    ByteArrayOutputStream bos2 = new ByteArrayOutputStream();

    MailUtils.writeMessage(message2, bos2);

    return Arrays.equals(bos2.toByteArray(), bos1.toByteArray());
}

From source file:com.tresys.jalop.utils.jnltest.Config.ConfigTest.java

@Test
public void createFromJsonReturnsValidConfigForListener() throws Exception {
    jsonCfg.put("listener", listener);
    Config cfg = Config.createFromJson("path/to/nothing", jsonCfg);
    assertNotNull(cfg);//from   ww w. j  av  a 2  s.co  m
    assertEquals("path/to/nothing", cfg.getSource());
    assertTrue(Arrays.equals(new byte[] { 127, 0, 0, 1 }, cfg.getAddress().getAddress()));
    assertEquals(128, cfg.getPendingDigestMax());
    assertEquals(120, cfg.getPendingDigestTimeout());
    assertEquals(1234, cfg.getPort());
    assertNotNull(cfg.getPeerConfigs());
}

From source file:com.phoenixst.collections.AnyPredicate.java

public boolean equals(Object object) {
    if (object == this) {
        return true;
    }// w  w w . j  a  v  a  2  s.  c om
    if (!(object instanceof AnyPredicate)) {
        return false;
    }
    AnyPredicate pred = (AnyPredicate) object;
    return Arrays.equals(predicateArray, pred.predicateArray);
}