|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsoalib.parser.Parser
Parser class provides default implementation of IParser interface.
In most cases the default implementation is sufficient, but the
following methods must be overridden, which is directly related
to the kind of parser:
Only one parser is associated with one extension. Each extension
must be associated with a different parser. Also, each ParserTable
have one Parser associated with it. Each ParserDatabase may have
one or more SqlParser objects.
IMPORTANT:
SqlParser objects are created or deleted when sql statements are
executed. Manipulation of sql statements do not case automatic
state change of Parser, ParserTable and ParserDatabase classes.
It is, therefore, necessary that for the Parser object always
point to the SqlParser tables in memory.
1. save() method
2. createTableAndFetch()
3. parse()
| Field Summary | |
protected java.lang.String |
checksum_
|
protected java.lang.String |
grammer_
|
| Fields inherited from interface soalib.parser.IParser |
CHECKSUM_COLUMN_NAME, CHECKSUM_COLUMN_SIZE |
| Constructor Summary | |
Parser()
|
|
| Method Summary | |
void |
allowChecksum(boolean yes)
Computes the checksum if set to true. |
static void |
attachParser(java.lang.String type,
java.lang.Class parser)
|
static Parser |
createParser(java.lang.String extension)
Creates an instance of a registered parser. |
protected void |
createTable(Table table,
int maxColumns)
This method provides a default implementation. |
protected abstract MemoryResultSet |
fetchData(Table table,
java.util.Vector rows)
|
java.lang.String |
getChecksum()
Gets the checksum value as string. |
java.lang.String |
getChecksumColumnName()
The last column of the Table is the checksum checksum column, if checksum was defined. |
Column[] |
getColumns()
|
soalib.parser.grammer.Grammer |
getGrammer()
|
MemoryTable |
getMemoryTable()
|
static java.lang.Class |
getParser(java.lang.String type)
|
static java.lang.Class[] |
getRegisteredClasses()
|
static java.lang.String[] |
getRegisteredExtensions()
|
MemoryResultSet |
getResultSet()
Gets the ResultSet for this parser. |
long |
getRowCount()
Gets row count of the table. |
protected abstract java.util.Vector |
getRows(java.lang.String source,
int[] columnCount)
|
boolean |
hasChecksum()
Returns true if checksum computation is set to true. |
static boolean |
hasParser(java.lang.String type)
|
boolean |
isBlank()
Checks if the table is blank. |
boolean |
parse(java.lang.String source,
Table initTable)
Parses the text from the source and initizlize the table initTable in the second argument. |
abstract boolean |
save(java.lang.String url)
Saves the content of the parser data into a file. |
void |
setBlankTable()
|
void |
setParserGrammer(java.lang.String grammer)
Sets parser attributes. |
void |
setResultSet(MemoryResultSet resultSet)
Sets an external memory result set. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.String grammer_
protected java.lang.String checksum_
| Constructor Detail |
public Parser()
| Method Detail |
public final void allowChecksum(boolean yes)
IParser
allowChecksum in interface IParseryes - a value of true mean, checkusm will be allowed.public final java.lang.String getChecksum()
IParser
getChecksum in interface IParserpublic final java.lang.String getChecksumColumnName()
IParser
getChecksumColumnName in interface IParserpublic final MemoryResultSet getResultSet()
IParser
getResultSet in interface IParserpublic final MemoryTable getMemoryTable()
public final long getRowCount()
IParser
getRowCount in interface IParserpublic soalib.parser.grammer.Grammer getGrammer()
public final boolean hasChecksum()
IParser
hasChecksum in interface IParsertrue, if the checksum was enabled.public final boolean isBlank()
IParser
isBlank in interface IParsertrue, if the table was blank.
public final boolean parse(java.lang.String source,
Table initTable)
IParser
parse in interface IParsersource - name of the file which should be read into the table.initTable - a table into which data is to be read.
true, if parsed successfully.
protected abstract MemoryResultSet fetchData(Table table,
java.util.Vector rows)
protected abstract java.util.Vector getRows(java.lang.String source,
int[] columnCount)
throws java.lang.Exception
java.lang.Exception
public final void setParserGrammer(java.lang.String grammer)
throws ParserException
IParser
setParserGrammer in interface IParsergrammer - the grammer of the table.
ParserExceptionpublic final void setResultSet(MemoryResultSet resultSet)
IParser
setResultSet in interface IParserresultSet - new result set in memory to set.public final void setBlankTable()
public final Column[] getColumns()
throws ParserException
ParserExceptionpublic abstract boolean save(java.lang.String url)
save in interface IParserurl - filename in URL form to store the data.
true, if the data saved correctly.
protected void createTable(Table table,
int maxColumns)
throws ParserException
table - maxColumns -
ParserException
public static final void attachParser(java.lang.String type,
java.lang.Class parser)
throws ParserException
ParserExceptionpublic static final java.lang.Class getParser(java.lang.String type)
public static final boolean hasParser(java.lang.String type)
public static final java.lang.String[] getRegisteredExtensions()
public static final java.lang.Class[] getRegisteredClasses()
public static final Parser createParser(java.lang.String extension)
throws java.lang.Exception
extension -
java.lang.Exception
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||