Package org.fife.rsta.ac.xml
Class XmlParser
java.lang.Object
org.fife.ui.rsyntaxtextarea.parser.AbstractParser
org.fife.rsta.ac.xml.XmlParser
- All Implemented Interfaces:
org.fife.ui.rsyntaxtextarea.parser.Parser
public class XmlParser
extends org.fife.ui.rsyntaxtextarea.parser.AbstractParser
Parses XML code in an
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.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassCallback for events when we're parsing the XML in the editor. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XmlTreeNodeprivate intprivate Locatorstatic final StringThe property change event that's fired when the document is re-parsed.private XmlTreeNodeprivate SAXParserprivate SAXParserFactoryprivate PropertyChangeSupportprivate ValidationConfigprivate XmlLanguageSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to this parser.getAst()Returns the XML model from the last time it was parsed.private StringgetMainAttribute(Attributes attributes) Returns a string representing the "main" attribute for an element.org.fife.ui.rsyntaxtextarea.parser.ParseResultvoidRemoves a listener on a specific property.voidsetValidationConfig(ValidationConfig config) Sets how validation will be done by this parser.Methods inherited from class org.fife.ui.rsyntaxtextarea.parser.AbstractParser
getHyperlinkListener, getImageBase, isEnabled, setEnabled, setHyperlinkListener
-
Field Details
-
PROPERTY_AST
The property change event that's fired when the document is re-parsed. Applications can listen for this property change and update themselves accordingly. The property's "new value" will be anXmlTreeNoderepresenting the root of a tree modeling the XML content. The "old value" is alwaysnull.- See Also:
-
xls
-
support
-
curElem
-
root
-
locator
-
spf
-
sp
-
validationConfig
-
elemCount
private int elemCount
-
-
Constructor Details
-
XmlParser
-
-
Method Details
-
addPropertyChangeListener
Adds a listener to this parser. Typically you'd want to register a listener on thePROPERTY_ASTproperty.- Parameters:
prop- The property to listen for changes on.l- The listener itself.- See Also:
-
getAst
Returns the XML model from the last time it was parsed.- Returns:
- The root node of the XML model, or
nullif it has not yet been parsed or an error occurred while parsing.
-
getMainAttribute
Returns a string representing the "main" attribute for an element.- Parameters:
attributes- The attributes of an element. Calling code should have already verified this has length > 0.- Returns:
- The "main" attribute.
-
getSaxParserFactory
-
parse
public org.fife.ui.rsyntaxtextarea.parser.ParseResult parse(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, String style) -
removePropertyChangeListener
Removes a listener on a specific property.- Parameters:
prop- The property being listened to.l- The listener to remove.- See Also:
-
setValidationConfig
Sets how validation will be done by this parser. This can be used to set up either DTD or Schema validation.- Parameters:
config- Configuration information for validation. If this isnull, no validation will be done.
-