import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
/**
* <b><u>BitBuffer</u></b>
* byte order.
*
* @return The int value (signed) read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the long. This exception can be
* raised if the buffer tries to read out of bounds
*/
- public int getInt() throws CTFReaderException {
+ public int getInt() throws CTFException {
return getInt(BIT_INT, true);
}
* byte order.
*
* @return The long value (signed) read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the long. This exception can be
* raised if the buffer tries to read out of bounds
*/
- public long getLong() throws CTFReaderException {
+ public long getLong() throws CTFException {
return get(BIT_LONG, true);
}
* @param signed
* The sign extended flag
* @return The long value read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the data. If more than 64 bits at a
* time are read, or the buffer is read beyond its end, this
* exception will be raised.
*/
- public long get(int length, boolean signed) throws CTFReaderException {
+ public long get(int length, boolean signed) throws CTFException {
if (length > BIT_LONG) {
- throw new CTFReaderException("Cannot read a long longer than 64 bits. Rquested: " + length); //$NON-NLS-1$
+ throw new CTFException("Cannot read a long longer than 64 bits. Rquested: " + length); //$NON-NLS-1$
}
if (length > BIT_INT) {
final int highShift = length - BIT_INT;
* @param signed
* The sign extended flag
* @return The int value read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the data. When the buffer is read
* beyond its end, this exception will be raised.
*/
- private int getInt(int length, boolean signed) throws CTFReaderException {
+ private int getInt(int length, boolean signed) throws CTFException {
/* Nothing to read. */
if (length == 0) {
/* Validate that the buffer has enough bits. */
if (!canRead(length)) {
- throw new CTFReaderException("Cannot read the integer, " + //$NON-NLS-1$
+ throw new CTFException("Cannot read the integer, " + //$NON-NLS-1$
"the buffer does not have enough remaining space. " + //$NON-NLS-1$
"Requested:" + length); //$NON-NLS-1$
}
*
* @param value
* The int value to write
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred writing the data. If the buffer is written
* beyond its end, this exception will be raised.
*/
- public void putInt(int value) throws CTFReaderException {
+ public void putInt(int value) throws CTFException {
putInt(BIT_INT, value);
}
* The number of bits to write
* @param value
* The value to write
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred writing the data. If the buffer is written
* beyond its end, this exception will be raised.
*/
- public void putInt(int length, int value) throws CTFReaderException {
+ public void putInt(int length, int value) throws CTFException {
final long curPos = fPosition;
if (!canRead(length)) {
- throw new CTFReaderException("Cannot write to bitbuffer, " //$NON-NLS-1$
+ throw new CTFException("Cannot write to bitbuffer, " //$NON-NLS-1$
+ "insufficient space. Requested: " + length); //$NON-NLS-1$
}
if (length == 0) {
*
* @param newPosition
* The new position of the buffer.
- * @throws CTFReaderException
+ * @throws CTFException
* Thrown on out of bounds exceptions
*/
- public void position(long newPosition) throws CTFReaderException {
+ public void position(long newPosition) throws CTFException {
if (newPosition > fBitCapacity) {
- throw new CTFReaderException("Out of bounds exception on a position move, attempting to access position: " + newPosition); //$NON-NLS-1$
+ throw new CTFException("Out of bounds exception on a position move, attempting to access position: " + newPosition); //$NON-NLS-1$
}
fPosition = newPosition;
}
return fPosition;
}
- /**
- * Sets the byte buffer
- *
- * @param buf
- * the byte buffer
- */
- @Deprecated
- public void setByteBuffer(ByteBuffer buf) {
- /*
- * to avoid "The method setByteBuffer(ByteBuffer) from the type
- * BitBuffer can be declared as static"
- */
- long data = fPosition;
- fPosition = data;
- throw new UnsupportedOperationException("Bytebuffers are now final"); //$NON-NLS-1$
-
- }
-
/**
* Gets the byte buffer
*