first commit
This commit is contained in:
53
hrmsEjb/jxl/biff/IntegerHelper.java
Normal file
53
hrmsEjb/jxl/biff/IntegerHelper.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package jxl.biff;
|
||||
|
||||
public final class IntegerHelper {
|
||||
public static int getInt(byte b1, byte b2) {
|
||||
int i1 = b1 & 0xFF;
|
||||
int i2 = b2 & 0xFF;
|
||||
int val = i2 << 8 | i1;
|
||||
return val;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static byte[] getTwoBytes(int i) {
|
||||
byte[] bytes = new byte[2];
|
||||
bytes[0] = (byte)(i & 0xFF);
|
||||
bytes[1] = (byte)((i & 0xFF00) >> 8);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static void getTwoBytes(int i, byte[] target, int pos) {
|
||||
target[pos] = (byte)(i & 0xFF);
|
||||
target[pos + 1] = (byte)((i & 0xFF00) >> 8);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user