Package org.apache.uima.util.impl
Class DataIO
- java.lang.Object
-
- org.apache.uima.util.impl.DataIO
-
public class DataIO extends java.lang.Object
Methods for working with Data during I/O
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.nio.charset.CharsetDecoder>
DECODER
private static int
MASK_LOW_7
private static long
MASK_LOW_7_LONG
private static int
SIGNED_INT_VALUE_0x80
static java.nio.charset.Charset
UTF8
-
Constructor Summary
Constructors Constructor Description DataIO()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
decodeUTF8(java.nio.ByteBuffer in, int length)
static long
lengthUTFv(java.lang.String string)
static int
lengthVnumber(int v)
static int
lengthVnumber(long v)
static int
lengthVPNnumber(int v)
static int
lengthVPNnumber(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 long
readRestOfVlong(java.io.DataInput in, int firstByte)
static int
readUnsignedByte(java.io.DataInput in)
static java.lang.String
readUTFv(java.io.DataInput in)
static long
readVlong(java.io.DataInput in)
static int
readVnumber(java.io.DataInput in)
static void
writeByte(java.io.DataOutput out, int v)
DataOutputStream writeByte with checking of argumentstatic void
writeByteArray(java.io.DataOutput out, byte[] v)
static void
writeIntArray(java.io.DataOutput out, int[] v)
write array preceded by its lengthstatic void
writeIntArrayDelta(java.io.DataOutput out, int[] v)
Write delta encoded value, for increasing valuesstatic void
writeLongArray(java.io.DataOutput out, long[] v)
static void
writeLongArrayDelta(java.io.DataOutput out, long[] v)
static void
writeShort(java.io.DataOutput out, int v)
DataOutputStream writeShort with checking of argumentstatic void
writeUnsignedByte(java.io.DataOutput out, int v)
Write lower 8 bitsstatic void
writeUTFv(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 void
writeVnumber(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 void
writeVnumber(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 void
writeVnumber1(java.io.DataOutput out, int v)
private static void
writeVnumber1(java.io.DataOutput out, long v)
static void
writeVPNnumber(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 void
writeVPNnumber(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.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:
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.IOException
DataOutputStream 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.IOException
DataOutputStream 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.IOException
Write 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.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:
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.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:
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.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:
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.IOException
write 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.IOException
Write 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
-
-