|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.p2p.util.XMLParser
This class is a memory-efficient implementation of most of the XML pull parsing API.
Nested Class Summary | |
class |
XMLParser.CharArrayBuffer
This class implements a char array buffer |
Field Summary | |
protected java.lang.String[] |
attributeKeys
If the tag parsed was a start tag, the list of attribute-> value pairs |
protected java.lang.String[] |
attributeValues
DESCRIBE THE FIELD |
protected char[] |
buffer
The internal buffer used to process data |
static int |
BUFFER_SIZE
The size of the internal buffer to allocate |
protected int |
bufferLimit
DESCRIBE THE FIELD |
protected int |
bufferPosition
Internal pointers into the buffer |
protected StringCache |
cache
The StringCache used to reduce the memory requirements |
static java.lang.String[][] |
ENTITIES
DESCRIBE THE FIELD |
protected boolean |
inTag
Whether or not we are currently in a tag... |
protected int |
mark
Internal variable which keeps track of the current mark |
protected XMLParser.CharArrayBuffer |
marked
DESCRIBE THE FIELD |
static int |
MAX_ATTRIBUTES
DESCRIBE THE FIELD |
protected java.lang.String |
name
If the tag parsed was a start/end, the name of the tag |
protected int |
numAttributes
DESCRIBE THE FIELD |
static char[] |
QUOTE
DESCRIBE THE FIELD |
protected java.io.Reader |
reader
The internal reader used to read data |
static char[] |
SINGLE
DESCRIBE THE FIELD |
static char[] |
TAG_END
DESCRIBE THE FIELD |
protected java.util.Stack |
tags
The internal stack of tags which have been read |
protected java.lang.String |
text
If the tag parsed was text, the text |
static char[] |
WHITESPACE
DESCRIBE THE FIELD |
static char[] |
WHITESPACE_OR_EQUALS
DESCRIBE THE FIELD |
static char[] |
WHITESPACE_OR_TAG_END
DESCRIBE THE FIELD |
Fields inherited from interface org.xmlpull.v1.XmlPullParser |
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, FEATURE_PROCESS_DOCDECL, FEATURE_PROCESS_NAMESPACES, FEATURE_REPORT_NAMESPACE_ATTRIBUTES, FEATURE_VALIDATION, IGNORABLE_WHITESPACE, NO_NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT, TYPES |
Constructor Summary | |
XMLParser()
Constructor |
Method Summary | |
protected void |
addAttribute(java.lang.String key,
java.lang.String value)
Internal method which adds an attributes |
protected void |
clearAttributes()
Internal method which clears the list of attributes |
protected boolean |
contains(char[] chars,
char c)
Internal method which checks for existence |
protected java.lang.String |
convert(java.lang.String string)
Internal method which deconverts all of the HTML/XML entities like &, >, <, etc... |
protected char |
current()
Method which returns the current char in the buffer |
void |
defineEntityReplacementText(java.lang.String entityName,
java.lang.String replacementText)
DESCRIBE THE METHOD |
protected void |
expect(char c)
An assertion method |
protected void |
fillBuffer()
Internal method which actually fills the buffer |
int |
getAttributeCount()
Gets the AttributeCount attribute of the XMLParser object |
java.lang.String |
getAttributeName(int index)
Gets the AttributeName attribute of the XMLParser object |
java.lang.String |
getAttributeNamespace(int index)
Gets the AttributeNamespace attribute of the XMLParser object |
java.lang.String |
getAttributePrefix(int index)
Gets the AttributePrefix attribute of the XMLParser object |
java.lang.String |
getAttributeType(int index)
Gets the AttributeType attribute of the XMLParser object |
java.lang.String |
getAttributeValue(int index)
Gets the AttributeValue attribute of the XMLParser object |
java.lang.String |
getAttributeValue(java.lang.String namespace,
java.lang.String name)
Returns the attributes value identified by namespace URI and namespace localName. |
int |
getColumnNumber()
Gets the ColumnNumber attribute of the XMLParser object |
int |
getDepth()
Gets the Depth attribute of the XMLParser object |
int |
getEventType()
Returns the type of the current event (START_TAG, END_TAG, TEXT, etc.) |
boolean |
getFeature(java.lang.String name)
Gets the Feature attribute of the XMLParser object |
java.lang.String |
getInputEncoding()
Gets the InputEncoding attribute of the XMLParser object |
int |
getLineNumber()
Gets the LineNumber attribute of the XMLParser object |
java.lang.String |
getName()
For START_TAG or END_TAG events, the (local) name of the current element is returned when namespaces are enabled. |
java.lang.String |
getNamespace()
Gets the Namespace attribute of the XMLParser object |
java.lang.String |
getNamespace(java.lang.String prefix)
Gets the Namespace attribute of the XMLParser object |
int |
getNamespaceCount(int depth)
Gets the NamespaceCount attribute of the XMLParser object |
java.lang.String |
getNamespacePrefix(int pos)
Gets the NamespacePrefix attribute of the XMLParser object |
java.lang.String |
getNamespaceUri(int pos)
Gets the NamespaceUri attribute of the XMLParser object |
java.lang.String |
getPositionDescription()
Gets the PositionDescription attribute of the XMLParser object |
java.lang.String |
getPrefix()
Gets the Prefix attribute of the XMLParser object |
java.lang.Object |
getProperty(java.lang.String name)
Gets the Property attribute of the XMLParser object |
java.lang.String |
getText()
Returns the text content of the current event as String. |
char[] |
getTextCharacters(int[] holderForStartAndLength)
Gets the TextCharacters attribute of the XMLParser object |
boolean |
isAttributeDefault(int index)
Gets the AttributeDefault attribute of the XMLParser object |
boolean |
isEmptyElementTag()
Gets the EmptyElementTag attribute of the XMLParser object |
boolean |
isWhitespace()
Checks whether the current TEXT event contains only whitespace characters. |
boolean |
isWhitespace(java.lang.String text)
Internal method which checks for existence |
protected void |
mark()
Sets the mark |
int |
next()
Get next parsing event - element content wil be coalesced and only one TEXT event must be returned for whole element content (comments and processing instructions will be ignored and emtity references must be expanded or exception mus be thrown if entity reerence can not be exapnded). |
int |
nextTag()
DESCRIBE THE METHOD |
java.lang.String |
nextText()
DESCRIBE THE METHOD |
int |
nextToken()
DESCRIBE THE METHOD |
protected void |
parseAttributes()
Method which parses all of the attributes of a start tag |
protected int |
parseDocumentTag()
Method which parses a document tag |
protected int |
parseEndTag()
Method which parses an end tag of the form |
protected int |
parseEndTag(java.lang.String tag)
Method which parses an end tag of the form |
protected int |
parseStartTag()
Method which parses a start tag |
protected int |
parseTag()
Internal method which parses a tag |
protected int |
parseText()
Method which parses an end tag of the form |
protected java.lang.String |
parseUntil(char c)
Method which parses and returns up to the next token |
protected java.lang.String |
parseUntil(char[] chars)
Method which parses and returns up to the next token |
protected void |
parseUntilNot(char[] chars)
Method which parses up to the next token |
void |
require(int type,
java.lang.String namespace,
java.lang.String name)
DESCRIBE THE METHOD |
void |
setFeature(java.lang.String name,
boolean state)
----- UNSUPPORTED METHODS ----- |
void |
setInput(java.io.InputStream inputStream,
java.lang.String inputEncoding)
Sets the Input attribute of the XMLParser object |
void |
setInput(java.io.Reader in)
Set the input source for parser to the given reader and resets the parser. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets the Property attribute of the XMLParser object |
protected void |
step()
Method which steps forward in the buffer |
protected java.lang.String |
unmark()
Unsets the mark |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.io.Reader reader
protected char[] buffer
protected int bufferPosition
protected int bufferLimit
protected StringCache cache
protected java.util.Stack tags
protected java.lang.String name
protected java.lang.String text
protected java.lang.String[] attributeKeys
protected java.lang.String[] attributeValues
protected int numAttributes
protected boolean inTag
protected int mark
protected XMLParser.CharArrayBuffer marked
public static final int BUFFER_SIZE
public static final int MAX_ATTRIBUTES
public static final char[] QUOTE
public static final char[] TAG_END
public static final char[] WHITESPACE
public static final char[] WHITESPACE_OR_TAG_END
public static final char[] WHITESPACE_OR_EQUALS
public static final char[] SINGLE
public static final java.lang.String[][] ENTITIES
Constructor Detail |
public XMLParser()
Method Detail |
public java.lang.String getText()
NOTE: in case of ENTITY_REF, this method returns the entity replacement text (or null if not available). This is the only case where getText() and getTextCharacters() return different values.
getText
in interface org.xmlpull.v1.XmlPullParser
getEventType()
,
next()
,
nextToken()
public java.lang.String getName()
Please note: To reconstruct the raw element name when namespaces are enabled and the prefix is not null, you will need to add the prefix and a colon to localName..
getName
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getAttributeValue(java.lang.String namespace, java.lang.String name)
NOTE: attribute value must be normalized (including entity replacement text if PROCESS_DOCDECL is false) as described in XML 1.0 section 3.3.3 Attribute-Value Normalization
getAttributeValue
in interface org.xmlpull.v1.XmlPullParser
namespace
- Namespace of the attribute if namespaces are enabled
otherwise must be nullname
- If namespaces enabled local name of attribute otherwise just
attribute name
defineEntityReplacementText(java.lang.String, java.lang.String)
public int getEventType() throws org.xmlpull.v1.XmlPullParserException
getEventType
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONnext()
,
nextToken()
public boolean isWhitespace() throws org.xmlpull.v1.XmlPullParserException
Please note: non-validating parsers are not able to distinguish whitespace and ignorable whitespace, except from whitespace outside the root element. Ignorable whitespace is reported as separate event, which is exposed via nextToken only.
isWhitespace
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic boolean isWhitespace(java.lang.String text)
text
- DESCRIBE THE PARAMETER
public boolean getFeature(java.lang.String name)
getFeature
in interface org.xmlpull.v1.XmlPullParser
name
- DESCRIBE THE PARAMETER
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface org.xmlpull.v1.XmlPullParser
name
- DESCRIBE THE PARAMETER
public java.lang.String getInputEncoding()
getInputEncoding
in interface org.xmlpull.v1.XmlPullParser
public int getNamespaceCount(int depth) throws org.xmlpull.v1.XmlPullParserException
getNamespaceCount
in interface org.xmlpull.v1.XmlPullParser
depth
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic java.lang.String getNamespacePrefix(int pos) throws org.xmlpull.v1.XmlPullParserException
getNamespacePrefix
in interface org.xmlpull.v1.XmlPullParser
pos
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic java.lang.String getNamespaceUri(int pos) throws org.xmlpull.v1.XmlPullParserException
getNamespaceUri
in interface org.xmlpull.v1.XmlPullParser
pos
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic java.lang.String getNamespace(java.lang.String prefix)
getNamespace
in interface org.xmlpull.v1.XmlPullParser
prefix
- DESCRIBE THE PARAMETER
public int getDepth()
getDepth
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getPositionDescription()
getPositionDescription
in interface org.xmlpull.v1.XmlPullParser
public int getLineNumber()
getLineNumber
in interface org.xmlpull.v1.XmlPullParser
public int getColumnNumber()
getColumnNumber
in interface org.xmlpull.v1.XmlPullParser
public char[] getTextCharacters(int[] holderForStartAndLength)
getTextCharacters
in interface org.xmlpull.v1.XmlPullParser
holderForStartAndLength
- DESCRIBE THE PARAMETER
public java.lang.String getNamespace()
getNamespace
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getPrefix()
getPrefix
in interface org.xmlpull.v1.XmlPullParser
public boolean isEmptyElementTag() throws org.xmlpull.v1.XmlPullParserException
isEmptyElementTag
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic java.lang.String getAttributeNamespace(int index)
getAttributeNamespace
in interface org.xmlpull.v1.XmlPullParser
index
- DESCRIBE THE PARAMETER
public java.lang.String getAttributePrefix(int index)
getAttributePrefix
in interface org.xmlpull.v1.XmlPullParser
index
- DESCRIBE THE PARAMETER
public java.lang.String getAttributeType(int index)
getAttributeType
in interface org.xmlpull.v1.XmlPullParser
index
- DESCRIBE THE PARAMETER
public boolean isAttributeDefault(int index)
isAttributeDefault
in interface org.xmlpull.v1.XmlPullParser
index
- DESCRIBE THE PARAMETER
public int getAttributeCount()
getAttributeCount
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getAttributeName(int index)
getAttributeName
in interface org.xmlpull.v1.XmlPullParser
index
- DESCRIBE THE PARAMETER
public java.lang.String getAttributeValue(int index)
getAttributeValue
in interface org.xmlpull.v1.XmlPullParser
index
- DESCRIBE THE PARAMETER
public void setInput(java.io.Reader in) throws org.xmlpull.v1.XmlPullParserException
setInput
in interface org.xmlpull.v1.XmlPullParser
in
- The new Input value
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic void setFeature(java.lang.String name, boolean state) throws org.xmlpull.v1.XmlPullParserException
setFeature
in interface org.xmlpull.v1.XmlPullParser
name
- The new Feature valuestate
- The new Feature value
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic void setProperty(java.lang.String name, java.lang.Object value) throws org.xmlpull.v1.XmlPullParserException
setProperty
in interface org.xmlpull.v1.XmlPullParser
name
- The new Property valuevalue
- The new Property value
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic void setInput(java.io.InputStream inputStream, java.lang.String inputEncoding) throws org.xmlpull.v1.XmlPullParserException
setInput
in interface org.xmlpull.v1.XmlPullParser
inputStream
- The new Input valueinputEncoding
- The new Input value
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic int next() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
NOTE: empty element (such as <tag/>) will be reported with two separate events: START_TAG, END_TAG - it must be so to preserve parsing equivalency of empty element to <tag></tag>. (see isEmptyElementTag ())
next
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONisEmptyElementTag()
,
XmlPullParser.START_TAG
,
XmlPullParser.TEXT
,
XmlPullParser.END_TAG
,
XmlPullParser.END_DOCUMENT
protected void fillBuffer() throws java.io.IOException
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected char current() throws java.io.IOException
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected void step()
protected void mark()
protected java.lang.String unmark()
protected void clearAttributes()
protected void addAttribute(java.lang.String key, java.lang.String value)
key
- The feature to be added to the Attribute attributevalue
- The feature to be added to the Attribute attributeprotected void expect(char c) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
c
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected boolean contains(char[] chars, char c)
chars
- The chars to check forc
- DESCRIBE THE PARAMETER
protected java.lang.String parseUntil(char[] chars) throws java.io.IOException
chars
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected java.lang.String parseUntil(char c) throws java.io.IOException
c
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected void parseUntilNot(char[] chars) throws java.io.IOException
chars
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected int parseEndTag(java.lang.String tag) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
tag
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected int parseTag() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected int parseEndTag() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected int parseStartTag() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected int parseDocumentTag() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected void parseAttributes() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected int parseText() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected java.lang.String convert(java.lang.String string)
string
- The string to convert
public void defineEntityReplacementText(java.lang.String entityName, java.lang.String replacementText) throws org.xmlpull.v1.XmlPullParserException
defineEntityReplacementText
in interface org.xmlpull.v1.XmlPullParser
entityName
- DESCRIBE THE PARAMETERreplacementText
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTIONpublic int nextToken() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
nextToken
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic void require(int type, java.lang.String namespace, java.lang.String name) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
require
in interface org.xmlpull.v1.XmlPullParser
type
- DESCRIBE THE PARAMETERnamespace
- DESCRIBE THE PARAMETERname
- DESCRIBE THE PARAMETER
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic java.lang.String nextText() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
nextText
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic int nextTag() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
nextTag
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
- DESCRIBE THE EXCEPTION
java.io.IOException
- DESCRIBE THE EXCEPTION
|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |