public class SimpleParser extends Base
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected boolean |
m_fValidate
If true, validate XML if it contains an XSD reference
|
protected com.tangosol.run.xml.XmlToken |
m_token
The "current" token being evaluated.
|
protected com.tangosol.run.xml.XmlTokenizer |
m_toker
The lexical tokenizer.
|
Constructor and Description |
---|
SimpleParser()
Construct an XML SimpleParser.
|
SimpleParser(boolean fValidate)
Construct an XML SimpleParser.
|
Modifier and Type | Method and Description |
---|---|
protected com.tangosol.run.xml.XmlToken |
current()
Returns the current token and advances to the next token.
|
protected boolean |
hasCurrent()
Determine if there is a current token.
|
protected boolean |
hasNext()
Determine if there is a next token.
|
protected void |
init()
Internal initialization.
|
protected XmlDocument |
instantiateDocument()
Factory method to instantiate an XmlDocument implementation.
|
static void |
main(String[] asArgs)
Unit test.
|
protected com.tangosol.run.xml.XmlToken |
mark()
Marks the current position and returns it as a token.
|
protected com.tangosol.run.xml.XmlToken |
match(int id)
Verifies that the current token matches the passed token id and, if so,
advances to the next token.
|
protected com.tangosol.run.xml.XmlToken |
match(String sName)
Verifies that the current token is a name token whose name matches
the passed String and, if so, advances to the next token.
|
protected com.tangosol.run.xml.XmlToken |
next()
Advances to and returns the next token.
|
protected void |
parseComment(XmlElement xml)
Parse comments.
|
protected void |
parseComment(XmlElement xml,
boolean fIsDocument)
Parse comments.
|
protected void |
parseDoctype(XmlDocument xml)
Parse doc type.
|
protected void |
parseDocument(XmlDocument xml)
Factory method to instantiate an XmlDocument implementation.
|
protected void |
parseElement(XmlElement xml)
Note: '<' and element name have already been parsed
|
protected void |
parseMisc(XmlElement xml)
Parse comments / other PIs.
|
protected void |
parsePi(XmlElement xml)
Parse <?
|
protected void |
parsePi(XmlElement xml,
boolean fXmlDeclAllowed)
Parse <?
|
XmlDocument |
parseXml(InputStream stream)
Parse the specified InputStream into an XmlDocument object.
|
XmlDocument |
parseXml(InputStream stream,
String sCharset)
Parse the specified InputStream into an XmlDocument object using
the specified charset.
|
XmlDocument |
parseXml(Reader reader)
Parse the specified Reader into an XmlDocument object.
|
XmlDocument |
parseXml(String sXml)
Parse the specified String into an XmlDocument object.
|
XmlDocument |
parseXml(String sXml,
XmlDocument xml)
Parse the passed script.
|
protected void |
parseXmlDecl(XmlDocument xml)
Parse XML declaration.
|
protected com.tangosol.run.xml.XmlToken |
peek(int id)
Tests if the current token matches the passed token id and, if so,
advances to the next token.
|
protected com.tangosol.run.xml.XmlToken |
peek(int cat,
int subcat)
Tests if the current token matches the passed token category and
sub-category.
|
protected com.tangosol.run.xml.XmlToken |
peek(String sName)
Tests if the current token is a name that matches the passed String
and, if so, advances to the next token.
|
protected InputStream |
skipBOM(InputStream in)
Read the provided
InputStream to determine if the stream starts
with a UTF-8 BOM (http://www.unicode.org/faq/utf_bom.html#BOM). |
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
protected final boolean m_fValidate
protected com.tangosol.run.xml.XmlTokenizer m_toker
protected com.tangosol.run.xml.XmlToken m_token
public SimpleParser()
public SimpleParser(boolean fValidate)
fValidate
- if true, validate XML if it contains
an XSD referenceprotected void init()
public XmlDocument parseXml(String sXml) throws IOException
sXml
- the String to parseIOException
- if I/O error occurspublic XmlDocument parseXml(Reader reader) throws IOException
reader
- the Reader objectIOException
- if I/O error occurspublic XmlDocument parseXml(InputStream stream) throws IOException
stream
- the InputStream objectIOException
- if I/O error occurspublic XmlDocument parseXml(InputStream stream, String sCharset) throws IOException
stream
- the InputStream objectsCharset
- the charset nameIOException
- if I/O error occurspublic XmlDocument parseXml(String sXml, XmlDocument xml) throws IOException
sXml
- the script to parse (as a string)xml
- the XML document object to parse intoIOException
- if I/O error occursprotected XmlDocument instantiateDocument()
public static void main(String[] asArgs)
asArgs
- the string array argumentsprotected void parseDocument(XmlDocument xml) throws com.tangosol.dev.compiler.CompilerException
xml
- a blank XmlDocumentcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parsePi(XmlElement xml) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML elementcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parsePi(XmlElement xml, boolean fXmlDeclAllowed) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML elementfXmlDeclAllowed
- whether XML declaration is allowedcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parseXmlDecl(XmlDocument xml) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML documentcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parseDoctype(XmlDocument xml) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML documentcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parseElement(XmlElement xml) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML elementcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parseMisc(XmlElement xml) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML elementcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parseComment(XmlElement xml) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML elementcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected void parseComment(XmlElement xml, boolean fIsDocument) throws com.tangosol.dev.compiler.CompilerException
xml
- the XML elementfIsDocument
- whether the passed in XmlElement is an XmlDocumentcom.tangosol.dev.compiler.CompilerException
- if compiler error occursprotected boolean hasCurrent()
protected com.tangosol.run.xml.XmlToken current() throws com.tangosol.dev.compiler.CompilerException
com.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected boolean hasNext()
protected com.tangosol.run.xml.XmlToken next() throws com.tangosol.dev.compiler.CompilerException
com.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected com.tangosol.run.xml.XmlToken match(int id) throws com.tangosol.dev.compiler.CompilerException
id
- the token id to matchcom.tangosol.dev.compiler.SyntaxException
- thrown if the token does not matchcom.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected com.tangosol.run.xml.XmlToken match(String sName) throws com.tangosol.dev.compiler.CompilerException
sName
- the name token text to matchcom.tangosol.dev.compiler.SyntaxException
- thrown if the token does not matchcom.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected com.tangosol.run.xml.XmlToken peek(int id) throws com.tangosol.dev.compiler.CompilerException
id
- the token id to peek forcom.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected com.tangosol.run.xml.XmlToken peek(int cat, int subcat) throws com.tangosol.dev.compiler.CompilerException
cat
- the category to peek forsubcat
- the sub-category to peek forcom.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected com.tangosol.run.xml.XmlToken peek(String sName) throws com.tangosol.dev.compiler.CompilerException
sName
- the name token text to peek forcom.tangosol.dev.compiler.CompilerException
- potentially thrown by the tokenizerprotected com.tangosol.run.xml.XmlToken mark()
protected InputStream skipBOM(InputStream in) throws IOException
InputStream
to determine if the stream starts
with a UTF-8 BOM (http://www.unicode.org/faq/utf_bom.html#BOM). If the
BOM is present, advance the stream to skip it.
This is a workaround for the inability of the Java UTF-8 encoding to recognize the UTF-8 BOM (http://bugs.sun.com/view_bug.do?bug_id=4508058).
in
- InputStream to check for BOMIOException
- if I/O error occurs