|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.app.DataRecord
public class DataRecord
The DataRecord provides a high-level interfaces to a record consisting of some number of rows, each of which may contain a variable number of columns of 'short', 'int', or 'string' data types.
TODO:
- deleting some or all of the columns in a row
- throw more meaningful exceptions than ArrayIndexOutOfBounds
- a SanityCheck() method to provide the ability to judge if
a records data is intact. An intact record will never cause
an exception to be thrown when reading from existing rows
and columns
- fast searching tools
- string extractor tools
LIMITATIONS:
- a row may only contain items of one type.
- a record may not be larger than 32K
- writing is inefficient, write numeric columns from right to left
for best performance
IMPLEMENTATION:
- Each record contains a directory, 1 short per row, containing
offsets from the start of the record to the start of that row
- There is one short, value 0, immediately after this directory
to serve as a terminator for the directory AND the place where
all empty rows are pointed at
- each row starts with a short countaining the number of columns
in that row
- 'int' and 'short' rows will contain 4*count and 2*count bytes of
data respectively
- 'string' rows will contain one short bytecount followed by that
number of bytes of UTF-8 character data
- all numbers are little-endian
(row0_offset:2) ------.
(row1_offset:2) --. |
(row2_offset:2) --|-. |
(zero:2) <-' | |
(row2_cols:2) <---' |
... |
... |
(row0_cols:2) <-----'
...
...
...
| Field Summary | |
|---|---|
static int |
FIND_FLAG_IGNORE_CASE
|
static int |
FIND_MASK_MODE
|
static int |
FIND_MODE_ALL_RECORDS
|
static int |
FIND_MODE_CONTAINS
|
static int |
FIND_MODE_EXACT
|
static int |
FIND_MODE_STARTS_WITH
|
byte[] |
mData
|
int |
mRows
|
| Constructor Summary | |
|---|---|
DataRecord(byte[] data,
int rows)
Create a new record backed against a provided byte array and specified number of rows |
|
DataRecord(int rows)
Create a new record with the specified number of rows, all of which will be empty initially. |
|
| Method Summary | |
|---|---|
void |
clearRowInt(int row)
Set the number of columns in the specified row to zero. |
void |
clearRowShort(int row)
Set the number of columns in the specified row to zero. |
void |
clearRowString(int row)
Set the number of columns in the specified row to zero. |
int |
collate(DangerCollator dc,
int row,
int col,
DataRecord other,
int other_row,
int other_col)
|
int |
collate(DangerCollator dc,
int row,
int col,
int skip,
DataRecord other,
int other_row,
int other_col,
int other_skip)
|
int |
collate(DangerCollator dc,
int row,
int col,
String other)
|
int |
countColumns(int row)
Return the number of columns in the specified row |
int |
countRows()
Return the number of rows in this record |
void |
drawString(int row,
int col,
Pen p,
int x,
int y)
Draws a string with the specified pen, at the specified xy location, without allocating a String object. |
void |
dump(String template)
Dump the contents of this record to System.err, based on the description in the template string (one char per row, 'i'==Integer, 's'==Short, '*'==String |
boolean |
findString(DangerCollator dc,
DataFinder df,
byte[] key,
int row,
int col,
int mode)
|
boolean |
findString(DataFinder df,
byte[] key,
int row,
int col,
int mode)
|
boolean |
findStringContains(DataFinder df,
byte[] key,
int row,
int col)
|
boolean |
findStringContainsIgnoreCase(DataFinder df,
byte[] keyUpperCase,
int row,
int col)
|
boolean |
findStringExactMatch(DataFinder df,
byte[] key,
int row,
int col)
|
boolean |
findStringExactMatchIgnoreCase(DataFinder df,
byte[] keyUpperCase,
int row,
int col)
|
boolean |
findStringStartsWith(DataFinder df,
byte[] key,
int row,
int col)
|
boolean |
findStringStartsWithIgnoreCase(DataFinder df,
byte[] keyUpperCase,
int row,
int col)
|
byte[] |
getByteArray(int row,
int col)
Read a byte[] from a specified row and column. |
int |
getInt(int row,
int col)
Read an Integer from a specified row and column. |
String |
getInternString(int row,
int col)
Read a String from a specified row and column and intern it. |
int |
getShort(int row,
int col)
Read a Short from a specified row and column. |
String |
getString(int row,
int col)
Read a String from a specified row and column. |
int |
getStringLength(int row,
int col)
|
int |
getStringOffset(int row,
int col)
|
void |
init(int rows)
Recreate a record with the specified number of rows, all of which will be empty initially. |
void |
putByteArray(int row,
int col,
byte[] value)
Write an byte[] to a specified row and column. |
void |
putInt(int row,
int col,
int value)
Write an Integer to a specified row and column. |
void |
putShort(int row,
int col,
int value)
Write an Short to a specified row and column. |
void |
putString(int row,
int col,
String value)
Write an String to a specified row and column. |
boolean |
startsWith(DangerCollator dc,
int row,
int col,
String other)
|
int |
stringCompareIgnoreCase(int row,
int col,
DataRecord other,
int other_row,
int other_col)
|
int |
stringCompareIgnoreCase(int row,
int col,
DataRecord other,
int other_row,
int other_col,
byte[][] ignoredPrefixes,
boolean ignoreTrailingWhitespace)
|
int |
stringCompareIgnoreCase(int row,
int col,
int skip,
DataRecord other,
int other_row,
int other_col,
int other_skip)
|
int |
stringCompareIgnoreCase(int row,
int col,
String other)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int FIND_MODE_EXACT
public static final int FIND_MODE_CONTAINS
public static final int FIND_MODE_STARTS_WITH
public static final int FIND_MODE_ALL_RECORDS
public static final int FIND_MASK_MODE
public static final int FIND_FLAG_IGNORE_CASE
public byte[] mData
public int mRows
| Constructor Detail |
|---|
public DataRecord(int rows)
public DataRecord(byte[] data,
int rows)
| Method Detail |
|---|
public void init(int rows)
public int countRows()
public int countColumns(int row)
public void clearRowInt(int row)
public void clearRowShort(int row)
public void clearRowString(int row)
public int getInt(int row,
int col)
public int getShort(int row,
int col)
public String getString(int row,
int col)
public String getInternString(int row,
int col)
public byte[] getByteArray(int row,
int col)
public boolean findString(DataFinder df,
byte[] key,
int row,
int col,
int mode)
public boolean findString(DangerCollator dc,
DataFinder df,
byte[] key,
int row,
int col,
int mode)
public boolean findStringContains(DataFinder df,
byte[] key,
int row,
int col)
public boolean findStringContainsIgnoreCase(DataFinder df,
byte[] keyUpperCase,
int row,
int col)
public boolean findStringStartsWith(DataFinder df,
byte[] key,
int row,
int col)
public boolean findStringStartsWithIgnoreCase(DataFinder df,
byte[] keyUpperCase,
int row,
int col)
public boolean findStringExactMatch(DataFinder df,
byte[] key,
int row,
int col)
public boolean findStringExactMatchIgnoreCase(DataFinder df,
byte[] keyUpperCase,
int row,
int col)
public void drawString(int row,
int col,
Pen p,
int x,
int y)
public void putInt(int row,
int col,
int value)
public void putShort(int row,
int col,
int value)
public void putString(int row,
int col,
String value)
public void putByteArray(int row,
int col,
byte[] value)
public void dump(String template)
public int getStringOffset(int row,
int col)
public int stringCompareIgnoreCase(int row,
int col,
DataRecord other,
int other_row,
int other_col)
public int collate(DangerCollator dc,
int row,
int col,
DataRecord other,
int other_row,
int other_col)
public int stringCompareIgnoreCase(int row,
int col,
int skip,
DataRecord other,
int other_row,
int other_col,
int other_skip)
public int collate(DangerCollator dc,
int row,
int col,
int skip,
DataRecord other,
int other_row,
int other_col,
int other_skip)
public int stringCompareIgnoreCase(int row,
int col,
DataRecord other,
int other_row,
int other_col,
byte[][] ignoredPrefixes,
boolean ignoreTrailingWhitespace)
public int stringCompareIgnoreCase(int row,
int col,
String other)
public int collate(DangerCollator dc,
int row,
int col,
String other)
public boolean startsWith(DangerCollator dc,
int row,
int col,
String other)
public int getStringLength(int row,
int col)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||