target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testEOFException() throws IOException { final ByteArrayInputStream input = new ByteArrayInputStream(new byte[] {}); try { EndianUtils.readSwappedDouble(input); fail("Expected EOFException"); } catch (final EOFException e) { } }
public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } EndianUtils(); }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testSwapShort() { assertEquals( (short) 0, EndianUtils.swapShort( (short) 0 ) ); assertEquals( (short) 0x0201, EndianUtils.swapShort( (short) 0x0102 ) ); assertEquals( (short) 0xffff, EndianUtils.swapShort( (short) 0xffff ) ); assertEquals( (short) 0x0102, EndianUtils.swapShort( (short) 0x0201 ) ); }
public static short swapShort(final short value) { return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + ( ( ( value >> 8 ) & 0xff ) << 0 ) ); }
EndianUtils { public static short swapShort(final short value) { return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + ( ( ( value >> 8 ) & 0xff ) << 0 ) ); } }
EndianUtils { public static short swapShort(final short value) { return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + ( ( ( value >> 8 ) & 0xff ) << 0 ) ); } EndianUtils(); }
EndianUtils { public static short swapShort(final short value) { return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + ( ( ( value >> 8 ) & 0xff ) << 0 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static short swapShort(final short value) { return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + ( ( ( value >> 8 ) & 0xff ) << 0 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testSwapInteger() { assertEquals( 0, EndianUtils.swapInteger( 0 ) ); assertEquals( 0x04030201, EndianUtils.swapInteger( 0x01020304 ) ); assertEquals( 0x01000000, EndianUtils.swapInteger( 0x00000001 ) ); assertEquals( 0x00000001, EndianUtils.swapInteger( 0x01000000 ) ); assertEquals( 0x11111111, EndianUtils.swapInteger( 0x11111111 ) ); assertEquals( 0xabcdef10, EndianUtils.swapInteger( 0x10efcdab ) ); assertEquals( 0xab, EndianUtils.swapInteger( 0xab000000 ) ); }
public static int swapInteger(final int value) { return ( ( ( value >> 0 ) & 0xff ) << 24 ) + ( ( ( value >> 8 ) & 0xff ) << 16 ) + ( ( ( value >> 16 ) & 0xff ) << 8 ) + ( ( ( value >> 24 ) & 0xff ) << 0 ); }
EndianUtils { public static int swapInteger(final int value) { return ( ( ( value >> 0 ) & 0xff ) << 24 ) + ( ( ( value >> 8 ) & 0xff ) << 16 ) + ( ( ( value >> 16 ) & 0xff ) << 8 ) + ( ( ( value >> 24 ) & 0xff ) << 0 ); } }
EndianUtils { public static int swapInteger(final int value) { return ( ( ( value >> 0 ) & 0xff ) << 24 ) + ( ( ( value >> 8 ) & 0xff ) << 16 ) + ( ( ( value >> 16 ) & 0xff ) << 8 ) + ( ( ( value >> 24 ) & 0xff ) << 0 ); } EndianUtils(); }
EndianUtils { public static int swapInteger(final int value) { return ( ( ( value >> 0 ) & 0xff ) << 24 ) + ( ( ( value >> 8 ) & 0xff ) << 16 ) + ( ( ( value >> 16 ) & 0xff ) << 8 ) + ( ( ( value >> 24 ) & 0xff ) << 0 ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static int swapInteger(final int value) { return ( ( ( value >> 0 ) & 0xff ) << 24 ) + ( ( ( value >> 8 ) & 0xff ) << 16 ) + ( ( ( value >> 16 ) & 0xff ) << 8 ) + ( ( ( value >> 24 ) & 0xff ) << 0 ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testSwapLong() { assertEquals( 0, EndianUtils.swapLong( 0 ) ); assertEquals( 0x0807060504030201L, EndianUtils.swapLong( 0x0102030405060708L ) ); assertEquals( 0xffffffffffffffffL, EndianUtils.swapLong( 0xffffffffffffffffL ) ); assertEquals( 0xab, EndianUtils.swapLong( 0xab00000000000000L ) ); }
public static long swapLong(final long value) { return ( ( ( value >> 0 ) & 0xff ) << 56 ) + ( ( ( value >> 8 ) & 0xff ) << 48 ) + ( ( ( value >> 16 ) & 0xff ) << 40 ) + ( ( ( value >> 24 ) & 0xff ) << 32 ) + ( ( ( value >> 32 ) & 0xff ) << 24 ) + ( ( ( value >> 40 ) & 0xff ) << 16 ) + ( ( ( value >> 48 ) & 0xff ) << 8 ) + ( ( ( value >> 56 ) & 0xff ) << 0 ); }
EndianUtils { public static long swapLong(final long value) { return ( ( ( value >> 0 ) & 0xff ) << 56 ) + ( ( ( value >> 8 ) & 0xff ) << 48 ) + ( ( ( value >> 16 ) & 0xff ) << 40 ) + ( ( ( value >> 24 ) & 0xff ) << 32 ) + ( ( ( value >> 32 ) & 0xff ) << 24 ) + ( ( ( value >> 40 ) & 0xff ) << 16 ) + ( ( ( value >> 48 ) & 0xff ) << 8 ) + ( ( ( value >> 56 ) & 0xff ) << 0 ); } }
EndianUtils { public static long swapLong(final long value) { return ( ( ( value >> 0 ) & 0xff ) << 56 ) + ( ( ( value >> 8 ) & 0xff ) << 48 ) + ( ( ( value >> 16 ) & 0xff ) << 40 ) + ( ( ( value >> 24 ) & 0xff ) << 32 ) + ( ( ( value >> 32 ) & 0xff ) << 24 ) + ( ( ( value >> 40 ) & 0xff ) << 16 ) + ( ( ( value >> 48 ) & 0xff ) << 8 ) + ( ( ( value >> 56 ) & 0xff ) << 0 ); } EndianUtils(); }
EndianUtils { public static long swapLong(final long value) { return ( ( ( value >> 0 ) & 0xff ) << 56 ) + ( ( ( value >> 8 ) & 0xff ) << 48 ) + ( ( ( value >> 16 ) & 0xff ) << 40 ) + ( ( ( value >> 24 ) & 0xff ) << 32 ) + ( ( ( value >> 32 ) & 0xff ) << 24 ) + ( ( ( value >> 40 ) & 0xff ) << 16 ) + ( ( ( value >> 48 ) & 0xff ) << 8 ) + ( ( ( value >> 56 ) & 0xff ) << 0 ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static long swapLong(final long value) { return ( ( ( value >> 0 ) & 0xff ) << 56 ) + ( ( ( value >> 8 ) & 0xff ) << 48 ) + ( ( ( value >> 16 ) & 0xff ) << 40 ) + ( ( ( value >> 24 ) & 0xff ) << 32 ) + ( ( ( value >> 32 ) & 0xff ) << 24 ) + ( ( ( value >> 40 ) & 0xff ) << 16 ) + ( ( ( value >> 48 ) & 0xff ) << 8 ) + ( ( ( value >> 56 ) & 0xff ) << 0 ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testSwapFloat() { assertEquals( 0.0f, EndianUtils.swapFloat( 0.0f ), 0.0 ); final float f1 = Float.intBitsToFloat( 0x01020304 ); final float f2 = Float.intBitsToFloat( 0x04030201 ); assertEquals( f2, EndianUtils.swapFloat( f1 ), 0.0 ); }
public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
EndianUtils { public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); } }
EndianUtils { public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); } EndianUtils(); }
EndianUtils { public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testSwapDouble() { assertEquals( 0.0, EndianUtils.swapDouble( 0.0 ), 0.0 ); final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); final double d2 = Double.longBitsToDouble( 0x0807060504030201L ); assertEquals( d2, EndianUtils.swapDouble( d1 ), 0.0 ); }
public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
EndianUtils { public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); } }
EndianUtils { public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); } EndianUtils(); }
EndianUtils { public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void eq() { String h = "<p>Hello<p>there<p>world"; Document doc = Jsoup.parse(h); assertEquals("there", doc.select("p").eq(1).text()); assertEquals("there", doc.select("p").get(1).text()); }
public Elements eq(int index) { return size() > index ? new Elements(get(index)) : new Elements(); }
Elements extends ArrayList<Element> { public Elements eq(int index) { return size() > index ? new Elements(get(index)) : new Elements(); } }
Elements extends ArrayList<Element> { public Elements eq(int index) { return size() > index ? new Elements(get(index)) : new Elements(); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public Elements eq(int index) { return size() > index ? new Elements(get(index)) : new Elements(); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public Elements eq(int index) { return size() > index ? new Elements(get(index)) : new Elements(); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testReadSwappedShort() throws IOException { final byte[] bytes = new byte[] { 0x02, 0x01 }; assertEquals( 0x0102, EndianUtils.readSwappedShort( bytes, 0 ) ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( 0x0102, EndianUtils.readSwappedShort( input ) ); }
public static short readSwappedShort(final byte[] data, final int offset) { return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); }
EndianUtils { public static short readSwappedShort(final byte[] data, final int offset) { return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } }
EndianUtils { public static short readSwappedShort(final byte[] data, final int offset) { return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } EndianUtils(); }
EndianUtils { public static short readSwappedShort(final byte[] data, final int offset) { return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static short readSwappedShort(final byte[] data, final int offset) { return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testWriteSwappedShort() throws IOException { byte[] bytes = new byte[2]; EndianUtils.writeSwappedShort( bytes, 0, (short) 0x0102 ); assertEquals( 0x02, bytes[0] ); assertEquals( 0x01, bytes[1] ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(2); EndianUtils.writeSwappedShort( baos, (short) 0x0102 ); bytes = baos.toByteArray(); assertEquals( 0x02, bytes[0] ); assertEquals( 0x01, bytes[1] ); }
public static void writeSwappedShort(final byte[] data, final int offset, final short value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); }
EndianUtils { public static void writeSwappedShort(final byte[] data, final int offset, final short value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); } }
EndianUtils { public static void writeSwappedShort(final byte[] data, final int offset, final short value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); } EndianUtils(); }
EndianUtils { public static void writeSwappedShort(final byte[] data, final int offset, final short value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static void writeSwappedShort(final byte[] data, final int offset, final short value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testReadSwappedUnsignedShort() throws IOException { final byte[] bytes = new byte[] { 0x02, 0x01 }; assertEquals( 0x00000102, EndianUtils.readSwappedUnsignedShort( bytes, 0 ) ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( 0x00000102, EndianUtils.readSwappedUnsignedShort( input ) ); }
public static int readSwappedUnsignedShort(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); }
EndianUtils { public static int readSwappedUnsignedShort(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } }
EndianUtils { public static int readSwappedUnsignedShort(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } EndianUtils(); }
EndianUtils { public static int readSwappedUnsignedShort(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static int readSwappedUnsignedShort(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testReadSwappedInteger() throws IOException { final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; assertEquals( 0x01020304, EndianUtils.readSwappedInteger( bytes, 0 ) ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( 0x01020304, EndianUtils.readSwappedInteger( input ) ); }
public static int readSwappedInteger(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); }
EndianUtils { public static int readSwappedInteger(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); } }
EndianUtils { public static int readSwappedInteger(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); } EndianUtils(); }
EndianUtils { public static int readSwappedInteger(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static int readSwappedInteger(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testWriteSwappedInteger() throws IOException { byte[] bytes = new byte[4]; EndianUtils.writeSwappedInteger( bytes, 0, 0x01020304 ); assertEquals( 0x04, bytes[0] ); assertEquals( 0x03, bytes[1] ); assertEquals( 0x02, bytes[2] ); assertEquals( 0x01, bytes[3] ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(4); EndianUtils.writeSwappedInteger( baos, 0x01020304 ); bytes = baos.toByteArray(); assertEquals( 0x04, bytes[0] ); assertEquals( 0x03, bytes[1] ); assertEquals( 0x02, bytes[2] ); assertEquals( 0x01, bytes[3] ); }
public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); }
EndianUtils { public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); } }
EndianUtils { public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); } EndianUtils(); }
EndianUtils { public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testReadSwappedUnsignedInteger() throws IOException { final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; assertEquals( 0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger( bytes, 0 ) ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( 0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger( input ) ); }
public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } EndianUtils(); }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testReadSwappedLong() throws IOException { final byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( bytes, 0 ) ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( input ) ); }
public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); }
EndianUtils { public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); } }
EndianUtils { public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); } EndianUtils(); }
EndianUtils { public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testWriteSwappedLong() throws IOException { byte[] bytes = new byte[8]; EndianUtils.writeSwappedLong( bytes, 0, 0x0102030405060708L ); assertEquals( 0x08, bytes[0] ); assertEquals( 0x07, bytes[1] ); assertEquals( 0x06, bytes[2] ); assertEquals( 0x05, bytes[3] ); assertEquals( 0x04, bytes[4] ); assertEquals( 0x03, bytes[5] ); assertEquals( 0x02, bytes[6] ); assertEquals( 0x01, bytes[7] ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(8); EndianUtils.writeSwappedLong( baos, 0x0102030405060708L ); bytes = baos.toByteArray(); assertEquals( 0x08, bytes[0] ); assertEquals( 0x07, bytes[1] ); assertEquals( 0x06, bytes[2] ); assertEquals( 0x05, bytes[3] ); assertEquals( 0x04, bytes[4] ); assertEquals( 0x03, bytes[5] ); assertEquals( 0x02, bytes[6] ); assertEquals( 0x01, bytes[7] ); }
public static void writeSwappedLong(final byte[] data, final int offset, final long value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); }
EndianUtils { public static void writeSwappedLong(final byte[] data, final int offset, final long value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); } }
EndianUtils { public static void writeSwappedLong(final byte[] data, final int offset, final long value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); } EndianUtils(); }
EndianUtils { public static void writeSwappedLong(final byte[] data, final int offset, final long value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static void writeSwappedLong(final byte[] data, final int offset, final long value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testReadSwappedFloat() throws IOException { final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; final float f1 = Float.intBitsToFloat( 0x01020304 ); final float f2 = EndianUtils.readSwappedFloat( bytes, 0 ); assertEquals( f1, f2, 0.0 ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( f1, EndianUtils.readSwappedFloat( input ), 0.0 ); }
public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
EndianUtils { public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); } }
EndianUtils { public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); } EndianUtils(); }
EndianUtils { public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testWriteSwappedFloat() throws IOException { byte[] bytes = new byte[4]; final float f1 = Float.intBitsToFloat( 0x01020304 ); EndianUtils.writeSwappedFloat( bytes, 0, f1 ); assertEquals( 0x04, bytes[0] ); assertEquals( 0x03, bytes[1] ); assertEquals( 0x02, bytes[2] ); assertEquals( 0x01, bytes[3] ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(4); EndianUtils.writeSwappedFloat( baos, f1 ); bytes = baos.toByteArray(); assertEquals( 0x04, bytes[0] ); assertEquals( 0x03, bytes[1] ); assertEquals( 0x02, bytes[2] ); assertEquals( 0x01, bytes[3] ); }
public static void writeSwappedFloat(final byte[] data, final int offset, final float value) { writeSwappedInteger( data, offset, Float.floatToIntBits( value ) ); }
EndianUtils { public static void writeSwappedFloat(final byte[] data, final int offset, final float value) { writeSwappedInteger( data, offset, Float.floatToIntBits( value ) ); } }
EndianUtils { public static void writeSwappedFloat(final byte[] data, final int offset, final float value) { writeSwappedInteger( data, offset, Float.floatToIntBits( value ) ); } EndianUtils(); }
EndianUtils { public static void writeSwappedFloat(final byte[] data, final int offset, final float value) { writeSwappedInteger( data, offset, Float.floatToIntBits( value ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static void writeSwappedFloat(final byte[] data, final int offset, final float value) { writeSwappedInteger( data, offset, Float.floatToIntBits( value ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void is() { String h = "<p>Hello<p title=foo>there<p>world"; Document doc = Jsoup.parse(h); Elements ps = doc.select("p"); assertTrue(ps.is("[title=foo]")); assertFalse(ps.is("[title=bar]")); }
public boolean is(String query) { Evaluator eval = QueryParser.parse(query); for (Element e : this) { if (e.is(eval)) return true; } return false; }
Elements extends ArrayList<Element> { public boolean is(String query) { Evaluator eval = QueryParser.parse(query); for (Element e : this) { if (e.is(eval)) return true; } return false; } }
Elements extends ArrayList<Element> { public boolean is(String query) { Evaluator eval = QueryParser.parse(query); for (Element e : this) { if (e.is(eval)) return true; } return false; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public boolean is(String query) { Evaluator eval = QueryParser.parse(query); for (Element e : this) { if (e.is(eval)) return true; } return false; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public boolean is(String query) { Evaluator eval = QueryParser.parse(query); for (Element e : this) { if (e.is(eval)) return true; } return false; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testReadSwappedDouble() throws IOException { final byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); final double d2 = EndianUtils.readSwappedDouble( bytes, 0 ); assertEquals( d1, d2, 0.0 ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( d1, EndianUtils.readSwappedDouble( input ), 0.0 ); }
public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } EndianUtils(); }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testWriteSwappedDouble() throws IOException { byte[] bytes = new byte[8]; final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); EndianUtils.writeSwappedDouble( bytes, 0, d1 ); assertEquals( 0x08, bytes[0] ); assertEquals( 0x07, bytes[1] ); assertEquals( 0x06, bytes[2] ); assertEquals( 0x05, bytes[3] ); assertEquals( 0x04, bytes[4] ); assertEquals( 0x03, bytes[5] ); assertEquals( 0x02, bytes[6] ); assertEquals( 0x01, bytes[7] ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(8); EndianUtils.writeSwappedDouble( baos, d1 ); bytes = baos.toByteArray(); assertEquals( 0x08, bytes[0] ); assertEquals( 0x07, bytes[1] ); assertEquals( 0x06, bytes[2] ); assertEquals( 0x05, bytes[3] ); assertEquals( 0x04, bytes[4] ); assertEquals( 0x03, bytes[5] ); assertEquals( 0x02, bytes[6] ); assertEquals( 0x01, bytes[7] ); }
public static void writeSwappedDouble(final byte[] data, final int offset, final double value) { writeSwappedLong( data, offset, Double.doubleToLongBits( value ) ); }
EndianUtils { public static void writeSwappedDouble(final byte[] data, final int offset, final double value) { writeSwappedLong( data, offset, Double.doubleToLongBits( value ) ); } }
EndianUtils { public static void writeSwappedDouble(final byte[] data, final int offset, final double value) { writeSwappedLong( data, offset, Double.doubleToLongBits( value ) ); } EndianUtils(); }
EndianUtils { public static void writeSwappedDouble(final byte[] data, final int offset, final double value) { writeSwappedLong( data, offset, Double.doubleToLongBits( value ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static void writeSwappedDouble(final byte[] data, final int offset, final double value) { writeSwappedLong( data, offset, Double.doubleToLongBits( value ) ); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void testUnsignedOverrun() throws Exception { final byte[] target = new byte[] { 0, 0, 0, (byte)0x80 }; final long expected = 0x80000000L; long actual = EndianUtils.readSwappedUnsignedInteger(target, 0); assertEquals("readSwappedUnsignedInteger(byte[], int) was incorrect", expected, actual); final ByteArrayInputStream in = new ByteArrayInputStream(target); actual = EndianUtils.readSwappedUnsignedInteger(in); assertEquals("readSwappedUnsignedInteger(InputStream) was incorrect", expected, actual); }
public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } EndianUtils(); }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
EndianUtils { public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); final long high = data[ offset + 3 ] & 0xff; return (high << 24) + (0xffffffffL & low); } EndianUtils(); static short swapShort(final short value); static int swapInteger(final int value); static long swapLong(final long value); static float swapFloat(final float value); static double swapDouble(final double value); static void writeSwappedShort(final byte[] data, final int offset, final short value); static short readSwappedShort(final byte[] data, final int offset); static int readSwappedUnsignedShort(final byte[] data, final int offset); static void writeSwappedInteger(final byte[] data, final int offset, final int value); static int readSwappedInteger(final byte[] data, final int offset); static long readSwappedUnsignedInteger(final byte[] data, final int offset); static void writeSwappedLong(final byte[] data, final int offset, final long value); static long readSwappedLong(final byte[] data, final int offset); static void writeSwappedFloat(final byte[] data, final int offset, final float value); static float readSwappedFloat(final byte[] data, final int offset); static void writeSwappedDouble(final byte[] data, final int offset, final double value); static double readSwappedDouble(final byte[] data, final int offset); static void writeSwappedShort(final OutputStream output, final short value); static short readSwappedShort(final InputStream input); static int readSwappedUnsignedShort(final InputStream input); static void writeSwappedInteger(final OutputStream output, final int value); static int readSwappedInteger(final InputStream input); static long readSwappedUnsignedInteger(final InputStream input); static void writeSwappedLong(final OutputStream output, final long value); static long readSwappedLong(final InputStream input); static void writeSwappedFloat(final OutputStream output, final float value); static float readSwappedFloat(final InputStream input); static void writeSwappedDouble(final OutputStream output, final double value); static double readSwappedDouble(final InputStream input); }
@Test public void noNames() throws Exception { final FullClassNameMatcher m = new FullClassNameMatcher(); assertFalse(m.matches(Integer.class.getName())); }
@Override public boolean matches(String className) { return classesSet.contains(className); }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } FullClassNameMatcher(String... classes); }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } FullClassNameMatcher(String... classes); @Override boolean matches(String className); }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } FullClassNameMatcher(String... classes); @Override boolean matches(String className); }
@Test public void withNames() throws Exception { final FullClassNameMatcher m = new FullClassNameMatcher(NAMES_ARRAY); assertTrue(m.matches(Integer.class.getName())); assertFalse(m.matches(String.class.getName())); }
@Override public boolean matches(String className) { return classesSet.contains(className); }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } FullClassNameMatcher(String... classes); }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } FullClassNameMatcher(String... classes); @Override boolean matches(String className); }
FullClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return classesSet.contains(className); } FullClassNameMatcher(String... classes); @Override boolean matches(String className); }
@Test public void noPattern() { ClassNameMatcher ca = new WildcardClassNameMatcher("org.foo"); assertTrue(ca.matches("org.foo")); assertFalse(ca.matches("org.foo.and.more")); assertFalse(ca.matches("org_foo")); }
@Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); @Override boolean matches(String className); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); @Override boolean matches(String className); }
@Test public void star() { ClassNameMatcher ca = new WildcardClassNameMatcher("org*"); assertTrue(ca.matches("org.foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); }
@Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); @Override boolean matches(String className); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); @Override boolean matches(String className); }
@Test public void starAndQuestionMark() { ClassNameMatcher ca = new WildcardClassNameMatcher("org?apache?something*"); assertTrue(ca.matches("org.apache_something.more")); assertFalse(ca.matches("org..apache_something.more")); }
@Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); @Override boolean matches(String className); }
WildcardClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); } WildcardClassNameMatcher(String pattern); @Override boolean matches(String className); }
@Test public void testSimplePatternFromString() { ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*"); assertTrue(ca.matches("foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); }
@Override public boolean matches(String className) { return pattern.matcher(className).matches(); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); @Override boolean matches(String className); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); @Override boolean matches(String className); }
@Test public void testSimplePatternFromPattern() { ClassNameMatcher ca = new RegexpClassNameMatcher(Pattern.compile("foo.*")); assertTrue(ca.matches("foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); }
@Override public boolean matches(String className) { return pattern.matcher(className).matches(); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); @Override boolean matches(String className); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); @Override boolean matches(String className); }
@Test public void parents() { Document doc = Jsoup.parse("<div><p>Hello</p></div><p>There</p>"); Elements parents = doc.select("p").parents(); assertEquals(3, parents.size()); assertEquals("div", parents.get(0).tagName()); assertEquals("body", parents.get(1).tagName()); assertEquals("html", parents.get(2).tagName()); }
public Elements parents() { HashSet<Element> combo = new LinkedHashSet<>(); for (Element e: this) { combo.addAll(e.parents()); } return new Elements(combo); }
Elements extends ArrayList<Element> { public Elements parents() { HashSet<Element> combo = new LinkedHashSet<>(); for (Element e: this) { combo.addAll(e.parents()); } return new Elements(combo); } }
Elements extends ArrayList<Element> { public Elements parents() { HashSet<Element> combo = new LinkedHashSet<>(); for (Element e: this) { combo.addAll(e.parents()); } return new Elements(combo); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public Elements parents() { HashSet<Element> combo = new LinkedHashSet<>(); for (Element e: this) { combo.addAll(e.parents()); } return new Elements(combo); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public Elements parents() { HashSet<Element> combo = new LinkedHashSet<>(); for (Element e: this) { combo.addAll(e.parents()); } return new Elements(combo); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testOrPattern() { ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*|bar.*"); assertTrue(ca.matches("foo.should.match")); assertTrue(ca.matches("bar.should.match")); assertFalse(ca.matches("zoo.should.not.match")); }
@Override public boolean matches(String className) { return pattern.matcher(className).matches(); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); @Override boolean matches(String className); }
RegexpClassNameMatcher implements ClassNameMatcher { @Override public boolean matches(String className) { return pattern.matcher(className).matches(); } RegexpClassNameMatcher(String regex); RegexpClassNameMatcher(Pattern pattern); @Override boolean matches(String className); }
@Test public void acceptCustomMatcher() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(ALWAYS_TRUE) ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void acceptPattern() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(Pattern.compile(".*MockSerializedClass.*")) ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void acceptWildcard() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept("org.apache.commons.io.*") ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test(expected = InvalidClassException.class) public void ourTestClassNotAccepted() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(Integer.class) ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void ourTestClassOnlyAccepted() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(MockSerializedClass.class) ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void ourTestClassAcceptedFirst() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(MockSerializedClass.class, Integer.class) ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void ourTestClassAcceptedSecond() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(Integer.class, MockSerializedClass.class) ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void ourTestClassAcceptedFirstWildcard() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept("*MockSerializedClass","*Integer") ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void ourTestClassAcceptedSecondWildcard() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept("*Integer","*MockSerializedClass") ); }
public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream accept(Class<?>... classes) { for (Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void not() { Document doc = Jsoup.parse("<div id=1><p>One</p></div> <div id=2><p><span>Two</span></p></div>"); Elements div1 = doc.select("div").not(":has(p > span)"); assertEquals(1, div1.size()); assertEquals("1", div1.first().id()); Elements div2 = doc.select("div").not("#1"); assertEquals(1, div2.size()); assertEquals("2", div2.first().id()); }
public Elements not(String query) { Elements out = Selector.select(query, this); return Selector.filterOut(this, out); }
Elements extends ArrayList<Element> { public Elements not(String query) { Elements out = Selector.select(query, this); return Selector.filterOut(this, out); } }
Elements extends ArrayList<Element> { public Elements not(String query) { Elements out = Selector.select(query, this); return Selector.filterOut(this, out); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public Elements not(String query) { Elements out = Selector.select(query, this); return Selector.filterOut(this, out); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public Elements not(String query) { Elements out = Selector.select(query, this); return Selector.filterOut(this, out); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test(expected = InvalidClassException.class) public void reject() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .accept(Long.class) .reject(MockSerializedClass.class, Integer.class) ); }
public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test(expected = InvalidClassException.class) public void rejectOnly() throws Exception { assertSerialization( willClose(new ValidatingObjectInputStream(testStream)) .reject(Integer.class) ); }
public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test(expected = RuntimeException.class) public void customInvalidMethod() throws Exception { class CustomVOIS extends ValidatingObjectInputStream { CustomVOIS(InputStream is) throws IOException { super(is); } @Override protected void invalidClassNameFound(String className) throws InvalidClassException { throw new RuntimeException("Custom exception"); } }; assertSerialization( willClose(new CustomVOIS(testStream)) .reject(Integer.class) ); }
public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
ValidatingObjectInputStream extends ObjectInputStream { public ValidatingObjectInputStream reject(Class<?>... classes) { for (Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; } ValidatingObjectInputStream(InputStream input); ValidatingObjectInputStream accept(Class<?>... classes); ValidatingObjectInputStream reject(Class<?>... classes); ValidatingObjectInputStream accept(String... patterns); ValidatingObjectInputStream reject(String... patterns); ValidatingObjectInputStream accept(Pattern pattern); ValidatingObjectInputStream reject(Pattern pattern); ValidatingObjectInputStream accept(ClassNameMatcher m); ValidatingObjectInputStream reject(ClassNameMatcher m); }
@Test public void testCaseSensitivity() { final File file3 = new File("FOO/file.txt"); final Comparator<File> sensitive = new PathFileComparator(null); assertTrue("sensitive file1 & file2 = 0", sensitive.compare(equalFile1, equalFile2) == 0); assertTrue("sensitive file1 & file3 > 0", sensitive.compare(equalFile1, file3) > 0); assertTrue("sensitive file1 & less > 0", sensitive.compare(equalFile1, lessFile) > 0); final Comparator<File> insensitive = PathFileComparator.PATH_INSENSITIVE_COMPARATOR; assertTrue("insensitive file1 & file2 = 0", insensitive.compare(equalFile1, equalFile2) == 0); assertTrue("insensitive file1 & file3 = 0", insensitive.compare(equalFile1, file3) == 0); assertTrue("insensitive file1 & file4 > 0", insensitive.compare(equalFile1, lessFile) > 0); assertTrue("insensitive file3 & less > 0", insensitive.compare(file3, lessFile) > 0); }
public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); }
PathFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); } }
PathFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); } PathFileComparator(); PathFileComparator(final IOCase caseSensitivity); }
PathFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); } PathFileComparator(); PathFileComparator(final IOCase caseSensitivity); int compare(final File file1, final File file2); @Override String toString(); }
PathFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); } PathFileComparator(); PathFileComparator(final IOCase caseSensitivity); int compare(final File file1, final File file2); @Override String toString(); static final Comparator<File> PATH_COMPARATOR; static final Comparator<File> PATH_REVERSE; static final Comparator<File> PATH_INSENSITIVE_COMPARATOR; static final Comparator<File> PATH_INSENSITIVE_REVERSE; static final Comparator<File> PATH_SYSTEM_COMPARATOR; static final Comparator<File> PATH_SYSTEM_REVERSE; }
@Test public void testCaseSensitivity() { final File file3 = new File("a/FOO.txt"); final Comparator<File> sensitive = new NameFileComparator(null); assertTrue("sensitive file1 & file2 = 0", sensitive.compare(equalFile1, equalFile2) == 0); assertTrue("sensitive file1 & file3 > 0", sensitive.compare(equalFile1, file3) > 0); assertTrue("sensitive file1 & less > 0", sensitive.compare(equalFile1, lessFile) > 0); final Comparator<File> insensitive = NameFileComparator.NAME_INSENSITIVE_COMPARATOR; assertTrue("insensitive file1 & file2 = 0", insensitive.compare(equalFile1, equalFile2) == 0); assertTrue("insensitive file1 & file3 = 0", insensitive.compare(equalFile1, file3) == 0); assertTrue("insensitive file1 & file4 > 0", insensitive.compare(equalFile1, lessFile) > 0); assertTrue("insensitive file3 & less > 0", insensitive.compare(file3, lessFile) > 0); }
public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); }
NameFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); } }
NameFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); } NameFileComparator(); NameFileComparator(final IOCase caseSensitivity); }
NameFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); } NameFileComparator(); NameFileComparator(final IOCase caseSensitivity); int compare(final File file1, final File file2); @Override String toString(); }
NameFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); } NameFileComparator(); NameFileComparator(final IOCase caseSensitivity); int compare(final File file1, final File file2); @Override String toString(); static final Comparator<File> NAME_COMPARATOR; static final Comparator<File> NAME_REVERSE; static final Comparator<File> NAME_INSENSITIVE_COMPARATOR; static final Comparator<File> NAME_INSENSITIVE_REVERSE; static final Comparator<File> NAME_SYSTEM_COMPARATOR; static final Comparator<File> NAME_SYSTEM_REVERSE; }
@Test public void testNonexistantFile() { final File nonexistantFile = new File(new File("."), "nonexistant.txt"); assertFalse(nonexistantFile.exists()); assertTrue("less", comparator.compare(nonexistantFile, moreFile) < 0); }
public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator(); SizeFileComparator(final boolean sumDirectoryContents); }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator(); SizeFileComparator(final boolean sumDirectoryContents); int compare(final File file1, final File file2); @Override String toString(); }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator(); SizeFileComparator(final boolean sumDirectoryContents); int compare(final File file1, final File file2); @Override String toString(); static final Comparator<File> SIZE_COMPARATOR; static final Comparator<File> SIZE_REVERSE; static final Comparator<File> SIZE_SUMDIR_COMPARATOR; static final Comparator<File> SIZE_SUMDIR_REVERSE; }
@Test public void testCompareDirectorySizes() { assertEquals("sumDirectoryContents=false", 0, comparator.compare(smallerDir, largerDir)); assertEquals("less", -1, SizeFileComparator.SIZE_SUMDIR_COMPARATOR.compare(smallerDir, largerDir)); assertEquals("less", 1, SizeFileComparator.SIZE_SUMDIR_REVERSE.compare(smallerDir, largerDir)); }
public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator(); SizeFileComparator(final boolean sumDirectoryContents); }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator(); SizeFileComparator(final boolean sumDirectoryContents); int compare(final File file1, final File file2); @Override String toString(); }
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator(); SizeFileComparator(final boolean sumDirectoryContents); int compare(final File file1, final File file2); @Override String toString(); static final Comparator<File> SIZE_COMPARATOR; static final Comparator<File> SIZE_REVERSE; static final Comparator<File> SIZE_SUMDIR_COMPARATOR; static final Comparator<File> SIZE_SUMDIR_REVERSE; }
@Test public void testCaseSensitivity() { final File file3 = new File("abc.FOO"); final Comparator<File> sensitive = new ExtensionFileComparator(null); assertTrue("sensitive file1 & file2 = 0", sensitive.compare(equalFile1, equalFile2) == 0); assertTrue("sensitive file1 & file3 > 0", sensitive.compare(equalFile1, file3) > 0); assertTrue("sensitive file1 & less > 0", sensitive.compare(equalFile1, lessFile) > 0); final Comparator<File> insensitive = ExtensionFileComparator.EXTENSION_INSENSITIVE_COMPARATOR; assertTrue("insensitive file1 & file2 = 0", insensitive.compare(equalFile1, equalFile2) == 0); assertTrue("insensitive file1 & file3 = 0", insensitive.compare(equalFile1, file3) == 0); assertTrue("insensitive file1 & file4 > 0", insensitive.compare(equalFile1, lessFile) > 0); assertTrue("insensitive file3 & less > 0", insensitive.compare(file3, lessFile) > 0); }
public int compare(final File file1, final File file2) { final String suffix1 = FilenameUtils.getExtension(file1.getName()); final String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); }
ExtensionFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { final String suffix1 = FilenameUtils.getExtension(file1.getName()); final String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); } }
ExtensionFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { final String suffix1 = FilenameUtils.getExtension(file1.getName()); final String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); } ExtensionFileComparator(); ExtensionFileComparator(final IOCase caseSensitivity); }
ExtensionFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { final String suffix1 = FilenameUtils.getExtension(file1.getName()); final String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); } ExtensionFileComparator(); ExtensionFileComparator(final IOCase caseSensitivity); int compare(final File file1, final File file2); @Override String toString(); }
ExtensionFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { final String suffix1 = FilenameUtils.getExtension(file1.getName()); final String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); } ExtensionFileComparator(); ExtensionFileComparator(final IOCase caseSensitivity); int compare(final File file1, final File file2); @Override String toString(); static final Comparator<File> EXTENSION_COMPARATOR; static final Comparator<File> EXTENSION_REVERSE; static final Comparator<File> EXTENSION_INSENSITIVE_COMPARATOR; static final Comparator<File> EXTENSION_INSENSITIVE_REVERSE; static final Comparator<File> EXTENSION_SYSTEM_COMPARATOR; static final Comparator<File> EXTENSION_SYSTEM_REVERSE; }
@Test public void constructorIterable_order() { final List<Comparator<File>> list = new ArrayList<Comparator<File>>(); list.add(SizeFileComparator.SIZE_COMPARATOR); list.add(ExtensionFileComparator.EXTENSION_COMPARATOR); final Comparator<File> c = new CompositeFileComparator(list); assertEquals("equal", 0, c.compare(equalFile1, equalFile2)); assertTrue("less", c.compare(lessFile, moreFile) < 0); assertTrue("more", c.compare(moreFile, lessFile) > 0); }
public int compare(final File file1, final File file2) { int result = 0; for (final Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; }
CompositeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { int result = 0; for (final Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; } }
CompositeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { int result = 0; for (final Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; } @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct CompositeFileComparator(final Comparator<File>... delegates); @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct CompositeFileComparator(final Iterable<Comparator<File>> delegates); }
CompositeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { int result = 0; for (final Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; } @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct CompositeFileComparator(final Comparator<File>... delegates); @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct CompositeFileComparator(final Iterable<Comparator<File>> delegates); int compare(final File file1, final File file2); @Override String toString(); }
CompositeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { int result = 0; for (final Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; } @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct CompositeFileComparator(final Comparator<File>... delegates); @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct CompositeFileComparator(final Iterable<Comparator<File>> delegates); int compare(final File file1, final File file2); @Override String toString(); }
@Test public void testRead() throws Exception { final ClosedInputStream cis = new ClosedInputStream(); assertEquals("read()", -1, cis.read()); cis.close(); }
@Override public int read() { return EOF; }
ClosedInputStream extends InputStream { @Override public int read() { return EOF; } }
ClosedInputStream extends InputStream { @Override public int read() { return EOF; } }
ClosedInputStream extends InputStream { @Override public int read() { return EOF; } @Override int read(); }
ClosedInputStream extends InputStream { @Override public int read() { return EOF; } @Override int read(); static final ClosedInputStream CLOSED_INPUT_STREAM; }
@Test public void traverse() { Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>"); final StringBuilder accum = new StringBuilder(); doc.select("div").traverse(new NodeVisitor() { public void head(Node node, int depth) { accum.append("<" + node.nodeName() + ">"); } public void tail(Node node, int depth) { accum.append("</" + node.nodeName() + ">"); } }); assertEquals("<div><p><#text></#text></p></div><div><#text></#text></div>", accum.toString()); }
public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testRead() throws Exception { final int size = 5; final TestNullReader reader = new TestNullReader(size); for (int i = 0; i < size; i++) { assertEquals("Check Value [" + i + "]", i, reader.read()); } assertEquals("End of File", -1, reader.read()); try { final int result = reader.read(); fail("Should have thrown an IOException, value=[" + result + "]"); } catch (final IOException e) { assertEquals("Read after end of file", e.getMessage()); } reader.close(); assertEquals("Available after close", 0, reader.getPosition()); }
@Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } NullReader(final long size); NullReader(final long size, final boolean markSupported, final boolean throwEofException); }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } NullReader(final long size); NullReader(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] chars); @Override int read(final char[] chars, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfChars); }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } NullReader(final long size); NullReader(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] chars); @Override int read(final char[] chars, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfChars); }
@Test public void testSkip() throws Exception { final Reader reader = new TestNullReader(10, true, false); assertEquals("Read 1", 0, reader.read()); assertEquals("Read 2", 1, reader.read()); assertEquals("Skip 1", 5, reader.skip(5)); assertEquals("Read 3", 7, reader.read()); assertEquals("Skip 2", 2, reader.skip(5)); assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); try { reader.skip(5); fail("Expected IOException for skipping after end of file"); } catch (final IOException e) { assertEquals("Skip after EOF IOException message", "Skip after end of file", e.getMessage()); } reader.close(); }
@Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; }
NullReader extends Reader { @Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; } }
NullReader extends Reader { @Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; } NullReader(final long size); NullReader(final long size, final boolean markSupported, final boolean throwEofException); }
NullReader extends Reader { @Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; } NullReader(final long size); NullReader(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] chars); @Override int read(final char[] chars, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfChars); }
NullReader extends Reader { @Override public long skip(final long numberOfChars) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfChars; long returnLength = numberOfChars; if (position > size) { returnLength = numberOfChars - (position - size); position = size; } return returnLength; } NullReader(final long size); NullReader(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] chars); @Override int read(final char[] chars, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfChars); }
@Test public void testClose() throws IOException { shielded.close(); assertFalse("closed", closed); assertEquals("read()", -1, shielded.read()); assertEquals("read()", data[0], original.read()); }
@Override public void close() { in = new ClosedInputStream(); }
CloseShieldInputStream extends ProxyInputStream { @Override public void close() { in = new ClosedInputStream(); } }
CloseShieldInputStream extends ProxyInputStream { @Override public void close() { in = new ClosedInputStream(); } CloseShieldInputStream(final InputStream in); }
CloseShieldInputStream extends ProxyInputStream { @Override public void close() { in = new ClosedInputStream(); } CloseShieldInputStream(final InputStream in); @Override void close(); }
CloseShieldInputStream extends ProxyInputStream { @Override public void close() { in = new ClosedInputStream(); } CloseShieldInputStream(final InputStream in); @Override void close(); }
@Test public void testReadOneByte() throws Exception { assertEquals('a', tee.read()); assertEquals("a", new String(output.toString(ASCII))); }
@Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
@Test public void testReadEverything() throws Exception { assertEquals('a', tee.read()); assertEquals('b', tee.read()); assertEquals('c', tee.read()); assertEquals(-1, tee.read()); assertEquals("abc", new String(output.toString(ASCII))); }
@Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
@Test public void testReadToArray() throws Exception { final byte[] buffer = new byte[8]; assertEquals(3, tee.read(buffer)); assertEquals('a', buffer[0]); assertEquals('b', buffer[1]); assertEquals('c', buffer[2]); assertEquals(-1, tee.read(buffer)); assertEquals("abc", new String(output.toString(ASCII))); }
@Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
@Test public void testReadToArrayWithOffset() throws Exception { final byte[] buffer = new byte[8]; assertEquals(3, tee.read(buffer, 4, 4)); assertEquals('a', buffer[4]); assertEquals('b', buffer[5]); assertEquals('c', buffer[6]); assertEquals(-1, tee.read(buffer, 4, 4)); assertEquals("abc", new String(output.toString(ASCII))); }
@Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
@Test public void testSkip() throws Exception { assertEquals('a', tee.read()); assertEquals(1, tee.skip(1)); assertEquals('c', tee.read()); assertEquals(-1, tee.read()); assertEquals("ac", new String(output.toString(ASCII))); }
@Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
@Test public void testMarkReset() throws Exception { assertEquals('a', tee.read()); tee.mark(1); assertEquals('b', tee.read()); tee.reset(); assertEquals('b', tee.read()); assertEquals('c', tee.read()); assertEquals(-1, tee.read()); assertEquals("abbc", new String(output.toString(ASCII))); }
@Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
TeeInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; } TeeInputStream(final InputStream input, final OutputStream branch); TeeInputStream( final InputStream input, final OutputStream branch, final boolean closeBranch); @Override void close(); @Override int read(); @Override int read(final byte[] bts, final int st, final int end); @Override int read(final byte[] bts); }
@Test public void testMarkSupported() throws Exception { final InputStream r = new CharSequenceInputStream("test", "UTF-8"); try { assertTrue(r.markSupported()); } finally { r.close(); } }
@Override public boolean markSupported() { return true; }
CharSequenceInputStream extends InputStream { @Override public boolean markSupported() { return true; } }
CharSequenceInputStream extends InputStream { @Override public boolean markSupported() { return true; } CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final Charset charset); CharSequenceInputStream(final CharSequence cs, final String charset); }
CharSequenceInputStream extends InputStream { @Override public boolean markSupported() { return true; } CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final Charset charset); CharSequenceInputStream(final CharSequence cs, final String charset); @Override int read(final byte[] b, int off, int len); @Override int read(); @Override int read(final byte[] b); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); }
CharSequenceInputStream extends InputStream { @Override public boolean markSupported() { return true; } CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final Charset charset); CharSequenceInputStream(final CharSequence cs, final String charset); @Override int read(final byte[] b, int off, int len); @Override int read(); @Override int read(final byte[] b); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); }
@Test public void forms() { Document doc = Jsoup.parse("<form id=1><input name=q></form><div /><form id=2><input name=f></form>"); Elements els = doc.select("*"); assertEquals(9, els.size()); List<FormElement> forms = els.forms(); assertEquals(2, forms.size()); assertTrue(forms.get(0) != null); assertTrue(forms.get(1) != null); assertEquals("1", forms.get(0).id()); assertEquals("2", forms.get(1).id()); }
public List<FormElement> forms() { ArrayList<FormElement> forms = new ArrayList<>(); for (Element el: this) if (el instanceof FormElement) forms.add((FormElement) el); return forms; }
Elements extends ArrayList<Element> { public List<FormElement> forms() { ArrayList<FormElement> forms = new ArrayList<>(); for (Element el: this) if (el instanceof FormElement) forms.add((FormElement) el); return forms; } }
Elements extends ArrayList<Element> { public List<FormElement> forms() { ArrayList<FormElement> forms = new ArrayList<>(); for (Element el: this) if (el instanceof FormElement) forms.add((FormElement) el); return forms; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public List<FormElement> forms() { ArrayList<FormElement> forms = new ArrayList<>(); for (Element el: this) if (el instanceof FormElement) forms.add((FormElement) el); return forms; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public List<FormElement> forms() { ArrayList<FormElement> forms = new ArrayList<>(); for (Element el: this) if (el instanceof FormElement) forms.add((FormElement) el); return forms; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testAvailable() throws Exception { for (final String csName : Charset.availableCharsets().keySet()) { try { if (isAvailabilityTestableForCharset(csName)) { testAvailableSkip(csName); testAvailableRead(csName); } } catch (UnsupportedOperationException e){ fail("Operation not supported for " + csName); } } }
@Override public int available() throws IOException { return this.bbuf.remaining() + this.cbuf.remaining(); }
CharSequenceInputStream extends InputStream { @Override public int available() throws IOException { return this.bbuf.remaining() + this.cbuf.remaining(); } }
CharSequenceInputStream extends InputStream { @Override public int available() throws IOException { return this.bbuf.remaining() + this.cbuf.remaining(); } CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final Charset charset); CharSequenceInputStream(final CharSequence cs, final String charset); }
CharSequenceInputStream extends InputStream { @Override public int available() throws IOException { return this.bbuf.remaining() + this.cbuf.remaining(); } CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final Charset charset); CharSequenceInputStream(final CharSequence cs, final String charset); @Override int read(final byte[] b, int off, int len); @Override int read(); @Override int read(final byte[] b); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); }
CharSequenceInputStream extends InputStream { @Override public int available() throws IOException { return this.bbuf.remaining() + this.cbuf.remaining(); } CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize); CharSequenceInputStream(final CharSequence cs, final Charset charset); CharSequenceInputStream(final CharSequence cs, final String charset); @Override int read(final byte[] b, int off, int len); @Override int read(); @Override int read(final byte[] b); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); }
@Test public void testEmptyBufferWithBOM() throws Exception { final byte[] data = new byte[] {}; final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); final byte[] buf = new byte[1024]; assertEquals(-1, in.read(buf)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testEmptyBufferWithoutBOM() throws Exception { final byte[] data = new byte[] {}; final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); final byte[] buf = new byte[1024]; assertEquals(-1, in.read(buf)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testLargeBufferWithBOM() throws Exception { final byte[] data = new byte[] { 'A', 'B', 'C' }; final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); final byte[] buf = new byte[1024]; assertData(data, buf, in.read(buf)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testLargeBufferWithoutBOM() throws Exception { final byte[] data = new byte[] { 'A', 'B', 'C' }; final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); final byte[] buf = new byte[1024]; assertData(data, buf, in.read(buf)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testLeadingNonBOMBufferedRead() throws Exception { final byte[] data = new byte[] { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD }; final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); final byte[] buf = new byte[1024]; assertData(data, buf, in.read(buf)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testLeadingNonBOMSingleRead() throws Exception { final byte[] data = new byte[] { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD }; final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); assertEquals(0xEF, in.read()); assertEquals(0xAB, in.read()); assertEquals(0xCD, in.read()); assertEquals(-1, in.read()); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testSmallBufferWithBOM() throws Exception { final byte[] data = new byte[] { 'A', 'B', 'C' }; final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); final byte[] buf = new byte[1024]; assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2)); assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testSmallBufferWithoutBOM() throws Exception { final byte[] data = new byte[] { 'A', 'B', 'C' }; final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); final byte[] buf = new byte[1024]; assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2)); assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2)); in.close(); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void testSupportCode() throws Exception { final InputStream in = createUtf8DataStream(new byte[] { 'A', 'B' }, true); final byte[] buf = new byte[1024]; final int len = in.read(buf); assertEquals(5, len); assertEquals(0xEF, buf[0] & 0xFF); assertEquals(0xBB, buf[1] & 0xFF); assertEquals(0xBF, buf[2] & 0xFF); assertEquals('A', buf[3] & 0xFF); assertEquals('B', buf[4] & 0xFF); assertData( new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF, 'A', 'B' }, buf, len); }
@Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
BOMInputStream extends ProxyInputStream { @Override public int read() throws IOException { final int b = readFirstBytes(); return b >= 0 ? b : in.read(); } BOMInputStream(final InputStream delegate); BOMInputStream(final InputStream delegate, final boolean include); BOMInputStream(final InputStream delegate, final ByteOrderMark... boms); BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms); boolean hasBOM(); boolean hasBOM(final ByteOrderMark bom); ByteOrderMark getBOM(); String getBOMCharsetName(); @Override int read(); @Override int read(final byte[] buf, int off, int len); @Override int read(final byte[] buf); @Override synchronized void mark(final int readlimit); @Override synchronized void reset(); @Override long skip(long n); }
@Test public void classWithHyphen() { Document doc = Jsoup.parse("<p class='tab-nav'>Check</p>"); Elements els = doc.getElementsByClass("tab-nav"); assertEquals(1, els.size()); assertEquals("Check", els.text()); }
public String text() { StringBuilder sb = new StringBuilder(); for (Element element : this) { if (sb.length() != 0) sb.append(" "); sb.append(element.text()); } return sb.toString(); }
Elements extends ArrayList<Element> { public String text() { StringBuilder sb = new StringBuilder(); for (Element element : this) { if (sb.length() != 0) sb.append(" "); sb.append(element.text()); } return sb.toString(); } }
Elements extends ArrayList<Element> { public String text() { StringBuilder sb = new StringBuilder(); for (Element element : this) { if (sb.length() != 0) sb.append(" "); sb.append(element.text()); } return sb.toString(); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public String text() { StringBuilder sb = new StringBuilder(); for (Element element : this) { if (sb.length() != 0) sb.append(" "); sb.append(element.text()); } return sb.toString(); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public String text() { StringBuilder sb = new StringBuilder(); for (Element element : this) { if (sb.length() != 0) sb.append(" "); sb.append(element.text()); } return sb.toString(); } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testRead() throws Exception { final int size = 5; final InputStream input = new TestNullInputStream(size); for (int i = 0; i < size; i++) { assertEquals("Check Size [" + i + "]", size - i, input.available()); assertEquals("Check Value [" + i + "]", i, input.read()); } assertEquals("Available after contents all read", 0, input.available()); assertEquals("End of File", -1, input.read()); assertEquals("Available after End of File", 0, input.available()); try { final int result = input.read(); fail("Should have thrown an IOException, byte=[" + result + "]"); } catch (final IOException e) { assertEquals("Read after end of file", e.getMessage()); } input.close(); assertEquals("Available after close", size, input.available()); }
@Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processByte(); }
NullInputStream extends InputStream { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processByte(); } }
NullInputStream extends InputStream { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processByte(); } NullInputStream(final long size); NullInputStream(final long size, final boolean markSupported, final boolean throwEofException); }
NullInputStream extends InputStream { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processByte(); } NullInputStream(final long size); NullInputStream(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final byte[] bytes); @Override int read(final byte[] bytes, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfBytes); }
NullInputStream extends InputStream { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processByte(); } NullInputStream(final long size); NullInputStream(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final byte[] bytes); @Override int read(final byte[] bytes, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfBytes); }
@Test public void testSkip() throws Exception { final InputStream input = new TestNullInputStream(10, true, false); assertEquals("Read 1", 0, input.read()); assertEquals("Read 2", 1, input.read()); assertEquals("Skip 1", 5, input.skip(5)); assertEquals("Read 3", 7, input.read()); assertEquals("Skip 2", 2, input.skip(5)); assertEquals("Skip 3 (EOF)", -1, input.skip(5)); try { input.skip(5); fail("Expected IOException for skipping after end of file"); } catch (final IOException e) { assertEquals("Skip after EOF IOException message", "Skip after end of file", e.getMessage()); } input.close(); }
@Override public long skip(final long numberOfBytes) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfBytes; long returnLength = numberOfBytes; if (position > size) { returnLength = numberOfBytes - (position - size); position = size; } return returnLength; }
NullInputStream extends InputStream { @Override public long skip(final long numberOfBytes) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfBytes; long returnLength = numberOfBytes; if (position > size) { returnLength = numberOfBytes - (position - size); position = size; } return returnLength; } }
NullInputStream extends InputStream { @Override public long skip(final long numberOfBytes) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfBytes; long returnLength = numberOfBytes; if (position > size) { returnLength = numberOfBytes - (position - size); position = size; } return returnLength; } NullInputStream(final long size); NullInputStream(final long size, final boolean markSupported, final boolean throwEofException); }
NullInputStream extends InputStream { @Override public long skip(final long numberOfBytes) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfBytes; long returnLength = numberOfBytes; if (position > size) { returnLength = numberOfBytes - (position - size); position = size; } return returnLength; } NullInputStream(final long size); NullInputStream(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final byte[] bytes); @Override int read(final byte[] bytes, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfBytes); }
NullInputStream extends InputStream { @Override public long skip(final long numberOfBytes) throws IOException { if (eof) { throw new IOException("Skip after end of file"); } if (position == size) { return doEndOfFile(); } position += numberOfBytes; long returnLength = numberOfBytes; if (position > size) { returnLength = numberOfBytes - (position - size); position = size; } return returnLength; } NullInputStream(final long size); NullInputStream(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final byte[] bytes); @Override int read(final byte[] bytes, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfBytes); }
@Test public void testClose() throws IOException { final Reader reader = new CharSequenceReader("FooBar"); checkRead(reader, "Foo"); reader.close(); checkRead(reader, "Foo"); }
@Override public void close() { idx = 0; mark = 0; }
CharSequenceReader extends Reader implements Serializable { @Override public void close() { idx = 0; mark = 0; } }
CharSequenceReader extends Reader implements Serializable { @Override public void close() { idx = 0; mark = 0; } CharSequenceReader(final CharSequence charSequence); }
CharSequenceReader extends Reader implements Serializable { @Override public void close() { idx = 0; mark = 0; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
CharSequenceReader extends Reader implements Serializable { @Override public void close() { idx = 0; mark = 0; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
@Test public void testMarkSupported() throws Exception { final Reader reader = new CharSequenceReader("FooBar"); assertTrue(reader.markSupported()); reader.close(); }
@Override public boolean markSupported() { return true; }
CharSequenceReader extends Reader implements Serializable { @Override public boolean markSupported() { return true; } }
CharSequenceReader extends Reader implements Serializable { @Override public boolean markSupported() { return true; } CharSequenceReader(final CharSequence charSequence); }
CharSequenceReader extends Reader implements Serializable { @Override public boolean markSupported() { return true; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
CharSequenceReader extends Reader implements Serializable { @Override public boolean markSupported() { return true; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
@Test public void testMark() throws IOException { final Reader reader = new CharSequenceReader("FooBar"); checkRead(reader, "Foo"); reader.mark(0); checkRead(reader, "Bar"); reader.reset(); checkRead(reader, "Bar"); reader.close(); checkRead(reader, "Foo"); reader.reset(); checkRead(reader, "Foo"); }
@Override public void mark(final int readAheadLimit) { mark = idx; }
CharSequenceReader extends Reader implements Serializable { @Override public void mark(final int readAheadLimit) { mark = idx; } }
CharSequenceReader extends Reader implements Serializable { @Override public void mark(final int readAheadLimit) { mark = idx; } CharSequenceReader(final CharSequence charSequence); }
CharSequenceReader extends Reader implements Serializable { @Override public void mark(final int readAheadLimit) { mark = idx; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
CharSequenceReader extends Reader implements Serializable { @Override public void mark(final int readAheadLimit) { mark = idx; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
@Test public void testSkip() throws IOException { final Reader reader = new CharSequenceReader("FooBar"); assertEquals(3, reader.skip(3)); checkRead(reader, "Bar"); assertEquals(-1, reader.skip(3)); reader.reset(); assertEquals(2, reader.skip(2)); assertEquals(4, reader.skip(10)); assertEquals(-1, reader.skip(1)); reader.close(); assertEquals(6, reader.skip(20)); assertEquals(-1, reader.read()); }
@Override public long skip(final long n) { if (n < 0) { throw new IllegalArgumentException( "Number of characters to skip is less than zero: " + n); } if (idx >= charSequence.length()) { return EOF; } final int dest = (int)Math.min(charSequence.length(), idx + n); final int count = dest - idx; idx = dest; return count; }
CharSequenceReader extends Reader implements Serializable { @Override public long skip(final long n) { if (n < 0) { throw new IllegalArgumentException( "Number of characters to skip is less than zero: " + n); } if (idx >= charSequence.length()) { return EOF; } final int dest = (int)Math.min(charSequence.length(), idx + n); final int count = dest - idx; idx = dest; return count; } }
CharSequenceReader extends Reader implements Serializable { @Override public long skip(final long n) { if (n < 0) { throw new IllegalArgumentException( "Number of characters to skip is less than zero: " + n); } if (idx >= charSequence.length()) { return EOF; } final int dest = (int)Math.min(charSequence.length(), idx + n); final int count = dest - idx; idx = dest; return count; } CharSequenceReader(final CharSequence charSequence); }
CharSequenceReader extends Reader implements Serializable { @Override public long skip(final long n) { if (n < 0) { throw new IllegalArgumentException( "Number of characters to skip is less than zero: " + n); } if (idx >= charSequence.length()) { return EOF; } final int dest = (int)Math.min(charSequence.length(), idx + n); final int count = dest - idx; idx = dest; return count; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
CharSequenceReader extends Reader implements Serializable { @Override public long skip(final long n) { if (n < 0) { throw new IllegalArgumentException( "Number of characters to skip is less than zero: " + n); } if (idx >= charSequence.length()) { return EOF; } final int dest = (int)Math.min(charSequence.length(), idx + n); final int count = dest - idx; idx = dest; return count; } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
@Test public void testRead() throws IOException { final Reader reader = new CharSequenceReader("Foo"); assertEquals('F', reader.read()); assertEquals('o', reader.read()); assertEquals('o', reader.read()); assertEquals(-1, reader.read()); assertEquals(-1, reader.read()); reader.close(); }
@Override public int read() { if (idx >= charSequence.length()) { return EOF; } else { return charSequence.charAt(idx++); } }
CharSequenceReader extends Reader implements Serializable { @Override public int read() { if (idx >= charSequence.length()) { return EOF; } else { return charSequence.charAt(idx++); } } }
CharSequenceReader extends Reader implements Serializable { @Override public int read() { if (idx >= charSequence.length()) { return EOF; } else { return charSequence.charAt(idx++); } } CharSequenceReader(final CharSequence charSequence); }
CharSequenceReader extends Reader implements Serializable { @Override public int read() { if (idx >= charSequence.length()) { return EOF; } else { return charSequence.charAt(idx++); } } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
CharSequenceReader extends Reader implements Serializable { @Override public int read() { if (idx >= charSequence.length()) { return EOF; } else { return charSequence.charAt(idx++); } } CharSequenceReader(final CharSequence charSequence); @Override void close(); @Override void mark(final int readAheadLimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] array, final int offset, final int length); @Override void reset(); @Override long skip(final long n); @Override String toString(); }
@Test public void testReadBoolean() throws IOException { bytes = new byte[] { 0x00, 0x01, 0x02, }; final ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); final SwappedDataInputStream sdis = new SwappedDataInputStream( bais ); assertEquals( false, sdis.readBoolean() ); assertEquals( true, sdis.readBoolean() ); assertEquals( true, sdis.readBoolean() ); sdis.close(); }
public boolean readBoolean() throws IOException, EOFException { return 0 != readByte(); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public boolean readBoolean() throws IOException, EOFException { return 0 != readByte(); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public boolean readBoolean() throws IOException, EOFException { return 0 != readByte(); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public boolean readBoolean() throws IOException, EOFException { return 0 != readByte(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public boolean readBoolean() throws IOException, EOFException { return 0 != readByte(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadByte() throws IOException { assertEquals( 0x01, this.sdis.readByte() ); }
public byte readByte() throws IOException, EOFException { return (byte)in.read(); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public byte readByte() throws IOException, EOFException { return (byte)in.read(); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public byte readByte() throws IOException, EOFException { return (byte)in.read(); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public byte readByte() throws IOException, EOFException { return (byte)in.read(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public byte readByte() throws IOException, EOFException { return (byte)in.read(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadChar() throws IOException { assertEquals( (char) 0x0201, this.sdis.readChar() ); }
public char readChar() throws IOException, EOFException { return (char)readShort(); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public char readChar() throws IOException, EOFException { return (char)readShort(); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public char readChar() throws IOException, EOFException { return (char)readShort(); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public char readChar() throws IOException, EOFException { return (char)readShort(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public char readChar() throws IOException, EOFException { return (char)readShort(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void siblings() { Document doc = Jsoup.parse("<div><p>1<p>2<p>3<p>4<p>5<p>6</div><div><p>7<p>8<p>9<p>10<p>11<p>12</div>"); Elements els = doc.select("p:eq(3)"); assertEquals(2, els.size()); Elements next = els.next(); assertEquals(2, next.size()); assertEquals("5", next.first().text()); assertEquals("11", next.last().text()); assertEquals(0, els.next("p:contains(6)").size()); final Elements nextF = els.next("p:contains(5)"); assertEquals(1, nextF.size()); assertEquals("5", nextF.first().text()); Elements nextA = els.nextAll(); assertEquals(4, nextA.size()); assertEquals("5", nextA.first().text()); assertEquals("12", nextA.last().text()); Elements nextAF = els.nextAll("p:contains(6)"); assertEquals(1, nextAF.size()); assertEquals("6", nextAF.first().text()); Elements prev = els.prev(); assertEquals(2, prev.size()); assertEquals("3", prev.first().text()); assertEquals("9", prev.last().text()); assertEquals(0, els.prev("p:contains(1)").size()); final Elements prevF = els.prev("p:contains(3)"); assertEquals(1, prevF.size()); assertEquals("3", prevF.first().text()); Elements prevA = els.prevAll(); assertEquals(6, prevA.size()); assertEquals("3", prevA.first().text()); assertEquals("7", prevA.last().text()); Elements prevAF = els.prevAll("p:contains(1)"); assertEquals(1, prevAF.size()); assertEquals("1", prevAF.first().text()); }
private Elements siblings(String query, boolean next, boolean all) { Elements els = new Elements(); Evaluator eval = query != null? QueryParser.parse(query) : null; for (Element e : this) { do { Element sib = next ? e.nextElementSibling() : e.previousElementSibling(); if (sib == null) break; if (eval == null) els.add(sib); else if (sib.is(eval)) els.add(sib); e = sib; } while (all); } return els; }
Elements extends ArrayList<Element> { private Elements siblings(String query, boolean next, boolean all) { Elements els = new Elements(); Evaluator eval = query != null? QueryParser.parse(query) : null; for (Element e : this) { do { Element sib = next ? e.nextElementSibling() : e.previousElementSibling(); if (sib == null) break; if (eval == null) els.add(sib); else if (sib.is(eval)) els.add(sib); e = sib; } while (all); } return els; } }
Elements extends ArrayList<Element> { private Elements siblings(String query, boolean next, boolean all) { Elements els = new Elements(); Evaluator eval = query != null? QueryParser.parse(query) : null; for (Element e : this) { do { Element sib = next ? e.nextElementSibling() : e.previousElementSibling(); if (sib == null) break; if (eval == null) els.add(sib); else if (sib.is(eval)) els.add(sib); e = sib; } while (all); } return els; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { private Elements siblings(String query, boolean next, boolean all) { Elements els = new Elements(); Evaluator eval = query != null? QueryParser.parse(query) : null; for (Element e : this) { do { Element sib = next ? e.nextElementSibling() : e.previousElementSibling(); if (sib == null) break; if (eval == null) els.add(sib); else if (sib.is(eval)) els.add(sib); e = sib; } while (all); } return els; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { private Elements siblings(String query, boolean next, boolean all) { Elements els = new Elements(); Evaluator eval = query != null? QueryParser.parse(query) : null; for (Element e : this) { do { Element sib = next ? e.nextElementSibling() : e.previousElementSibling(); if (sib == null) break; if (eval == null) els.add(sib); else if (sib.is(eval)) els.add(sib); e = sib; } while (all); } return els; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Override @Test public void shouldGetResultFromResultSetByPosition() throws Exception { byte[] byteArray = new byte[]{1, 2}; when(rs.getBytes(1)).thenReturn(byteArray); when(rs.wasNull()).thenReturn(false); assertThat(TYPE_HANDLER.getResult(rs, 1), is(new Byte[]{1, 2})); }
private Byte[] getBytes(byte[] bytes) { Byte[] returnValue = null; if (bytes != null) { returnValue = ByteArrayUtils.convertToObjectArray(bytes); } return returnValue; }
ByteObjectArrayTypeHandler extends BaseTypeHandler<Byte[]> { private Byte[] getBytes(byte[] bytes) { Byte[] returnValue = null; if (bytes != null) { returnValue = ByteArrayUtils.convertToObjectArray(bytes); } return returnValue; } }
ByteObjectArrayTypeHandler extends BaseTypeHandler<Byte[]> { private Byte[] getBytes(byte[] bytes) { Byte[] returnValue = null; if (bytes != null) { returnValue = ByteArrayUtils.convertToObjectArray(bytes); } return returnValue; } }
ByteObjectArrayTypeHandler extends BaseTypeHandler<Byte[]> { private Byte[] getBytes(byte[] bytes) { Byte[] returnValue = null; if (bytes != null) { returnValue = ByteArrayUtils.convertToObjectArray(bytes); } return returnValue; } @Override void setNonNullParameter(PreparedStatement ps, int index, Byte[] parameter, JdbcType jdbcType); @Override Byte[] getNullableResult(ResultSet rs, int index); @Override JdbcType getJdbcType(); }
ByteObjectArrayTypeHandler extends BaseTypeHandler<Byte[]> { private Byte[] getBytes(byte[] bytes) { Byte[] returnValue = null; if (bytes != null) { returnValue = ByteArrayUtils.convertToObjectArray(bytes); } return returnValue; } @Override void setNonNullParameter(PreparedStatement ps, int index, Byte[] parameter, JdbcType jdbcType); @Override Byte[] getNullableResult(ResultSet rs, int index); @Override JdbcType getJdbcType(); }
@Test public void testReadDouble() throws IOException { assertEquals( Double.longBitsToDouble(0x0807060504030201L), this.sdis.readDouble(), 0 ); }
public double readDouble() throws IOException, EOFException { return EndianUtils.readSwappedDouble( in ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public double readDouble() throws IOException, EOFException { return EndianUtils.readSwappedDouble( in ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public double readDouble() throws IOException, EOFException { return EndianUtils.readSwappedDouble( in ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public double readDouble() throws IOException, EOFException { return EndianUtils.readSwappedDouble( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public double readDouble() throws IOException, EOFException { return EndianUtils.readSwappedDouble( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadFloat() throws IOException { assertEquals( Float.intBitsToFloat(0x04030201), this.sdis.readFloat(), 0 ); }
public float readFloat() throws IOException, EOFException { return EndianUtils.readSwappedFloat( in ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public float readFloat() throws IOException, EOFException { return EndianUtils.readSwappedFloat( in ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public float readFloat() throws IOException, EOFException { return EndianUtils.readSwappedFloat( in ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public float readFloat() throws IOException, EOFException { return EndianUtils.readSwappedFloat( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public float readFloat() throws IOException, EOFException { return EndianUtils.readSwappedFloat( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadFully() throws IOException { final byte[] bytesIn = new byte[8]; this.sdis.readFully(bytesIn); for( int i=0; i<8; i++) { assertEquals( bytes[i], bytesIn[i] ); } }
public void readFully( final byte[] data ) throws IOException, EOFException { readFully( data, 0, data.length ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public void readFully( final byte[] data ) throws IOException, EOFException { readFully( data, 0, data.length ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public void readFully( final byte[] data ) throws IOException, EOFException { readFully( data, 0, data.length ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public void readFully( final byte[] data ) throws IOException, EOFException { readFully( data, 0, data.length ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public void readFully( final byte[] data ) throws IOException, EOFException { readFully( data, 0, data.length ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadInt() throws IOException { assertEquals( 0x04030201, this.sdis.readInt() ); }
public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test(expected = UnsupportedOperationException.class) public void testReadLine() throws IOException { this.sdis.readLine(); fail("readLine should be unsupported. "); }
public String readLine() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readLine()" ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readLine() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readLine()" ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readLine() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readLine()" ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readLine() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readLine()" ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readLine() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readLine()" ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadLong() throws IOException { assertEquals( 0x0807060504030201L, this.sdis.readLong() ); }
public long readLong() throws IOException, EOFException { return EndianUtils.readSwappedLong( in ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public long readLong() throws IOException, EOFException { return EndianUtils.readSwappedLong( in ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public long readLong() throws IOException, EOFException { return EndianUtils.readSwappedLong( in ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public long readLong() throws IOException, EOFException { return EndianUtils.readSwappedLong( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public long readLong() throws IOException, EOFException { return EndianUtils.readSwappedLong( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadShort() throws IOException { assertEquals( (short) 0x0201, this.sdis.readShort() ); }
public short readShort() throws IOException, EOFException { return EndianUtils.readSwappedShort( in ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public short readShort() throws IOException, EOFException { return EndianUtils.readSwappedShort( in ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public short readShort() throws IOException, EOFException { return EndianUtils.readSwappedShort( in ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public short readShort() throws IOException, EOFException { return EndianUtils.readSwappedShort( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public short readShort() throws IOException, EOFException { return EndianUtils.readSwappedShort( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadUnsignedByte() throws IOException { assertEquals( 0x01, this.sdis.readUnsignedByte() ); }
public int readUnsignedByte() throws IOException, EOFException { return in.read(); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedByte() throws IOException, EOFException { return in.read(); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedByte() throws IOException, EOFException { return in.read(); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedByte() throws IOException, EOFException { return in.read(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedByte() throws IOException, EOFException { return in.read(); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void testReadUnsignedShort() throws IOException { assertEquals( (short) 0x0201, this.sdis.readUnsignedShort() ); }
public int readUnsignedShort() throws IOException, EOFException { return EndianUtils.readSwappedUnsignedShort( in ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedShort() throws IOException, EOFException { return EndianUtils.readSwappedUnsignedShort( in ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedShort() throws IOException, EOFException { return EndianUtils.readSwappedUnsignedShort( in ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedShort() throws IOException, EOFException { return EndianUtils.readSwappedUnsignedShort( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int readUnsignedShort() throws IOException, EOFException { return EndianUtils.readSwappedUnsignedShort( in ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test(expected = UnsupportedOperationException.class) public void testReadUTF() throws IOException { this.sdis.readUTF(); fail("readUTF should be unsupported. "); }
public String readUTF() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readUTF()" ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readUTF() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readUTF()" ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readUTF() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readUTF()" ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readUTF() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readUTF()" ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public String readUTF() throws IOException, EOFException { throw new UnsupportedOperationException( "Operation not supported: readUTF()" ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@Test public void eachText() { Document doc = Jsoup.parse("<div><p>1<p>2<p>3<p>4<p>5<p>6</div><div><p>7<p>8<p>9<p>10<p>11<p>12<p></p></div>"); List<String> divText = doc.select("div").eachText(); assertEquals(2, divText.size()); assertEquals("1 2 3 4 5 6", divText.get(0)); assertEquals("7 8 9 10 11 12", divText.get(1)); List<String> pText = doc.select("p").eachText(); Elements ps = doc.select("p"); assertEquals(13, ps.size()); assertEquals(12, pText.size()); assertEquals("1", pText.get(0)); assertEquals("2", pText.get(1)); assertEquals("5", pText.get(4)); assertEquals("7", pText.get(6)); assertEquals("12", pText.get(11)); }
public List<String> eachText() { ArrayList<String> texts = new ArrayList<>(size()); for (Element el: this) { if (el.hasText()) texts.add(el.text()); } return texts; }
Elements extends ArrayList<Element> { public List<String> eachText() { ArrayList<String> texts = new ArrayList<>(size()); for (Element el: this) { if (el.hasText()) texts.add(el.text()); } return texts; } }
Elements extends ArrayList<Element> { public List<String> eachText() { ArrayList<String> texts = new ArrayList<>(size()); for (Element el: this) { if (el.hasText()) texts.add(el.text()); } return texts; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); }
Elements extends ArrayList<Element> { public List<String> eachText() { ArrayList<String> texts = new ArrayList<>(size()); for (Element el: this) { if (el.hasText()) texts.add(el.text()); } return texts; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public List<String> eachText() { ArrayList<String> texts = new ArrayList<>(size()); for (Element el: this) { if (el.hasText()) texts.add(el.text()); } return texts; } Elements(); Elements(int initialCapacity); Elements(Collection<Element> elements); Elements(List<Element> elements); Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
@Test public void testSkipBytes() throws IOException { this.sdis.skipBytes(4); assertEquals( 0x08070605, this.sdis.readInt() ); }
public int skipBytes( final int count ) throws IOException, EOFException { return (int)in.skip( count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int skipBytes( final int count ) throws IOException, EOFException { return (int)in.skip( count ); } }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int skipBytes( final int count ) throws IOException, EOFException { return (int)in.skip( count ); } SwappedDataInputStream( final InputStream input ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int skipBytes( final int count ) throws IOException, EOFException { return (int)in.skip( count ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
SwappedDataInputStream extends ProxyInputStream implements DataInput { public int skipBytes( final int count ) throws IOException, EOFException { return (int)in.skip( count ); } SwappedDataInputStream( final InputStream input ); boolean readBoolean(); byte readByte(); char readChar(); double readDouble(); float readFloat(); void readFully( final byte[] data ); void readFully( final byte[] data, final int offset, final int length ); int readInt(); String readLine(); long readLong(); short readShort(); int readUnsignedByte(); int readUnsignedShort(); String readUTF(); int skipBytes( final int count ); }
@SuppressWarnings("deprecation") @Test public void testMultiByteBreak() throws Exception { System.out.println("testMultiByteBreak() Default charset: "+Charset.defaultCharset().displayName()); final long delay = 50; final File origin = new File(this.getClass().getResource("/test-file-utf8.bin").toURI()); final File file = new File(getTestDirectory(), "testMultiByteBreak.txt"); createFile(file, 0); final TestTailerListener listener = new TestTailerListener(); final String osname = System.getProperty("os.name"); final boolean isWindows = osname.startsWith("Windows"); final Charset charsetUTF8 = Charsets.UTF_8; tailer = new Tailer(file, charsetUTF8, listener, delay, false, isWindows, 4096); final Thread thread = new Thread(tailer); thread.start(); Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8); BufferedReader reader = null; try{ List<String> lines = new ArrayList<String>(); reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin), charsetUTF8)); String line; while((line = reader.readLine()) != null){ out.write(line); out.write("\n"); lines.add(line); } out.close(); final long testDelayMillis = delay * 10; TestUtils.sleep(testDelayMillis); List<String> tailerlines = listener.getLines(); assertEquals("line count",lines.size(),tailerlines.size()); for(int i = 0,len = lines.size();i<len;i++){ final String expected = lines.get(i); final String actual = tailerlines.get(i); if (!expected.equals(actual)) { fail("Line: " + i + "\nExp: (" + expected.length() + ") " + expected + "\nAct: (" + actual.length() + ") "+ actual); } } }finally{ tailer.stop(); IOUtils.closeQuietly(reader); IOUtils.closeQuietly(out); } }
private void stop(final Exception e) { listener.handle(e); stop(); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
@Test public void testTailerEof() throws Exception { final long delay = 50; final File file = new File(getTestDirectory(), "tailer2-test.txt"); createFile(file, 0); final TestTailerListener listener = new TestTailerListener(); final Tailer tailer = new Tailer(file, listener, delay, false); final Thread thread = new Thread(tailer); thread.start(); final FileWriter writer = null; try { writeString(file, "Line"); TestUtils.sleep(delay * 2); List<String> lines = listener.getLines(); assertEquals("1 line count", 0, lines.size()); writeString(file, " one\n"); TestUtils.sleep(delay * 2); lines = listener.getLines(); assertEquals("1 line count", 1, lines.size()); assertEquals("1 line 1", "Line one", lines.get(0)); listener.clear(); } finally { tailer.stop(); TestUtils.sleep(delay * 2); IOUtils.closeQuietly(writer); } }
private void stop(final Exception e) { listener.handle(e); stop(); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
@Test public void testTailer() throws Exception { final long delayMillis = 50; final File file = new File(getTestDirectory(), "tailer1-test.txt"); createFile(file, 0); final TestTailerListener listener = new TestTailerListener(); final String osname = System.getProperty("os.name"); final boolean isWindows = osname.startsWith("Windows"); tailer = new Tailer(file, listener, delayMillis, false, isWindows); final Thread thread = new Thread(tailer); thread.start(); write(file, "Line one", "Line two"); final long testDelayMillis = delayMillis * 10; TestUtils.sleep(testDelayMillis); List<String> lines = listener.getLines(); assertEquals("1 line count", 2, lines.size()); assertEquals("1 line 1", "Line one", lines.get(0)); assertEquals("1 line 2", "Line two", lines.get(1)); listener.clear(); write(file, "Line three"); TestUtils.sleep(testDelayMillis); lines = listener.getLines(); assertEquals("2 line count", 1, lines.size()); assertEquals("2 line 3", "Line three", lines.get(0)); listener.clear(); lines = FileUtils.readLines(file, "UTF-8"); assertEquals("3 line count", 3, lines.size()); assertEquals("3 line 1", "Line one", lines.get(0)); assertEquals("3 line 2", "Line two", lines.get(1)); assertEquals("3 line 3", "Line three", lines.get(2)); file.delete(); final boolean exists = file.exists(); assertFalse("File should not exist", exists); createFile(file, 0); TestUtils.sleep(testDelayMillis); write(file, "Line four"); TestUtils.sleep(testDelayMillis); lines = listener.getLines(); assertEquals("4 line count", 1, lines.size()); assertEquals("4 line 3", "Line four", lines.get(0)); listener.clear(); thread.interrupt(); TestUtils.sleep(testDelayMillis * 4); write(file, "Line five"); assertEquals("4 line count", 0, listener.getLines().size()); assertNotNull("Missing InterruptedException", listener.exception); assertTrue("Unexpected Exception: " + listener.exception, listener.exception instanceof InterruptedException); assertEquals("Expected init to be called", 1 , listener.initialised); assertEquals("fileNotFound should not be called", 0 , listener.notFound); assertEquals("fileRotated should be be called", 1 , listener.rotated); tailer.stop(); tailer=null; }
public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } Tailer(final File file, final TailerListener listener); Tailer(final File file, final TailerListener listener, final long delayMillis); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }