public class XmlParser
extends AbstractParser
RSyntaxTextArea.
Like all RSTA Parsers, an XmlParser instance is
notified when the RSTA's text content changes. After a small delay, it will
parse the content as XML, building an AST and looking for any errors. When
parsing is complete, a property change event of type PROPERTY_AST
is fired. Listeners can check the new value of the property for an
XmlTreeNode that represents the root of a tree structure modeling
the XML content in the text area. Note that the XmlTreeNode
may be incomplete if there were parsing/syntax errors (it will usually be
complete "up to" the error in the content).
This parser cannot be shared amongst multiple instances of
RSyntaxTextArea.
| Modifier and Type | Class and Description |
|---|---|
class |
XmlParser.Handler
Callback for events when we're parsing the XML in the editor.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTY_AST
The property change event that's fired when the document is re-parsed.
|
| Constructor and Description |
|---|
XmlParser(XmlLanguageSupport xls) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
Adds a listener to this parser.
|
XmlTreeNode |
getAst()
Returns the XML model from the last time it was parsed.
|
javax.xml.parsers.SAXParserFactory |
getSaxParserFactory() |
ParseResult |
parse(RSyntaxDocument doc,
java.lang.String style) |
void |
removePropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
Removes a listener on a specific property.
|
void |
setValidationConfig(ValidationConfig config)
Sets how validation will be done by this parser.
|
public static final java.lang.String PROPERTY_AST
XmlTreeNode
representing the root of a tree modeling the XML content. The "old
value" is always null.public XmlParser(XmlLanguageSupport xls)
public void addPropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
PROPERTY_AST property.prop - The property to listen for changes on.l - The listener itself.removePropertyChangeListener(String, PropertyChangeListener)public XmlTreeNode getAst()
null if it has
not yet been parsed or an error occurred while parsing.public javax.xml.parsers.SAXParserFactory getSaxParserFactory()
public ParseResult parse(RSyntaxDocument doc,
java.lang.String style)
public void removePropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
prop - The property being listened to.l - The listener to remove.addPropertyChangeListener(String, PropertyChangeListener)public void setValidationConfig(ValidationConfig config)
config - Configuration information for validation. If this is
null, no validation will be done.