|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.msi.comms.bytebuffer.FixedBuffer
FixedBuffer provides a model of a fixed length
byte buffer as is commonly used in communications between
various systems. The buffers modeled here have:
Given a buffer layout:
msgid cmd parm 1 parm 2
[-----][---][--------][--------]
FixedBuffer buf = new FixedBuffer(24);
buf.addCell("Message ID", 5);
buf.addCell("Command", 3);
buf.addCell("Parameter 1", 8);
buf.addCell("Parameter 2", 8);
| Field Summary | |
protected byte[] |
buffer
|
private java.util.ArrayList |
cells
|
private int |
length
|
| Constructor Summary | |
FixedBuffer(int length)
Creates a new FixedBuffer instance. |
|
| Method Summary | |
int |
addCell(java.lang.String name,
int length)
addCell add a cell to the end of the
existing cells defining the buffer format. |
void |
clearBuffer(byte b)
clearBuffer set all bytes in the
buffer to the given value. |
byte[] |
getBytes()
getBytes return a copy of the
buffer bytes. |
byte[] |
getCell(int index)
getCell retrieve the buffer contents specified
by cell index. |
double |
getCellDouble(int index)
getCellDouble retrieve the buffer contents specified
by cell index. |
int |
getCellInt(int index)
getCellInt retrieve the buffer contents specified
by cell index. |
java.util.ArrayList |
getCells()
Get the value of cells. |
java.lang.String |
getCellText(int index)
getCellText retrieve the buffer contents specified
by cell index. |
java.lang.String |
getCellTextTrim(int index)
getCellTextTrim retrieve the buffer contents specified
by cell index. |
int |
getLength()
Get the value of length. |
private int |
nextOffset()
nextOffset calculate the index of the next
available offset into the buffer. |
void |
setBuffer(byte[] v)
setBuffer copy as much of the
supplied data as possible into the buffer. |
void |
setCell(int index,
byte[] value)
setCell copy the supplied bytes into the fixed
buffer at the location defined by the cell at the supplied
index. |
void |
setCells(java.util.ArrayList v)
Set the value of cells. |
void |
setLength(int v)
Set the value of length. |
java.lang.String |
toString()
toString presentation of class state. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private int length
protected byte[] buffer
private java.util.ArrayList cells
| Constructor Detail |
public FixedBuffer(int length)
FixedBuffer instance.
length - an int of the fixed buffer in bytes.| Method Detail |
public void setBuffer(byte[] v)
setBuffer copy as much of the
supplied data as possible into the buffer.
v - a byte[] valuepublic void clearBuffer(byte b)
clearBuffer set all bytes in the
buffer to the given value.
b - a byte valuepublic byte[] getBytes()
getBytes return a copy of the
buffer bytes.
byte[] value
public int addCell(java.lang.String name,
int length)
throws java.lang.Exception
addCell add a cell to the end of the
existing cells defining the buffer format.
name - a String name for the cell.length - an int length in bytes for the cell.
int representing the index of the new cell.
java.lang.Exception
public void setCell(int index,
byte[] value)
throws java.lang.Exception
setCell copy the supplied bytes into the fixed
buffer at the location defined by the cell at the supplied
index.
index - an int valuevalue - a byte[] value
java.lang.Exception - if an error occurs
public byte[] getCell(int index)
throws java.lang.Exception
getCell retrieve the buffer contents specified
by cell index.
index - an int value
byte[] value
java.lang.Exception - if an error occurs
public java.lang.String getCellText(int index)
throws java.lang.Exception
getCellText retrieve the buffer contents specified
by cell index.
index - an int value
java.lang.Exception - if an error occurs
public java.lang.String getCellTextTrim(int index)
throws java.lang.Exception
getCellTextTrim retrieve the buffer contents specified
by cell index.
index - an int value
java.lang.Exception - if an error occurs
public int getCellInt(int index)
throws java.lang.Exception
getCellInt retrieve the buffer contents specified
by cell index.
index - an int value
java.lang.Exception - if an error occurs
public double getCellDouble(int index)
throws java.lang.Exception
getCellDouble retrieve the buffer contents specified
by cell index.
index - an int value
java.lang.Exception - if an error occurspublic java.lang.String toString()
toString presentation of class state.
toString in class java.lang.ObjectString valueprivate int nextOffset()
nextOffset calculate the index of the next
available offset into the buffer.
int index of the next available byte.public int getLength()
public void setLength(int v)
v - Value to assign to length.public java.util.ArrayList getCells()
public void setCells(java.util.ArrayList v)
v - Value to assign to cells.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||