Package org.opencms.json
Class XMLTokener
java.lang.Object
org.opencms.json.JSONTokener
org.opencms.json.XMLTokener
The XMLTokener extends the JSONTokener to provide additional methods
for the parsing of XML texts.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the text in the CDATA block.Get the next XML outer token, trimming whitespace.nextEntity
(char a) Return the next ENTITY.nextMeta()
Returns the next XML meta token.Get the next XML Token.boolean
Skip characters until past the requested string.Methods inherited from class org.opencms.json.JSONTokener
back, dehexchar, more, next, next, next, nextClean, nextString, nextTo, nextTo, nextValue, setOrdered, skipTo, syntaxError, toString
-
Field Details
-
ENTITY
The table of ENTITY values. It initially contains Character values for amp, apos, gt, lt, quot.
-
-
Constructor Details
-
XMLTokener
Construct an XMLTokener from a string.- Parameters:
s
- a source string
-
-
Method Details
-
nextCDATA
Get the text in the CDATA block.- Returns:
- the string up to the
]]>
- Throws:
JSONException
- if the]]>
is not found
-
nextContent
Get the next XML outer token, trimming whitespace.There are two kinds of tokens: the '<' character which begins a markup tag, and the content text between markup tags.
- Returns:
- a string, or a '<' Character, or null if there is no more source text
- Throws:
JSONException
- if something goes wrong
-
nextEntity
Return the next ENTITY. These entities are translated to Characters:& ' > < "
.- Parameters:
a
- an ampersand character- Returns:
- a Character or an entity String if the entity is not recognized
- Throws:
JSONException
- if missing ';' in XML entity
-
nextMeta
Returns the next XML meta token. This is used for skipping over <!...> and <?...?> structures.- Returns:
- syntax characters (
< > / = ! ?
) are returned as Character, and strings and names are returned as Boolean. We don't care what the values actually are - Throws:
JSONException
- if a string is not properly closed or if the XML is badly structured
-
nextToken
Get the next XML Token.These tokens are found inside of angle brackets. It may be one of these characters:
/ > = ! ?
or it may be a string wrapped in single quotes or double quotes, or it may be a name.- Returns:
- a string or a Character
- Throws:
JSONException
- if the XML is not well formed
-
skipPast
Skip characters until past the requested string.If it is not found, we are left at the end of the source with a result of false.
- Parameters:
to
- a string to skip past- Returns:
- the truth
- Throws:
JSONException
- if something goes wrong
-