org.fife.ui.autocomplete
Class CompletionXMLParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.fife.ui.autocomplete.CompletionXMLParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class CompletionXMLParser
extends org.xml.sax.helpers.DefaultHandler

Parser for an XML file describing a procedural language such as C. XML files will be validated against the CompletionXml.dtd DTD found in this package.

Version:
1.0
Author:
Robert Futrell

Constructor Summary
CompletionXMLParser(CompletionProvider provider)
          Constructor.
CompletionXMLParser(CompletionProvider provider, java.lang.ClassLoader cl)
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Called when character data inside an element is found.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Called when an element is closed.
 void error(org.xml.sax.SAXParseException e)
           
 java.util.List<Completion> getCompletions()
          Returns the completions found after parsing the XML.
 char getParamEndChar()
          Returns the parameter end character specified.
 java.lang.String getParamSeparator()
          Returns the parameter end string specified.
 char getParamStartChar()
          Returns the parameter start character specified.
 void reset(CompletionProvider provider)
          Resets this parser to grab more completions.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicID, java.lang.String systemID)
           
static void setDefaultCompletionClassLoader(java.lang.ClassLoader cl)
          Sets the class loader to use when loading custom classes to use for various Completion types, such as FunctionCompletions, from XML.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Called when an element starts.
 void warning(org.xml.sax.SAXParseException e)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompletionXMLParser

public CompletionXMLParser(CompletionProvider provider)
Constructor.

Parameters:
provider - The provider to get completions for.
See Also:
reset(CompletionProvider)

CompletionXMLParser

public CompletionXMLParser(CompletionProvider provider,
                           java.lang.ClassLoader cl)
Constructor.

Parameters:
provider - The provider to get completions for.
cl - The class loader to use, if necessary, when loading classes from the XML (custom FunctionCompletions, for example). This may be null if the default is to be used, or if the XML does not define specific classes for completion types.
See Also:
reset(CompletionProvider)
Method Detail

characters

public void characters(char[] ch,
                       int start,
                       int length)
Called when character data inside an element is found.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
Called when an element is closed.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

getCompletions

public java.util.List<Completion> getCompletions()
Returns the completions found after parsing the XML.

Returns:
The completions.

getParamEndChar

public char getParamEndChar()
Returns the parameter end character specified.

Returns:
The character, or 0 if none was specified.

getParamSeparator

public java.lang.String getParamSeparator()
Returns the parameter end string specified.

Returns:
The string, or null if none was specified.

getParamStartChar

public char getParamStartChar()
Returns the parameter start character specified.

Returns:
The character, or 0 if none was specified.

reset

public void reset(CompletionProvider provider)
Resets this parser to grab more completions.

Parameters:
provider - The new provider to get completions for.

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicID,
                                             java.lang.String systemID)
                                      throws org.xml.sax.SAXException
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

setDefaultCompletionClassLoader

public static void setDefaultCompletionClassLoader(java.lang.ClassLoader cl)
Sets the class loader to use when loading custom classes to use for various Completion types, such as FunctionCompletions, from XML.

Users should very rarely have a need to use this method.

Parameters:
cl - The class loader to use. If this is null, then a default is used.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
Called when an element starts.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException