Package org.apache.uima.util.impl
Class DataIO
- java.lang.Object
-
- org.apache.uima.util.impl.DataIO
-
public class DataIO extends Object
Methods for working with Data during I/O
-
-
Constructor Summary
Constructors Constructor Description DataIO()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdecodeUTF8(ByteBuffer in, int length)static longlengthUTFv(String string)static intlengthVnumber(int v)static intlengthVnumber(long v)static intlengthVPNnumber(int v)static intlengthVPNnumber(long v)static byte[]readByteArray(DataInput in)static int[]readIntArray(DataInput in)static int[]readIntArrayDelta(DataInput in)static long[]readLongArray(DataInput in)static long[]readLongArrayDelta(DataInput in)static longreadRestOfVlong(DataInput in, int firstByte)static intreadUnsignedByte(DataInput in)static StringreadUTFv(DataInput in)static longreadVlong(DataInput in)static intreadVnumber(DataInput in)static voidwriteByte(DataOutput out, int v)DataOutputStream writeByte with checking of argumentstatic voidwriteByteArray(DataOutput out, byte[] v)static voidwriteIntArray(DataOutput out, int[] v)write array preceded by its lengthstatic voidwriteIntArrayDelta(DataOutput out, int[] v)Write delta encoded value, for increasing valuesstatic voidwriteLongArray(DataOutput out, long[] v)static voidwriteLongArrayDelta(DataOutput out, long[] v)static voidwriteShort(DataOutput out, int v)DataOutputStream writeShort with checking of argumentstatic voidwriteUnsignedByte(DataOutput out, int v)Write lower 8 bitsstatic voidwriteUTFv(String string, DataOutput out)Similar to writeUTF, but ok for strings > 32K bytes long and better for strings < 127 string utf-8 length must be ≤ Integer.MAX_VALUE - 1static voidwriteVnumber(DataOutput out, int v)Write a positive number with the fewest bytes possible up to 127 written as a byte high order bit on means get another byte Note: value treated as unsigned 32 bit intstatic voidwriteVnumber(DataOutput out, long v)Write a positive long with the fewest bytes possible; up to 127 written as a byte, high order bit on means get another byte.static voidwriteVPNnumber(DataOutput out, int v)write a positive or negative number, optimized for fewer bytes near 0 sign put in low order bit, rest of number converted to positive and shifted left 1 max negative written as - 0.static voidwriteVPNnumber(DataOutput out, long v)
-
-
-
Field Detail
-
UTF8
public static final Charset UTF8
-
UTF8_FAST
public static final String UTF8_FAST
- See Also:
- Constant Field Values
-
-
Method Detail
-
decodeUTF8
public static String decodeUTF8(ByteBuffer in, int length)
-
writeUTFv
public static void writeUTFv(String string, DataOutput out) throws IOException
Similar to writeUTF, but ok for strings > 32K bytes long and better for strings < 127 string utf-8 length must be ≤ Integer.MAX_VALUE - 1- Parameters:
string- the string to writeout- the output sink- Throws:
IOException- passthru
-
readUTFv
public static String readUTFv(DataInput in) throws IOException
- Throws:
IOException
-
lengthUTFv
public static long lengthUTFv(String string) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
writeShort
public static void writeShort(DataOutput out, int v) throws IOException
DataOutputStream writeShort with checking of argument- Parameters:
out- the output sinkv- the value to write- Throws:
IOException- passthru
-
writeByte
public static void writeByte(DataOutput out, int v) throws IOException
DataOutputStream writeByte with checking of argument- Parameters:
out- output sinkv- the value to write- Throws:
IOException- passthru
-
writeUnsignedByte
public static void writeUnsignedByte(DataOutput out, int v) throws IOException
Write lower 8 bits- Parameters:
out- output sinkv- the value to write- Throws:
IOException- passthru
-
writeVPNnumber
public static void writeVPNnumber(DataOutput out, int v) throws IOException
write a positive or negative number, optimized for fewer bytes near 0 sign put in low order bit, rest of number converted to positive and shifted left 1 max negative written as - 0.- Parameters:
out- output sinkv- the value to write- Throws:
IOException- passthru
-
writeVPNnumber
public static void writeVPNnumber(DataOutput out, long v) throws IOException
- Throws:
IOException
-
lengthVPNnumber
public static int lengthVPNnumber(int v)
-
lengthVPNnumber
public static int lengthVPNnumber(long v)
-
writeVnumber
public static void writeVnumber(DataOutput out, int v) throws IOException
Write a positive number with the fewest bytes possible up to 127 written as a byte high order bit on means get another byte Note: value treated as unsigned 32 bit int- Parameters:
out- output sinkv- the value to write- Throws:
IOException- passthru
-
lengthVnumber
public static int lengthVnumber(int v)
-
readVnumber
public static int readVnumber(DataInput in) throws IOException
- Throws:
IOException
-
writeVnumber
public static void writeVnumber(DataOutput out, long v) throws IOException
Write a positive long with the fewest bytes possible; up to 127 written as a byte, high order bit on means get another byte.- Parameters:
out- output sinkv- the value to write is never negative- Throws:
IOException- passthru
-
lengthVnumber
public static int lengthVnumber(long v)
-
readVlong
public static long readVlong(DataInput in) throws IOException
- Throws:
IOException
-
readRestOfVlong
public static long readRestOfVlong(DataInput in, int firstByte) throws IOException
- Throws:
IOException
-
writeByteArray
public static void writeByteArray(DataOutput out, byte[] v) throws IOException
- Throws:
IOException
-
readByteArray
public static byte[] readByteArray(DataInput in) throws IOException
- Throws:
IOException
-
writeIntArray
public static void writeIntArray(DataOutput out, int[] v) throws IOException
write array preceded by its length- Parameters:
out- output sinkv- the value to write- Throws:
IOException- passthru
-
readIntArray
public static int[] readIntArray(DataInput in) throws IOException
- Throws:
IOException
-
writeIntArrayDelta
public static void writeIntArrayDelta(DataOutput out, int[] v) throws IOException
Write delta encoded value, for increasing values- Parameters:
out- output sinkv- the value to write- Throws:
IOException- passthru
-
readIntArrayDelta
public static int[] readIntArrayDelta(DataInput in) throws IOException
- Throws:
IOException
-
writeLongArray
public static void writeLongArray(DataOutput out, long[] v) throws IOException
- Throws:
IOException
-
readLongArray
public static long[] readLongArray(DataInput in) throws IOException
- Throws:
IOException
-
writeLongArrayDelta
public static void writeLongArrayDelta(DataOutput out, long[] v) throws IOException
- Throws:
IOException
-
readLongArrayDelta
public static long[] readLongArrayDelta(DataInput in) throws IOException
- Throws:
IOException
-
readUnsignedByte
public static int readUnsignedByte(DataInput in) throws IOException
- Throws:
IOException
-
-