/** * Returns <code>true</code> if and only if the given Object is a <code>BOM</code> instance with the same * signature as this instance. * * * @param o the Object to test for equality * @return true if the specified Object is a BOM instance with the same signature as this instance */ public boolean equals(Object o) { return (o instanceof BOM) && ((BOM)o).sigEquals(sig); }
/** * Tests {@link BOM} comparison methods. */ @Test public void testBOMComparisons() { // Tests BOM#sigStartsWith method assert UTF8_BOM.sigStartsWith(new byte[]{(byte)0xEF, (byte)0xBB}); assert UTF8_BOM.sigStartsWith(new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF}); assert !UTF8_BOM.sigStartsWith(new byte[]{(byte)0xAA}); assert !UTF8_BOM.sigStartsWith(new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF, (byte)0xAA}); // Tests BOM#sigEquals method assert UTF8_BOM.sigEquals(UTF8_BOM.getSignature()); assert !UTF8_BOM.sigEquals(UTF16_LE_BOM.getSignature()); // Tests BOM#equals method assert UTF8_BOM.equals(UTF8_BOM); assert !UTF8_BOM.equals(UTF16_LE_BOM); assert !UTF8_BOM.equals(new Object()); }