// ------------------------------------------------------------------------
private ByteBuffer buf;
- private int pos;
+ private long pos;
private ByteOrder byteOrder;
// ------------------------------------------------------------------------
case BitBuffer.BIT_CHAR:
// Byte
if (signed) {
- val = this.buf.get(this.pos / 8);
+ val = this.buf.get((int) (this.pos / 8));
} else {
- val = (this.buf.get(this.pos / 8)) & 0xff;
+ val = (this.buf.get((int) (this.pos / 8))) & 0xff;
}
gotIt = true;
break;
case BitBuffer.BIT_SHORT:
// Word
if (signed) {
- val = this.buf.getShort(this.pos / 8);
+ val = this.buf.getShort((int) (this.pos / 8));
} else {
- short a = this.buf.getShort(this.pos / 8);
+ short a = this.buf.getShort((int) (this.pos / 8));
val = a & 0xffff;
}
gotIt = true;
case BitBuffer.BIT_INT:
// Double word
- val = this.buf.getInt(this.pos / 8);
+ val = this.buf.getInt((int) (this.pos / 8));
gotIt = true;
break;
return val;
}
- private int getIntBE(int index, int length, boolean signed) {
+ private int getIntBE(long index, int length, boolean signed) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask, cache;
int value = 0;
value |= cmask;
return value;
}
- cshift = index % BIT_CHAR;
+ cshift = (int) (index % BIT_CHAR);
if (cshift > 0) {
mask = ~((~0) << (BIT_CHAR - cshift));
cmask = cache & mask;
value <<= BIT_CHAR;
value |= this.buf.get(currByte) & 0xFF;
}
- lshift = end % BIT_CHAR;
+ lshift = (int) (end % BIT_CHAR);
if (lshift > 0) {
mask = ~((~0) << lshift);
cmask = this.buf.get(currByte) & 0xFF;
return value;
}
- private int getIntLE(int index, int length, boolean signed) {
+ private int getIntLE(long index, int length, boolean signed) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask, cache, mod;
int value = 0;
currByte = endByte - 1;
cache = buf.get(currByte) & 0xFF;
- mod = end % BIT_CHAR;
+ mod = (int) (end % BIT_CHAR);
lshift = (mod > 0) ? mod : BIT_CHAR;
boolean isNeg = (cache & (1 << (lshift - 1))) != 0;
if (signed && isNeg) {
value |= cmask;
return value;
}
- cshift = end % BIT_CHAR;
+ cshift = (int) (end % BIT_CHAR);
if (cshift > 0) {
mask = ~((~0) << cshift);
cmask = cache & mask;
value <<= BIT_CHAR;
value |= buf.get(currByte) & 0xFF;
}
- lshift = index % BIT_CHAR;
+ lshift = (int) (index % BIT_CHAR);
if (lshift > 0) {
mask = ~((~0) << (BIT_CHAR - lshift));
cmask = buf.get(currByte) & 0xFF;
* The value to write
*/
public void putInt(int length, int value) {
- final int curPos = this.pos;
+ final long curPos = this.pos;
if (!canRead(length)) {
throw new BufferOverflowException();
this.pos += length;
}
- private void putIntBE(int index, int length, int value) {
+ private void putIntBE(long index, int length, int value) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask;
int correctedValue = value;
/* sub byte */
if (startByte == (endByte - 1)) {
- lshift = (BIT_CHAR - (end % BIT_CHAR)) % BIT_CHAR;
+ lshift = (int) ((BIT_CHAR - (end % BIT_CHAR)) % BIT_CHAR);
mask = ~((~0) << lshift);
if ((index % BIT_CHAR) > 0) {
mask |= (~(0)) << (BIT_CHAR - (index % BIT_CHAR));
/* head byte contains MSB */
currByte = endByte - 1;
- cshift = end % BIT_CHAR;
+ cshift = (int) (end % BIT_CHAR);
if (cshift > 0) {
lshift = BIT_CHAR - cshift;
mask = ~((~0) << lshift);
}
}
- private void putIntLE(int index, int length, int value) {
+ private void putIntLE(long index, int length, int value) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask;
int correctedValue = value;
/* sub byte */
if (startByte == (endByte - 1)) {
- lshift = index % BIT_CHAR;
+ lshift = (int) (index % BIT_CHAR);
mask = ~((~0) << lshift);
if ((end % BIT_CHAR) > 0) {
mask |= (~(0)) << (end % BIT_CHAR);
/* head byte */
currByte = startByte;
- cshift = index % BIT_CHAR;
+ cshift = (int) (index % BIT_CHAR);
if (cshift > 0) {
mask = ~((~0) << cshift);
cmask = correctedValue << cshift;
return false;
}
- if ((this.pos + length) > (this.buf.capacity() * BIT_CHAR)) {
+ if ((this.pos + length) > (((long) this.buf.capacity()) * BIT_CHAR)) {
return false;
}
return true;
* @param newPosition
* The new position of the buffer.
*/
- public void position(int newPosition) {
+ public void position(long newPosition) {
this.pos = newPosition;
}
*
* @return order The position of the buffer.
*/
- public int position() {
+ public long position() {
return this.pos;
}
/**
* Offset of the data in the packet, in bits
*/
- private int dataOffsetBits = 0;
+ private long dataOffsetBits = 0;
/**
* Packet size, in bits
*/
- private int packetSizeBits = 0;
+ private long packetSizeBits = 0;
/**
* Content size, in bits
*/
- private int contentSizeBits = 0;
+ private long contentSizeBits = 0;
/**
* Begin timestamp
/**
* @return the dataOffsetBits
*/
- public int getDataOffsetBits() {
+ public long getDataOffsetBits() {
return dataOffsetBits;
}
* @param dataOffsetBits
* the dataOffsetBits to set
*/
- public void setDataOffsetBits(int dataOffsetBits) {
+ public void setDataOffsetBits(long dataOffsetBits) {
this.dataOffsetBits = dataOffsetBits;
}
/**
* @return the packetSizeBits
*/
- public int getPacketSizeBits() {
+ public long getPacketSizeBits() {
return packetSizeBits;
}
* @param packetSizeBits
* the packetSizeBits to set
*/
- public void setPacketSizeBits(int packetSizeBits) {
+ public void setPacketSizeBits(long packetSizeBits) {
this.packetSizeBits = packetSizeBits;
}
/**
* @return the contentSizeBits
*/
- public int getContentSizeBits() {
+ public long getContentSizeBits() {
return contentSizeBits;
}
* @param contentSizeBits
* the contentSizeBits to set
*/
- public void setContentSizeBits(int contentSizeBits) {
+ public void setContentSizeBits(long contentSizeBits) {
this.contentSizeBits = contentSizeBits;
}