|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openadaptor.simplexml.XToken
public abstract class XToken
XToken - abstract superclass for the various simplexml token classes.
This class has two sets of methods. The first is some static (class-wide) helper
methods, which provide methods for XML to plain text translations,
and synchronised access to a shared StringBuffer instance, amongst other things.
The second set of instance methods define the common functionality of
all XTokens. XTokens are intended to be used by XML Scanners, and the XML
parsers and document parsers which control them, for reading and writing the
basic units of XML from and onto I/O streams. As such, XTokens have methods
for writing themselves out, and comparing themselves to existing XTokens.
Currently the subclasses of XToken cover the basic units of XML syntax; symbols (markup), strings and runs of free text, and also higher level XML syntactic units; comments, tags, tag attributes and strings. We might want to group these higher-level elements under another class, but we still want the same common functionality for writing and reading, so it would have to be a subclass of XToken.
| Field Summary | |
|---|---|
protected static java.lang.String |
AMPERSAND
|
(package private) static org.apache.log4j.Logger |
log
|
protected static java.lang.String |
RCARET
|
| Constructor Summary | |
|---|---|
XToken()
|
|
| Method Summary | |
|---|---|
protected static java.lang.StringBuffer |
_grabStringBuffer()
Returns an empty string string buffer from the pool for your use. |
protected static void |
_releaseStringBuffer(java.lang.StringBuffer sb)
Called to return a StringBuffer to the 'free' pool. |
static java.lang.String |
convertToPlaintext(java.lang.String xmlText,
java.lang.String[][] entities)
Translates XML free text to plain text. |
abstract boolean |
equals(XToken other)
Returns true if the receiver exactly matches other. |
protected java.lang.String |
getClassName()
Convenience method which returns the unqualified class name e.g. |
boolean |
isReleased()
Returns "reuse" status of object. |
boolean |
isWhitespace()
Returns true if the XToken represents whitespace. |
abstract boolean |
matches(XToken token)
Returns true if the receiver is the same "type" of XToken as other. |
void |
printDebug()
Print receiver details on System.err. |
void |
setReleased(boolean flag)
Sets the object "reuse" status |
abstract java.lang.String |
toString()
Returns a textual representation of the receiver in a String |
abstract void |
toWriter(java.io.Writer writer)
Writes a textual representation of the receiver onto writer |
void |
toWriter(java.io.Writer writer,
java.lang.String text)
A convenience method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static org.apache.log4j.Logger log
protected static java.lang.String RCARET
protected static java.lang.String AMPERSAND
| Constructor Detail |
|---|
public XToken()
| Method Detail |
|---|
public static java.lang.String convertToPlaintext(java.lang.String xmlText,
java.lang.String[][] entities)
xmlText - XML format text
protected static java.lang.StringBuffer _grabStringBuffer()
releaseStringBuffer().
protected static void _releaseStringBuffer(java.lang.StringBuffer sb)
protected java.lang.String getClassName()
public void printDebug()
public void toWriter(java.io.Writer writer,
java.lang.String text)
throws java.io.IOException
writer, followed by text.
- Parameters:
writer - Output stream.text - Text to follow representation of the receiver on the stream.
- Throws:
java.io.IOException
public boolean isWhitespace()
public abstract void toWriter(java.io.Writer writer)
throws java.io.IOException
writer
writer - Output stream.
java.io.IOExceptionpublic abstract java.lang.String toString()
toString in class java.lang.Objectpublic abstract boolean matches(XToken token)
other.
How "same type" is interpreted varies from subclass to subclass. For instance,
a comment matches any other comment no matter what text they contain,
but a string only matches a string if they are equal.
A tag with attributes matches another tag with the same name and attribute names,
even if the values of the attributes are not the same.
This method is used by scanners and tokens looking for a specific class of
XToken.
- Parameters:
token - XToken to be compared.
- Returns:
- true if the receiver equals
other.- See Also:
equals(org.openadaptor.simplexml.XToken)
public abstract boolean equals(XToken other)
other.
This method will be used by scanners and parsers looking for exact matches
of e.g. comments, runs of text or tags.
- Parameters:
other - XToken to be compared.
- Returns:
- true if the receiver equals
other.- See Also:
matches(org.openadaptor.simplexml.XToken)
public void setReleased(boolean flag)
setReleased in interface ReusableObjectpublic boolean isReleased()
isReleased in interface ReusableObject
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||