|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.labs.minion.util.buffer.StdBufferImpl
public abstract class StdBufferImpl
A abstract class that implements most of the
WriteableBuffer and ReadableBuffer interfaces
in terms of the two implemented interfaces' get and
put methods. These can be overidden in subclasses if the
performance is unacceptable.
WriteableBuffer,
ReadableBuffer| Field Summary | |
|---|---|
protected static int[] |
masks
Bitmasks to add a single bit to a byte. |
protected static long[] |
maxBEValues
The number of bytes that are required for encoding a number given our 7 bit encoding strategy. |
protected static long[] |
maxValues
The maximum values that can be encoded using a given number of bytes. |
protected static int[] |
nBits
The number of 1 bits in a byte, as a lookup table. |
| Constructor Summary | |
|---|---|
StdBufferImpl()
|
|
| Method Summary | |
|---|---|
WriteableBuffer |
append(ReadableBuffer b)
Appends a readable buffer onto this buffer. |
WriteableBuffer |
append(ReadableBuffer b,
int n)
Appends a given number of bytes from a readable buffer onto this buffer. |
int |
byteDecode()
Decodes an integer stored using the minimal number of bytes. |
int |
byteDecode(int nBytes)
Decodes a postive integer that was coded using a specific number of bytes. |
int |
byteDecode(int pos,
int nBytes)
Decodes a postive integer that was coded using a specific number of bytes from a specific position in the buffer. |
long |
byteDecodeLong()
Decodes a long stored using the 7 bit encoding. |
long |
byteDecodeLong(int nBytes)
Decodes a postive long that was coded using a specific number of bytes. |
long |
byteDecodeLong(int pos,
int nBytes)
Decodes a postive long that was coded using a specific number of bytes from a given position. |
WriteableBuffer |
byteEncode(int pos,
long n,
int nBytes)
Encodes a positive long directly, using a given number of bytes, starting at the given position in the units. |
int |
byteEncode(long n)
Encodes an integer in a byte-aligned fashion, using the minimal number of bytes. |
WriteableBuffer |
byteEncode(long n,
int nBytes)
Encodes a positive long onto a writeable in a given number of bytes. |
static int |
bytesRequired(long n)
Gets the number of bytes required to directly encode a given number. |
static java.lang.String |
byteToBinaryString(byte n)
Build a string representation of a byte with the bits in the right order. |
WriteableBuffer |
clear()
Clears the buffer. |
int |
countBits()
Counts the number of bits that are set in a buffer. |
protected int |
countBits(int start,
int end)
|
float |
decodeFloat()
Decode a float stored in 4 bytes. |
WriteableBuffer |
encode(java.lang.CharSequence s)
Encodes a character sequence onto the buffer. |
WriteableBuffer |
encode(float f)
Encodes a floating point value in 4 bytes. |
java.lang.String |
getString()
Gets a string from this buffer. |
WriteableBuffer |
set(int bitIndex)
Sets the given bit to 1 in the given buffer. |
protected static int |
sizeUTF8(java.lang.CharSequence s)
Determines the size of the UTF-8 encoding of a character sequence. |
int |
skipByteEncoded()
Skips an integer encoded using our 7 bit encoding without actually decoding it. |
boolean |
test(int bitIndex)
Tests whether a given bit is true or false. |
java.lang.String |
toString()
Gets a string representation of the bytes in this buffer. |
java.lang.String |
toString(int mode)
Print the bits in the buffer in the order in which they actually occur. |
java.lang.String |
toString(int start,
int end)
Print the bits in the buffer in the order in which they actually occur. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.sun.labs.minion.util.buffer.WriteableBuffer |
|---|
capacity, getReadableBuffer, or, put, put, write, write, write, write, xor |
| Methods inherited from interface com.sun.labs.minion.util.buffer.ReadableBuffer |
|---|
duplicate, get, get, slice |
| Methods inherited from interface com.sun.labs.minion.util.buffer.Buffer |
|---|
limit, limit, position, position, remaining |
| Field Detail |
|---|
protected static long[] maxValues
protected static long[] maxBEValues
protected static int[] nBits
protected static int[] masks
| Constructor Detail |
|---|
public StdBufferImpl()
| Method Detail |
|---|
public static int bytesRequired(long n)
n - The number that we want to encode.
public WriteableBuffer byteEncode(long n,
int nBytes)
byteEncode in interface WriteableBuffern - The number to encode.nBytes - The number of bytes to use in the encoding.
public WriteableBuffer byteEncode(int pos,
long n,
int nBytes)
byteEncode in interface WriteableBufferpos - The position to start encoding.n - The number to encode.nBytes - The number of bytes to use in the encoding.
public int byteEncode(long n)
byteEncode in interface WriteableBuffern - The number to encode.
public WriteableBuffer encode(float f)
encode in interface WriteableBufferf - the floating point number to encode
protected static int sizeUTF8(java.lang.CharSequence s)
s - The sequence that we wish to encode.
public WriteableBuffer append(ReadableBuffer b)
append in interface WriteableBufferb - The buffer that we wish to append onto this buffer.
public WriteableBuffer append(ReadableBuffer b,
int n)
append in interface WriteableBufferb - The buffer that we wish to append onto this buffer.n - The number of bytes from the given buffer to append onto this buffer.
public WriteableBuffer encode(java.lang.CharSequence s)
byteEncode
method. Then, the characters in the sequence are encoded using a
UTF-8 encoding.
encode in interface WriteableBuffers - The sequence that we wish to encode.
public WriteableBuffer set(int bitIndex)
set in interface WriteableBufferbitIndex - the index of the bit to set to 1.
public WriteableBuffer clear()
clear in interface WriteableBufferpublic int byteDecode(int nBytes)
byteDecode in interface ReadableBuffernBytes - The number of bytes to use.
public int byteDecode(int pos,
int nBytes)
byteDecode in interface ReadableBufferpos - The position to decode from.nBytes - The number of bytes to use.
public long byteDecodeLong(int nBytes)
byteDecodeLong in interface ReadableBuffernBytes - The number of bytes to use.
public long byteDecodeLong(int pos,
int nBytes)
byteDecodeLong in interface ReadableBufferpos - The position to decode from.nBytes - The number of bytes to use.
public int byteDecode()
byteDecode in interface ReadableBufferbyteEncode(long, int)public long byteDecodeLong()
byteDecodeLong in interface ReadableBufferbyteEncode(long, int)public float decodeFloat()
decodeFloat in interface ReadableBufferpublic int skipByteEncoded()
skipByteEncoded in interface ReadableBufferWriteableBuffer.byteEncode(long, int)public boolean test(int bitIndex)
test in interface ReadableBufferbitIndex - the index of the bit to test.
public int countBits()
countBits in interface ReadableBuffer
protected int countBits(int start,
int end)
public java.lang.String getString()
getString in interface ReadableBufferWriteableBuffer.encode(CharSequence)public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(int mode)
mode - The type of print out required.
public java.lang.String toString(int start,
int end)
start - The starting position in the buffer from which to
display the bytes.end - The (exclusive) ending position in the buffer.
public static java.lang.String byteToBinaryString(byte n)
n - The number to represent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||