DataExpressionSource extends Source { @Override protected boolean isAvailable(final BigInteger offset, final BigInteger length) { return checkNotNegative(offset, "offset").add(checkNotNegative(length, "length")).compareTo(BigInteger.valueOf(getValue().length)) <= 0; } DataExpressionSource(final ValueExpression dataExpression, final int index, final ParseState parseState, final Encoding encoding); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); final ValueExpression dataExpression; final int index; final ParseState parseState; final Encoding encoding; }
@Test public void createSliceFromParseValue() { final ParseValue value = setupValue(); assertTrue(value.slice().source.isAvailable(ZERO, BigInteger.valueOf(4))); assertFalse(value.slice().source.isAvailable(ZERO, BigInteger.valueOf(5))); }
@Test public void notAValue() { thrown.expect(IllegalStateException.class); thrown.expectMessage("ValueExpression dataExpression yields NOT_A_VALUE at index 0."); new DataExpressionSource(div(con(1), con(0)), 0, EMPTY_PARSE_STATE, enc()).isAvailable(ZERO, ZERO); }