public class XMLTable extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
XMLTable.IMapValue |
static interface |
XMLTable.IParser<T extends XMLTable.IMapValue> |
Modifier and Type | Field and Description |
---|---|
protected String |
_tableID |
protected HashMap<String,Integer> |
columns |
protected String[] |
currentRec |
static int |
duplicateIgnor
If pk is duplicating, merging record is ignored.
|
static int |
duplicateReplace
If pk is duplicating, this obj's record is replaced with merging.
|
protected HashMap<String,Integer> |
pkCols |
protected ArrayList<String[]> |
rows |
Constructor and Description |
---|
XMLTable(HashMap<String,Integer> fromColumns,
HashMap<String,Integer> fromPkCols,
ArrayList<ArrayList<Object>> fromList)
This can be used to clone from FLResultset.
Becareful, the cols and rows indexes in result set start at 1, but in XMLTable that start at 0! All columns and rows idxes are -1. |
XMLTable(String tableID,
HashMap<String,Integer> fromColumns,
HashMap<String,Integer> fromPkCols)
Constructing an empty table, table structure value copied from parameters.
|
XMLTable(String newTableID,
HashMap<String,Integer> fromColumns,
HashMap<String,Integer> fromPkCols,
ArrayList<String[]> fromList)
value copy and construct a new table, according to parameters.
|
XMLTable(String tableID,
String cols,
String pk,
ILogger log)
Construct an empty table according to cols and pk.
Table construction not finished without calling endTablePush().
|
Modifier and Type | Method and Description |
---|---|
protected void |
appendFieldValue(int colIdx,
String fieldValue) |
protected void |
appendFieldValue(String colName,
String fieldValue) |
void |
appendRow(HashMap<String,String> row) |
XMLTable |
beforeFirst() |
void |
cloneCol(String newName,
String oldName)
Clone a column index for id reference.
Sometimes the E2Engine will refere to a fixed name field to retrieve data, e.g. |
void |
end() |
protected void |
endRecordPush(boolean checkPK)
Push the temp record into table rows.
|
XMLTable |
endTablePush() |
ArrayList<String[]> |
findRecords(HashMap<String,String> kv) |
XMLTable |
findRecordsTable(HashMap<String,String> pkVals) |
String |
getAttribute(String attr,
String defaultVal) |
boolean |
getBool(String colName,
boolean defaultVal) |
HashMap<String,Integer> |
getColumns() |
float |
getFloat(String colName,
float defaultVal) |
float[] |
getFloats(String colName,
float defaultVal) |
int |
getInt(int col,
int defaultVal) |
int |
getInt(String colName) |
int |
getInt(String colName,
int defaultVal) |
int |
getIntAt(int row,
int col,
int defaultVal) |
int |
getIntAt(int row,
String colName,
int defaultVal) |
int[] |
getInts(String colName,
int defaultVal) |
HashMap<String,Integer> |
getPKs() |
String[] |
getRecordByPK(String[] pkVals)
Find record according to pk values.
|
String[] |
getRow() |
String[] |
getRowAt(int position) |
int |
getRowCount() |
int |
getRowIdx() |
ArrayList<String[]> |
getRows() |
String[] |
getRows(String colName) |
String |
getString(int col) |
String |
getString(String colName) |
String |
getStringAt(int row,
String colName) |
String[] |
getStrings(String colName) |
String |
getTableID() |
boolean |
goAt(int position) |
void |
insertRowAt(int rowIdx,
HashMap<String,String> row) |
void |
last()
go last record - getXXX(c) got last row's field.
|
<T extends XMLTable.IMapValue> |
map(XMLTable.IParser<T> parser) |
void |
mergeWith(XMLTable withTable,
int duplicateMode)
Merge withTable to this object.
Table name and colomns order can be different, but both table must have exactly the same columns and pk fields. Note: This method is not suitable for large record's number. |
boolean |
next() |
boolean |
previous() |
void |
remove(HashMap<String,String> kv) |
void |
setField(String colName,
String val) |
void |
setXmlAttrs(Attributes attributes) |
protected void |
startRecordPush() |
void |
startTablePush() |
protected String _tableID
protected String[] currentRec
public static final int duplicateIgnor
public static final int duplicateReplace
public XMLTable(String tableID, String cols, String pk, ILogger log) throws SAXException
tableID
- cols
- pk
- Exception
SAXException
public XMLTable(String tableID, HashMap<String,Integer> fromColumns, HashMap<String,Integer> fromPkCols)
tableID
- fromColumns
- fromPkCols
- public XMLTable(String newTableID, HashMap<String,Integer> fromColumns, HashMap<String,Integer> fromPkCols, ArrayList<String[]> fromList)
newTableID
- fromColumns
- fromPkCols
- fromList
- public XMLTable(HashMap<String,Integer> fromColumns, HashMap<String,Integer> fromPkCols, ArrayList<ArrayList<Object>> fromList)
fromColumns
- fromPkCols
- fromList
- protected void appendFieldValue(String colName, String fieldValue) throws SAXParseException
SAXParseException
protected void appendFieldValue(int colIdx, String fieldValue) throws SAXParseException
SAXParseException
protected void startRecordPush() throws SAXParseException
SAXParseException
protected void endRecordPush(boolean checkPK) throws SAXParseException
checkPK
- SAXParseException
public String[] getRecordByPK(String[] pkVals) throws SAXParseException
pkVals
- SAXParseException
public void startTablePush()
public XMLTable endTablePush()
public XMLTable beforeFirst() throws SAXException
SAXException
public void last() throws SAXException
SAXException
public boolean next() throws SAXException
SAXException
public boolean goAt(int position) throws SAXException
SAXException
public void end() throws SAXException
SAXException
public boolean previous() throws SAXException
SAXException
public String[] getRow() throws SAXException
SAXException
public String getString(int col) throws SAXException
col
- start from 0.SAXException
public String getString(String colName) throws SAXException
SAXException
public String getStringAt(int row, String colName) throws SAXException
SAXException
public String getTableID()
public int getRowCount()
public int getRowIdx()
public ArrayList<String[]> findRecords(HashMap<String,String> kv) throws SAXException
kv
- - [key = colname, val = fieldVal]SAXException
public XMLTable findRecordsTable(HashMap<String,String> pkVals) throws SAXException
pkVals
- - [key = colname, val = fieldVal]SAXException
public String[] getRowAt(int position) throws SAXException
SAXException
public void cloneCol(String newName, String oldName) throws SAXException
newName
- oldName
- SAXException
public String[] getRows(String colName) throws SAXException
SAXException
public int getInt(String colName, int defaultVal)
public int getInt(String colName) throws SAXException
SAXException
public int getInt(int col, int defaultVal)
public int getIntAt(int row, String colName, int defaultVal)
public int getIntAt(int row, int col, int defaultVal)
public boolean getBool(String colName, boolean defaultVal)
public String[] getStrings(String colName) throws SAXException
SAXException
public float getFloat(String colName, float defaultVal)
public float[] getFloats(String colName, float defaultVal) throws SAXException
SAXException
public int[] getInts(String colName, int defaultVal) throws SAXException
SAXException
public void setXmlAttrs(Attributes attributes)
public void setField(String colName, String val) throws SAXException
SAXException
public void mergeWith(XMLTable withTable, int duplicateMode) throws SAXException
withTable
- duplicateMode
- one of duplicateIgnor
and duplicateReplace
SAXException
public void appendRow(HashMap<String,String> row) throws SAXException
SAXException
public void insertRowAt(int rowIdx, HashMap<String,String> row) throws SAXException
SAXException
public void remove(HashMap<String,String> kv) throws SAXException
SAXException
public <T extends XMLTable.IMapValue> HashMap<String,T> map(XMLTable.IParser<T> parser) throws SAXException, SemanticException
SAXException
SemanticException
Copyright © 2024. All rights reserved.