public class Part21Parser extends Object
Modifier and Type | Class and Description |
---|---|
class |
Part21Parser.State |
Modifier and Type | Field and Description |
---|---|
boolean |
convert
If true, attempt to perform a type conversion before throwing an error.
|
boolean |
fail_fast
If true, error recovery is disabled, and will result in an exception
getting thrown on any errors in the Part 21 file.
|
boolean |
keep_partial
If true, does not attempt to clean up when
statusUpdate()
throws a CanceledException. |
int |
status_freq
Set the frequency at which the statusUpdate method is called.
|
Constructor and Description |
---|
Part21Parser()
Create a Part 21 file Reader.
|
Modifier and Type | Method and Description |
---|---|
SchemaBase |
getSchema(String name)
Find the schema for a given name.
|
Model |
parse(File src)
Read a Part 21 file into a new Model.
|
Model |
parse(File src,
String fname)
Read a Part 21 file into a new Model.
|
void |
parse(File src,
String fname,
long flen,
Model mod,
EntityIDTable eids,
boolean set_header,
boolean one_sect)
Read a Part 21 file into an existing Model.
|
Model |
parse(InputStream in,
String fname,
long flen)
Read a Part 21 file into a new Model.
|
void |
parse(InputStream in,
String fname,
long flen,
Model mod,
EntityIDTable eids,
boolean set_header,
boolean one_sect)
Read a Part 21 file into an existing Model.
|
Model |
parse(String fname)
Read a Part 21 file into a new Model.
|
void |
reportError(String fname,
int lineno,
String message)
Report an error in the input file.
|
void |
statusUpdate(Part21Parser.State st)
The method is called periodically as the parser parses its input.
|
public boolean fail_fast
public boolean convert
public int status_freq
status_freq
instances
are read in.public boolean keep_partial
statusUpdate()
throws a CanceledException. If this is false, the CanceledException will
be propogated to the called of parse()
, and the partially
read model will be reclained by the garbage collector. If true the
incomplete model will be returned from the parse()
method.public Part21Parser() throws STDevException
STDevException
public SchemaBase getSchema(String name) throws SchemaNotFoundException
name
- The name of the schema as specified in Part 21SchemaNotFoundException
- the schema could not be found.public void reportError(String fname, int lineno, String message)
fname
- The Part21 file.lineno
- The line number where the error occurred.message
- The error message to be reported.public void statusUpdate(Part21Parser.State st) throws CanceledException
status_freq
instance variable.
The read will be aborted if this method throws an exception.st
- The parser state information. This can be queried to
obtain the number of bytes in the file, the number of bytes ready by
the parser, and the number is insteances read.CanceledException
- to signal the parser to stop parsing the
file. If the exception's keepPartial()
flag is
true
, then the partially read model is return from the
parse
method. Otherwise, the exception is propogated, and
the data that was read will be reclained by the garabge collecto.rpublic Model parse(String fname) throws STDevException, IOException
fname
- The file name.STDevException
- There was some problem parsing the fileIOException
- An I/O exception occurred getting the inputpublic Model parse(File src) throws STDevException, IOException
src
- The file to read.STDevException
- There was some problem parsing the fileIOException
- An I/O exception occurred getting the inputpublic Model parse(File src, String fname) throws STDevException, IOException
src
- The file to read.fname
- The file name for error reporting purposes.
If null
, src.toString() will be used.STDevException
- There was some problem parsing the fileIOException
- An I/O exception occurred getting the inputpublic Model parse(InputStream in, String fname, long flen) throws STDevException, IOException
in
- The reader to readfname
- The file name for error reporting purposes.flen
- The length of the input stream in bytes. This is used for
status reporting.STDevException
- There was some problem parsing the fileIOException
- An I/O exception occurred getting the inputpublic void parse(File src, String fname, long flen, Model mod, EntityIDTable eids, boolean set_header, boolean one_sect) throws STDevException, IOException
src
- The Part 21 file to readfname
- The file name for error reporting purposes.flen
- The length of the input stream in bytes. This is used for
status reporting.mod
- The model to populateeids
- The entity ID table to populateset_header
- Add the file header as a section to the model.one_sect
- Force everything into one data populationSTDevException
- There was some problem parsing the fileIOException
- An I/O exception occurred getting the inputpublic void parse(InputStream in, String fname, long flen, Model mod, EntityIDTable eids, boolean set_header, boolean one_sect) throws STDevException, IOException
in
- The reader to readfname
- The file name for error reporting purposes.flen
- The length of the input stream in bytes. This is used for
status reporting.mod
- The model to populateeids
- The entity ID table to populateset_header
- Add the file header as a section to the model.one_sect
- Force everything into one data populationSTDevException
- There was some problem parsing the fileIOException
- An I/O exception occurred getting the input