public class TagArray
extends Object
Modifier and Type | Field and Description |
---|---|
private int |
BLOCK_SIZE |
private byte[][] |
blocks |
private byte[] |
curBlock |
private int |
curBlockUsed |
private short |
nBlocks |
private int |
nTags |
private int |
nTypes |
private short[] |
tagBlock |
private short[] |
tagLength |
private int[] |
tagOffset |
private short[] |
tagSubType |
private byte[] |
tagType |
static Tester |
tester
Basic regression test
|
private Hashtable |
typeTable |
Constructor and Description |
---|
TagArray() |
Modifier and Type | Method and Description |
---|---|
int |
add(String str,
int type)
Add a tag to the array
|
int |
add(String str,
int type,
int subType)
Add a tag to the array
|
private int |
allocateID()
Allocate a new string identifier, expanding the arrays if necessary.
|
long |
byteSize()
Calculate the size in bytes of the major structures of the tag array.
|
private void |
ensureCapacity(int nBytes)
Checks if the current block has space for the given number of bytes.
|
int |
findType(String t)
Allocates a number for the given type string.
|
TagChars |
getChars(int tag)
Get the characters that make up a given tag.
|
TagChars |
getChars(int tag,
TagChars chars)
Get the characters that make up a given tag, with no object allocation
at all.
|
String |
getString(int tag)
Get the string value of the given tag
|
short |
getSubType(int tag)
Get the sub-type associated with a given tag (zero if none)
|
int |
getType(int tag)
Get the type associated with a given tag.
|
private void |
newBlock()
Allocates a new block, and sets
curBlock to point at it. |
int |
next(int tag)
Retrieve the next tag in order, if its type is the same as the given one,
or -1 if there is no such tag.
|
int |
prev(int tag)
Retrieve the previous tag in order, if its type is the same as the given one,
or -1 if there is no such tag.
|
int |
size()
Retrieve a count of how many tags have been added.
|
private int BLOCK_SIZE
private byte[][] blocks
private short nBlocks
private byte[] curBlock
private int curBlockUsed
private byte[] tagType
private short[] tagSubType
private short[] tagBlock
private int[] tagOffset
private short[] tagLength
private int nTags
private Hashtable typeTable
private int nTypes
public static final Tester tester
public int findType(String t)
t
- The type to findpublic final int add(String str, int type)
str
- The string to addtype
- The type ID of the new tag (from findType(String)
)public int add(String str, int type, int subType)
str
- The string to addtype
- The type ID of the new tag (from findType(String)
)subType
- The sub-type of the new tag (or 0 for none)public int size()
public String getString(int tag)
public final TagChars getChars(int tag)
public TagChars getChars(int tag, TagChars chars)
tag
- The tag to get the value ofchars
- Where to store the pointerpublic int getType(int tag)
public short getSubType(int tag)
public int next(int tag)
public int prev(int tag)
public long byteSize()
private int allocateID()
private void ensureCapacity(int nBytes)
nBytes
- How many bytes to check forprivate void newBlock()
curBlock
to point at it.