|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectloci.formats.DataTools
public final class DataTools
A utility class with convenience methods for reading, writing and decoding words.
Field Summary | |
---|---|
static int |
COBOL
|
static long |
COBOL_EPOCH
|
static int |
UNIX
Timestamp formats. |
static long |
UNIX_EPOCH
Milliseconds until UNIX epoch. |
Method Summary | |
---|---|
static int |
bytesToInt(byte[] bytes,
boolean little)
Translates up to the first 4 bytes of a byte array to an int. |
static int |
bytesToInt(byte[] bytes,
int off,
boolean little)
Translates up to the first 4 bytes of a byte array beyond the given offset to an int. |
static int |
bytesToInt(byte[] bytes,
int off,
int len,
boolean little)
Translates up to the first len bytes of a byte array beyond the given offset to an int. |
static int |
bytesToInt(short[] bytes,
boolean little)
Translates up to the first 4 bytes of a byte array to an int. |
static int |
bytesToInt(short[] bytes,
int off,
boolean little)
Translates up to the first 4 bytes of a byte array beyond the given offset to an int. |
static int |
bytesToInt(short[] bytes,
int off,
int len,
boolean little)
Translates up to the first len bytes of a byte array beyond the given offset to an int. |
static long |
bytesToLong(byte[] bytes,
boolean little)
Translates up to the first 8 bytes of a byte array to a long. |
static long |
bytesToLong(byte[] bytes,
int off,
boolean little)
Translates up to the first 8 bytes of a byte array beyond the given offset to a long. |
static long |
bytesToLong(byte[] bytes,
int off,
int len,
boolean little)
Translates up to the first len bytes of a byte array beyond the given offset to a long. |
static long |
bytesToLong(short[] bytes,
boolean little)
Translates up to the first 8 bytes of a byte array to a long. |
static long |
bytesToLong(short[] bytes,
int off,
boolean little)
Translates up to the first 8 bytes of a byte array beyond the given offset to a long. |
static long |
bytesToLong(short[] bytes,
int off,
int len,
boolean little)
Translates up to the first len bytes of a byte array beyond the given offset to a long. |
static short |
bytesToShort(byte[] bytes,
boolean little)
Translates up to the first 2 bytes of a byte array to a short. |
static short |
bytesToShort(byte[] bytes,
int off,
boolean little)
Translates up to the first 2 bytes of a byte array beyond the given offset to a short. |
static short |
bytesToShort(byte[] bytes,
int off,
int len,
boolean little)
Translates up to the first len bytes of a byte array beyond the given offset to a short. |
static short |
bytesToShort(short[] bytes,
boolean little)
Translates up to the first 2 bytes of a byte array to a short. |
static short |
bytesToShort(short[] bytes,
int off,
boolean little)
Translates up to the first 2 bytes of a byte array byond the given offset to a short. |
static short |
bytesToShort(short[] bytes,
int off,
int len,
boolean little)
Translates up to the first len bytes of a byte array byond the given offset to a short. |
static String |
convertDate(long stamp,
int format)
Converts the given timestamp into an ISO 8061 date. |
static Object |
makeDataArray(byte[] b,
int bpp,
boolean fp,
boolean little)
Convert a byte array to the appropriate primitive type array. |
static float[] |
normalizeFloats(float[] data)
Normalize the given float array so that the minimum value maps to 0.0 and the maximum value maps to 1.0. |
static short |
read2SignedBytes(DataInput in,
boolean little)
Reads 2 signed bytes [-32768, 32767]. |
static int |
read2UnsignedBytes(DataInput in,
boolean little)
Reads 2 unsigned bytes [0, 65535]. |
static int |
read4SignedBytes(DataInput in,
boolean little)
Reads 4 signed bytes [-2147483648, 2147483647]. |
static long |
read4UnsignedBytes(DataInput in,
boolean little)
Reads 4 unsigned bytes [0, 4294967296]. |
static long |
read8SignedBytes(DataInput in,
boolean little)
Reads 8 signed bytes [-9223372036854775808, 9223372036854775807]. |
static double |
readDouble(DataInput in,
boolean little)
Reads 8 bytes in double precision IEEE format. |
static float |
readFloat(DataInput in,
boolean little)
Reads 4 bytes in single precision IEEE format. |
static byte |
readSignedByte(DataInput in)
Reads 1 signed byte [-128, 127]. |
static short |
readUnsignedByte(DataInput in)
Reads 1 unsigned byte [0, 255]. |
static boolean |
samePrefix(String s1,
String s2)
Check if two filenames have the same prefix. |
static String |
stripString(String toStrip)
Remove null bytes from a string. |
static char |
swap(char x)
|
static int |
swap(int x)
|
static long |
swap(long x)
|
static short |
swap(short x)
|
static void |
writeInt(DataOutput out,
int v,
boolean little)
Writes an integer to the given data output destination. |
static void |
writeShort(DataOutput out,
int v,
boolean little)
Writes a short to the given data output destination. |
static void |
writeString(DataOutput out,
String s)
Writes a string to the given data output destination. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int UNIX
public static final int COBOL
public static final long UNIX_EPOCH
public static final long COBOL_EPOCH
Method Detail |
---|
public static byte readSignedByte(DataInput in) throws IOException
IOException
public static short readUnsignedByte(DataInput in) throws IOException
IOException
public static short read2SignedBytes(DataInput in, boolean little) throws IOException
IOException
public static int read2UnsignedBytes(DataInput in, boolean little) throws IOException
IOException
public static int read4SignedBytes(DataInput in, boolean little) throws IOException
IOException
public static long read4UnsignedBytes(DataInput in, boolean little) throws IOException
IOException
public static long read8SignedBytes(DataInput in, boolean little) throws IOException
IOException
public static float readFloat(DataInput in, boolean little) throws IOException
IOException
public static double readDouble(DataInput in, boolean little) throws IOException
IOException
public static void writeString(DataOutput out, String s) throws IOException
IOException
public static void writeInt(DataOutput out, int v, boolean little) throws IOException
IOException
public static void writeShort(DataOutput out, int v, boolean little) throws IOException
IOException
public static short bytesToShort(byte[] bytes, int off, int len, boolean little)
public static short bytesToShort(byte[] bytes, int off, boolean little)
public static short bytesToShort(byte[] bytes, boolean little)
public static short bytesToShort(short[] bytes, int off, int len, boolean little)
public static short bytesToShort(short[] bytes, int off, boolean little)
public static short bytesToShort(short[] bytes, boolean little)
public static int bytesToInt(byte[] bytes, int off, int len, boolean little)
public static int bytesToInt(byte[] bytes, int off, boolean little)
public static int bytesToInt(byte[] bytes, boolean little)
public static int bytesToInt(short[] bytes, int off, int len, boolean little)
public static int bytesToInt(short[] bytes, int off, boolean little)
public static int bytesToInt(short[] bytes, boolean little)
public static long bytesToLong(byte[] bytes, int off, int len, boolean little)
public static long bytesToLong(byte[] bytes, int off, boolean little)
public static long bytesToLong(byte[] bytes, boolean little)
public static long bytesToLong(short[] bytes, int off, int len, boolean little)
public static long bytesToLong(short[] bytes, int off, boolean little)
public static long bytesToLong(short[] bytes, boolean little)
public static Object makeDataArray(byte[] b, int bpp, boolean fp, boolean little)
b
- Byte array to convert.bpp
- Denotes the number of bytes in the returned primitive type
(e.g. if bpp == 2, we should return an array of type short).fp
- If set and bpp == 4 or bpp == 8, then return floats or doubles.little
- Whether byte array is in little-endian order.public static short swap(short x)
public static char swap(char x)
public static int swap(int x)
public static long swap(long x)
public static String stripString(String toStrip)
public static boolean samePrefix(String s1, String s2)
public static float[] normalizeFloats(float[] data)
public static String convertDate(long stamp, int format)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |