public class StandardBuffer extends java.lang.Object implements Buffer
| Modifier and Type | Field and Description |
|---|---|
protected int |
count |
protected boolean |
frozen |
protected java.lang.String |
header |
protected Item[] |
items |
| Constructor and Description |
|---|
StandardBuffer()
Constructs a new instance of StandardBuffer.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addItem(Item item)
Append a specified Item to the end of the item list in this Buffer,
which may lead to duplicate item names.
|
int |
addItem(java.lang.String itemName,
Buffer value)
Create and append a new Item to this buffer.
|
int |
addItem(java.lang.String itemName,
int value)
Create and append a new Item to this buffer.
|
int |
addItem(java.lang.String itemName,
java.lang.Object value)
Create and append a new Item to the end of the item list in this Buffer,
which may lead to duplicate item names.
|
int |
addItem(java.lang.String itemName,
java.lang.String value)
Create and append a new Item to this buffer.
|
void |
checkItem(Item item)
Check if the Item is of Expected class.
|
void |
clear()
Clear the contents of this buffer.
|
java.lang.Object |
clone()
Clone this Buffer.
|
int |
countItems()
Return the number of items collected in this Buffer.
|
int |
countItems(java.lang.String name)
Return the number of items with the specified name collected in this Buffer.
|
boolean |
equals(java.lang.Object obj)
Compares this buffer to another one.
|
Item |
findItem(java.lang.String itemName)
Find a named Item inthis Buffer.
|
void |
freeze()
Freezes this buffer.
|
Buffer |
getBuffer(int position)
Get the value of the item at the specified position.
|
Buffer |
getBuffer(java.lang.String itemName)
Get the value of the item with the specified name.
|
Buffer |
getBuffer(java.lang.String itemName,
Buffer defaultValue)
Get the value of the item with the specified name.
|
java.lang.String |
getHeader()
Return the header of this Buffer.
|
int |
getInt(int position)
Get the value of the item at the specified position.
|
int |
getInt(java.lang.String itemName)
Get the value of the item with the specified name.
|
int |
getInt(java.lang.String itemName,
int defaultValue)
Get the value of the item with the specified name.
|
Item |
getItem(int position)
Return the Item at the specified position, or null if the position
is invalid.
|
Item |
getItem(java.lang.String itemName)
Get the item with the specified name.
|
Item |
getItem(java.lang.String itemName,
Item defaultValue)
Get the item with the specified name.
|
int |
getItemPosition(java.lang.String itemName)
Return the position of the first occurrence of a named Item
or -1 if such Item does not exist.
|
java.lang.Object |
getObject(int position)
Get the value of the item at the specified position.
|
java.lang.Object |
getObject(java.lang.String itemName)
Get the value of the item with the specified name.
|
java.lang.Object |
getObject(java.lang.String itemName,
java.lang.Object defaultValue)
Get the value of the item with the specified name.
|
java.lang.String |
getString(int position)
Get the value of the item at the specified position.
|
java.lang.String |
getString(java.lang.String itemName)
Get the value of the item with the specified name.
|
java.lang.String |
getString(java.lang.String itemName,
java.lang.String defaultValue)
Get the value of the item with the specified name.
|
int |
hashCode()
Compute the hash code for this Buffer
|
int |
insertItem(Item item,
int position)
Insert a specified Item at the specified position (0,1,...) in
the item list.
|
boolean |
isFrozen()
Indicates if this buffer is frozen.
|
BufferIterator |
iterator()
Return an iterator over all items in this Buffer.
|
Buffer |
newInstance()
Return a new (empty) instance of the same class as this Buffer
|
Item |
newItem()
Return a new instance of Item
|
void |
removeItem(int position)
Remove the Item at a specified position (0,1,...) in this Buffer.
|
void |
removeItem(java.lang.String itemName)
Remove the named item from the item list in this Buffer.
|
void |
removeItems()
Remove all items from this Buffer.
|
void |
setHeader(java.lang.String header)
Set the header of this Buffer.
|
int |
setItem(java.lang.String itemName,
int value)
Mofify the first occurence of a named item, or create a new item,
if such item does not exist.
|
int |
setItem(java.lang.String itemName,
java.lang.String value)
Mofify the first occurence of a named item, or create a new item,
if such item does not exist.
|
java.lang.String |
toString()
Returns a string describing this buffer.
|
void |
unfreeze()
Un-freezes this buffer.
|
protected java.lang.String header
protected int count
protected Item[] items
protected boolean frozen
public StandardBuffer()
public void clear()
Bufferpublic void setHeader(java.lang.String header)
public java.lang.String getHeader()
public int countItems()
countItems in interface Bufferpublic int countItems(java.lang.String name)
countItems in interface Buffername - item namepublic BufferIterator iterator()
public int addItem(Item item)
public int addItem(java.lang.String itemName,
java.lang.Object value)
public int addItem(java.lang.String itemName,
Buffer value)
Bufferpublic int addItem(java.lang.String itemName,
java.lang.String value)
Bufferpublic int addItem(java.lang.String itemName,
int value)
Bufferpublic int insertItem(Item item, int position)
insertItem in interface Bufferitem - the item to insertposition - a zero-bassed indexpublic int setItem(java.lang.String itemName,
java.lang.String value)
public int setItem(java.lang.String itemName,
int value)
Bufferpublic int getItemPosition(java.lang.String itemName)
getItemPosition in interface BufferitemName - item namepublic Item getItem(int position)
public Item getItem(java.lang.String itemName) throws ItemNotFoundException
BuffergetItem in interface BufferitemName - item nameItemNotFoundException - if the specified item does not existpublic Item getItem(java.lang.String itemName, Item defaultValue)
Bufferpublic java.lang.String getString(int position)
Bufferpublic java.lang.String getString(java.lang.String itemName)
throws ItemNotFoundException
BuffergetString in interface BufferitemName - item nameItemNotFoundException - if the specified item does not existpublic java.lang.String getString(java.lang.String itemName,
java.lang.String defaultValue)
Bufferpublic int getInt(int position)
Bufferpublic int getInt(java.lang.String itemName)
throws ItemNotFoundException
BuffergetInt in interface BufferitemName - item nameItemNotFoundException - if the specified item does not existpublic int getInt(java.lang.String itemName,
int defaultValue)
Bufferpublic java.lang.Object getObject(int position)
Bufferpublic java.lang.Object getObject(java.lang.String itemName)
throws ItemNotFoundException
BuffergetObject in interface BufferitemName - item nameItemNotFoundException - if the specified item does not existpublic java.lang.Object getObject(java.lang.String itemName,
java.lang.Object defaultValue)
Bufferpublic Buffer getBuffer(int position)
Bufferpublic Buffer getBuffer(java.lang.String itemName) throws ItemNotFoundException
BuffergetBuffer in interface BufferitemName - item nameItemNotFoundException - if the specified item does not existpublic Buffer getBuffer(java.lang.String itemName, Buffer defaultValue)
Bufferpublic void removeItem(java.lang.String itemName)
removeItem in interface BufferitemName - the name of an itempublic void removeItem(int position)
removeItem in interface Bufferposition - zero-based index of an existing itempublic void removeItems()
removeItems in interface Bufferpublic Item findItem(java.lang.String itemName)
Bufferpublic Buffer newInstance()
BuffernewInstance in interface Bufferpublic boolean equals(java.lang.Object obj)
Bufferpublic java.lang.Object clone()
Bufferpublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
Bufferpublic Item newItem()
Bufferpublic void checkItem(Item item)
public boolean isFrozen()
public void freeze()
Buffer