Converts excel byte representations into integers
| Method from jxl.biff.IntegerHelper Detail: |
public static byte[] getFourBytes(int i) {
byte[] bytes = new byte[4];
int i1 = i & 0xffff;
int i2 = (i & 0xffff0000) > > 16;
getTwoBytes(i1, bytes, 0);
getTwoBytes(i2, bytes, 2);
return bytes;
}
Gets a four byte array from an integer |
public static void getFourBytes(int i,
byte[] target,
int pos) {
byte[] bytes = getFourBytes(i);
target[pos] = bytes[0];
target[pos + 1] = bytes[1];
target[pos + 2] = bytes[2];
target[pos + 3] = bytes[3];
}
Converts an integer into four bytes, and places it in the array at the
specified position |
public static int getInt(byte b1,
byte b2) {
int i1 = b1 & 0xff;
int i2 = b2 & 0xff;
int val = i2 < < 8 | i1;
return val;
}
Gets an int from two bytes |
public static int getInt(byte b1,
byte b2,
byte b3,
byte b4) {
int i1 = getInt(b1, b2);
int i2 = getInt(b3, b4);
int val = i2 < < 16 | i1;
return val;
}
Gets an int from four bytes, doing all the necessary swapping |
public static short getShort(byte b1,
byte b2) {
short i1 = (short) (b1 & 0xff);
short i2 = (short) (b2 & 0xff);
short val = (short) (i2 < < 8 | i1);
return val;
}
Gets an short from two bytes |
public static byte[] getTwoBytes(int i) {
byte[] bytes = new byte[2];
bytes[0] = (byte) (i & 0xff);
bytes[1] = (byte) ((i & 0xff00) > > 8);
return bytes;
}
Gets a two byte array from an integer |
public static void getTwoBytes(int i,
byte[] target,
int pos) {
target[pos] = (byte) (i & 0xff);
target[pos + 1] = (byte) ((i & 0xff00) > > 8);
}
Converts an integer into two bytes, and places it in the array at the
specified position |