public abstract class Parser
extends org.xml.sax.helpers.DefaultHandler
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
DEFAULT_PARSER_NAME
Default parser name.
|
protected boolean |
mAdjFName
Boolean flag to ensure that two adjacent filenames are separated by a
whitespace.
|
protected org.xml.sax.Locator |
mLocator
Locator object to determine on which line in the xml has the error
occured.
|
protected LogManager |
mLogger
The LogManager object which logs the Pegasus messages.
|
protected java.lang.String |
mLogMsg
The String which contains the messages to be logged.
|
protected org.xml.sax.XMLReader |
mParser
The object which is used to parse the dax.
|
protected PegasusProperties |
mProps
The object holding all the properties pertaining to Pegasus.
|
protected java.lang.StringBuffer |
mTextContent
Holds the text in an element (text between start and final tags if any).
|
protected java.lang.String |
mTextString
A String that holds the contents of data passed as text.
|
Constructor and Description |
---|
Parser(PegasusBag bag)
Intialises the parser.
|
Parser(PegasusProperties properties)
Intialises the parser.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] chars,
int start,
int length)
This is used to store the character data that is in xml.
|
private void |
createParserInstance()
Creates an instance of the parser, and sets the various options to it.
|
abstract void |
endDocument()
This is called automatically when the end of the XML file is reached.
|
abstract void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
An empty implementation is provided by DefaultHandler class.
|
abstract java.lang.String |
getSchemaLocation()
Helps the load database to locate the XML schema, if available.
|
abstract java.lang.String |
getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms
to.
|
java.lang.String |
ignoreWhitespace(java.lang.String str)
Our own implementation for ignorable whitespace.
|
java.lang.String |
ignoreWhitespace(java.lang.String str,
boolean preserveLineBreak)
Our own implementation for ignorable whitespace.
|
void |
setDocumentLocator(org.xml.sax.Locator loc)
Overrides the empty implementation provided by Default Handler and sets
the locator variable for the locator.
|
boolean |
setParserFeature(java.lang.String uri,
boolean flag)
Sets a parser feature, and fails here enabling us to set all the following
features.
|
void |
setSchemaLocations(java.lang.String list)
Sets the list of external real locations where the XML schema may be found.
|
abstract void |
startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs)
An empty implementation is provided by DefaultHandler of ContentHandler.
|
abstract void |
startParser(java.lang.String file)
Start the parser.
|
void |
testForFile(java.lang.String file)
Tests whether the file exists or not.
|
protected final java.lang.String DEFAULT_PARSER_NAME
protected org.xml.sax.Locator mLocator
protected java.lang.StringBuffer mTextContent
protected LogManager mLogger
protected java.lang.String mLogMsg
protected org.xml.sax.XMLReader mParser
protected PegasusProperties mProps
protected java.lang.String mTextString
protected boolean mAdjFName
public Parser(PegasusBag bag)
bag
- the bag of objects that is useful for initialization.public Parser(PegasusProperties properties)
properties
- the properties passed at runtime.public abstract void startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public abstract void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public abstract void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
public abstract void startParser(java.lang.String file)
file
- the path to the XML file you want to parse.public abstract java.lang.String getSchemaLocation()
public abstract java.lang.String getSchemaNamespace()
public void setSchemaLocations(java.lang.String list)
list
- is a list of strings representing schema locations. The content
exists in pairs, one of the namespace URI, one of the location URL.public void characters(char[] chars, int start, int length)
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
public java.lang.String ignoreWhitespace(java.lang.String str)
str
- The string that contains whitespaces.public java.lang.String ignoreWhitespace(java.lang.String str, boolean preserveLineBreak)
str
- The string that contains whitespaces.public void setDocumentLocator(org.xml.sax.Locator loc)
setDocumentLocator
in interface org.xml.sax.ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
loc
- the Locator object which keeps the track as to the line
numbers of the line being parsed.public void testForFile(java.lang.String file) throws java.io.FileNotFoundException
java.io.FileNotFoundException
private void createParserInstance()
public boolean setParserFeature(java.lang.String uri, boolean flag)
uri
- is the feature's URI to modifyflag
- is the new value to set.