/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof RegexStringComparator)) return false; RegexStringComparator comparator = (RegexStringComparator)other; return super.areSerializedFieldsEqual(comparator) && engine.getClass().isInstance(comparator.getEngine()) && engine.getPattern().equals(comparator.getEngine().getPattern()) && engine.getFlags() == comparator.getEngine().getFlags() && engine.getCharset().equals(comparator.getEngine().getCharset()); }
if (charset.length() > 0) { try { comparator.getEngine().setCharset(charset); } catch (IllegalCharsetNameException e) { LOG.error("invalid charset", e);
@Test public void testSerialization() throws Exception { // Default engine is the Java engine RegexStringComparator a = new RegexStringComparator("a|b"); RegexStringComparator b = RegexStringComparator.parseFrom(a.toByteArray()); assertTrue(a.areSerializedFieldsEqual(b)); assertTrue(b.getEngine() instanceof RegexStringComparator.JavaRegexEngine); // joni engine a = new RegexStringComparator("a|b", EngineType.JONI); b = RegexStringComparator.parseFrom(a.toByteArray()); assertTrue(a.areSerializedFieldsEqual(b)); assertTrue(b.getEngine() instanceof RegexStringComparator.JoniRegexEngine); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof RegexStringComparator)) return false; RegexStringComparator comparator = (RegexStringComparator)other; return super.areSerializedFieldsEqual(comparator) && engine.getClass().isInstance(comparator.getEngine()) && engine.getPattern().equals(comparator.getEngine().getPattern()) && engine.getFlags() == comparator.getEngine().getFlags() && engine.getCharset().equals(comparator.getEngine().getCharset()); }
if (charset.length() > 0) { try { comparator.getEngine().setCharset(charset); } catch (IllegalCharsetNameException e) { LOG.error("invalid charset", e);
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof RegexStringComparator)) return false; RegexStringComparator comparator = (RegexStringComparator)other; return super.areSerializedFieldsEqual(comparator) && engine.getClass().isInstance(comparator.getEngine()) && engine.getPattern().equals(comparator.getEngine().getPattern()) && engine.getFlags() == comparator.getEngine().getFlags() && engine.getCharset().equals(comparator.getEngine().getCharset()); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof RegexStringComparator)) return false; RegexStringComparator comparator = (RegexStringComparator)other; return super.areSerializedFieldsEqual(comparator) && engine.getClass().isInstance(comparator.getEngine()) && engine.getPattern().equals(comparator.getEngine().getPattern()) && engine.getFlags() == comparator.getEngine().getFlags() && engine.getCharset().equals(comparator.getEngine().getCharset()); }
if (charset.length() > 0) { try { comparator.getEngine().setCharset(charset); } catch (IllegalCharsetNameException e) { LOG.error("invalid charset", e);
if (charset.length() > 0) { try { comparator.getEngine().setCharset(charset); } catch (IllegalCharsetNameException e) { LOG.error("invalid charset", e);
@Test public void testSerialization() throws Exception { // Default engine is the Java engine RegexStringComparator a = new RegexStringComparator("a|b"); RegexStringComparator b = RegexStringComparator.parseFrom(a.toByteArray()); assertTrue(a.areSerializedFieldsEqual(b)); assertTrue(b.getEngine() instanceof RegexStringComparator.JavaRegexEngine); // joni engine a = new RegexStringComparator("a|b", EngineType.JONI); b = RegexStringComparator.parseFrom(a.toByteArray()); assertTrue(a.areSerializedFieldsEqual(b)); assertTrue(b.getEngine() instanceof RegexStringComparator.JoniRegexEngine); }