@SuppressWarnings("unchecked") @Override public int encodedLength(Object[] val) { assert fields.length >= val.length; int sum = 0; for (int i = 0; i < val.length; i++) { sum += fields[i].encodedLength(val[i]); } return sum; }
@Override public int encodedLength(T val) { return wrapped.encodedLength(val) + term.length; }
@Override public int encodedLength(Object val) { Integer i = null; String s = null; try { i = (Integer) val; } catch (ClassCastException e) {} try { s = (String) val; } catch (ClassCastException e) {} if (null != i) return 1 + typeA.encodedLength(i); if (null != s) return 1 + typeB.encodedLength(s); throw new IllegalArgumentException("val is not a valid member of this union."); }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<String> type : new OrderedString[] { OrderedString.ASCENDING, OrderedString.DESCENDING }) { for (String val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + val, buff.getPosition(), type.encodedLength(val)); } } } }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<byte[]> type : new OrderedBlob[] { OrderedBlob.ASCENDING, OrderedBlob.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } } }
generic.encodedLength(constructorArgs[i])); encodedSpecialized[i] = new SimplePositionedMutableByteRange( specialized.encodedLength(vals[i]));
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<byte[]> type : new OrderedBlobVar[] { OrderedBlobVar.ASCENDING, OrderedBlobVar.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } } }
@SuppressWarnings("unchecked") @Override public int encodedLength(Object[] val) { assert fields.length >= val.length; int sum = 0; for (int i = 0; i < val.length; i++) { sum += fields[i].encodedLength(val[i]); } return sum; }
@SuppressWarnings("unchecked") @Override public int encodedLength(Object[] val) { assert fields.length >= val.length; int sum = 0; for (int i = 0; i < val.length; i++) { sum += fields[i].encodedLength(val[i]); } return sum; }
@Override public int encodedLength(T val) { return wrapped.encodedLength(val) + term.length; }
@SuppressWarnings("unchecked") @Override public int encodedLength(Object[] val) { assert fields.length >= val.length; int sum = 0; for (int i = 0; i < val.length; i++) sum += fields[i].encodedLength(val[i]); return sum; }
@Override public int encodedLength(T val) { return wrapped.encodedLength(val) + term.length; }
@Override public int encodedLength(T val) { return wrapped.encodedLength(val) + term.length; }
@Override public int encodedLength(Object val) { Integer i = null; String s = null; try { i = (Integer) val; } catch (ClassCastException e) {} try { s = (String) val; } catch (ClassCastException e) {} if (null != i) return 1 + typeA.encodedLength(i); if (null != s) return 1 + typeB.encodedLength(s); throw new IllegalArgumentException("val is not a valid member of this union."); }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<String> type : new OrderedString[] { OrderedString.ASCENDING, OrderedString.DESCENDING }) { for (String val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + val, buff.getPosition(), type.encodedLength(val)); } } } }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<String> type : new OrderedString[] { OrderedString.ASCENDING, OrderedString.DESCENDING }) { for (String val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + val, buff.getPosition(), type.encodedLength(val)); } } } }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<byte[]> type : new OrderedBlobVar[] { OrderedBlobVar.ASCENDING, OrderedBlobVar.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } } }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<byte[]> type : new OrderedBlob[] { OrderedBlob.ASCENDING, OrderedBlob.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } } }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<byte[]> type : new OrderedBlobVar[] { OrderedBlobVar.ASCENDING, OrderedBlobVar.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } } }
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (DataType<byte[]> type : new OrderedBlob[] { OrderedBlob.ASCENDING, OrderedBlob.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals( "encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } } }