Package org.apache.uima.util.impl
Class DataIO
- java.lang.Object
-
- org.apache.uima.util.impl.DataIO
-
public class DataIO extends java.lang.ObjectMethods for working with Data during I/O
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.nio.charset.CharsetDecoder>DECODERprivate static intMASK_LOW_7private static longMASK_LOW_7_LONGprivate static intSIGNED_INT_VALUE_0x80static java.nio.charset.CharsetUTF8
-
Constructor Summary
Constructors Constructor Description DataIO()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdecodeUTF8(java.nio.ByteBuffer in, int length)static longlengthUTFv(java.lang.String string)static intlengthVnumber(int v)static intlengthVnumber(long v)static intlengthVPNnumber(int v)static intlengthVPNnumber(long v)static byte[]readByteArray(java.io.DataInput in)static int[]readIntArray(java.io.DataInput in)static int[]readIntArrayDelta(java.io.DataInput in)static long[]readLongArray(java.io.DataInput in)static long[]readLongArrayDelta(java.io.DataInput in)static longreadRestOfVlong(java.io.DataInput in, int firstByte)static intreadUnsignedByte(java.io.DataInput in)static java.lang.StringreadUTFv(java.io.DataInput in)static longreadVlong(java.io.DataInput in)static intreadVnumber(java.io.DataInput in)static voidwriteByte(java.io.DataOutput out, int v)DataOutputStream writeByte with checking of argumentstatic voidwriteByteArray(java.io.DataOutput out, byte[] v)static voidwriteIntArray(java.io.DataOutput out, int[] v)write array preceded by its lengthstatic voidwriteIntArrayDelta(java.io.DataOutput out, int[] v)Write delta encoded value, for increasing valuesstatic voidwriteLongArray(java.io.DataOutput out, long[] v)static voidwriteLongArrayDelta(java.io.DataOutput out, long[] v)static voidwriteShort(java.io.DataOutput out, int v)DataOutputStream writeShort with checking of argumentstatic voidwriteUnsignedByte(java.io.DataOutput out, int v)Write lower 8 bitsstatic voidwriteUTFv(java.lang.String string, java.io.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(java.io.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(java.io.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.private static voidwriteVnumber1(java.io.DataOutput out, int v)private static voidwriteVnumber1(java.io.DataOutput out, long v)static voidwriteVPNnumber(java.io.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(java.io.DataOutput out, long v)
-
-
-
Field Detail
-
UTF8
public static final java.nio.charset.Charset UTF8
-
SIGNED_INT_VALUE_0x80
private static final int SIGNED_INT_VALUE_0x80
- See Also:
- Constant Field Values
-
MASK_LOW_7
private static final int MASK_LOW_7
- See Also:
- Constant Field Values
-
MASK_LOW_7_LONG
private static final long MASK_LOW_7_LONG
- See Also:
- Constant Field Values
-
DECODER
private static java.lang.ThreadLocal<java.nio.charset.CharsetDecoder> DECODER
-
-
Method Detail
-
decodeUTF8
public static java.lang.String decodeUTF8(java.nio.ByteBuffer in, int length)
-
writeUTFv
public static void writeUTFv(java.lang.String string, java.io.DataOutput out) throws java.io.IOExceptionSimilar 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:
java.io.IOException- passthru
-
readUTFv
public static java.lang.String readUTFv(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
lengthUTFv
public static long lengthUTFv(java.lang.String string) throws java.io.UnsupportedEncodingException- Throws:
java.io.UnsupportedEncodingException
-
writeShort
public static void writeShort(java.io.DataOutput out, int v) throws java.io.IOExceptionDataOutputStream writeShort with checking of argument- Parameters:
out- the output sinkv- the value to write- Throws:
java.io.IOException- passthru
-
writeByte
public static void writeByte(java.io.DataOutput out, int v) throws java.io.IOExceptionDataOutputStream writeByte with checking of argument- Parameters:
out- output sinkv- the value to write- Throws:
java.io.IOException- passthru
-
writeUnsignedByte
public static void writeUnsignedByte(java.io.DataOutput out, int v) throws java.io.IOExceptionWrite lower 8 bits- Parameters:
out- output sinkv- the value to write- Throws:
java.io.IOException- passthru
-
writeVPNnumber
public static void writeVPNnumber(java.io.DataOutput out, int v) throws java.io.IOExceptionwrite 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:
java.io.IOException- passthru
-
writeVPNnumber
public static void writeVPNnumber(java.io.DataOutput out, long v) throws java.io.IOException- Throws:
java.io.IOException
-
lengthVPNnumber
public static int lengthVPNnumber(int v)
-
lengthVPNnumber
public static int lengthVPNnumber(long v)
-
writeVnumber
public static void writeVnumber(java.io.DataOutput out, int v) throws java.io.IOExceptionWrite 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:
java.io.IOException- passthru
-
writeVnumber1
private static void writeVnumber1(java.io.DataOutput out, int v) throws java.io.IOException- Throws:
java.io.IOException
-
lengthVnumber
public static int lengthVnumber(int v)
-
readVnumber
public static int readVnumber(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
writeVnumber
public static void writeVnumber(java.io.DataOutput out, long v) throws java.io.IOExceptionWrite 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:
java.io.IOException- passthru
-
writeVnumber1
private static void writeVnumber1(java.io.DataOutput out, long v) throws java.io.IOException- Throws:
java.io.IOException
-
lengthVnumber
public static int lengthVnumber(long v)
-
readVlong
public static long readVlong(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
readRestOfVlong
public static long readRestOfVlong(java.io.DataInput in, int firstByte) throws java.io.IOException- Throws:
java.io.IOException
-
writeByteArray
public static void writeByteArray(java.io.DataOutput out, byte[] v) throws java.io.IOException- Throws:
java.io.IOException
-
readByteArray
public static byte[] readByteArray(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
writeIntArray
public static void writeIntArray(java.io.DataOutput out, int[] v) throws java.io.IOExceptionwrite array preceded by its length- Parameters:
out- output sinkv- the value to write- Throws:
java.io.IOException- passthru
-
readIntArray
public static int[] readIntArray(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
writeIntArrayDelta
public static void writeIntArrayDelta(java.io.DataOutput out, int[] v) throws java.io.IOExceptionWrite delta encoded value, for increasing values- Parameters:
out- output sinkv- the value to write- Throws:
java.io.IOException- passthru
-
readIntArrayDelta
public static int[] readIntArrayDelta(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
writeLongArray
public static void writeLongArray(java.io.DataOutput out, long[] v) throws java.io.IOException- Throws:
java.io.IOException
-
readLongArray
public static long[] readLongArray(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
writeLongArrayDelta
public static void writeLongArrayDelta(java.io.DataOutput out, long[] v) throws java.io.IOException- Throws:
java.io.IOException
-
readLongArrayDelta
public static long[] readLongArrayDelta(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
readUnsignedByte
public static int readUnsignedByte(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
-