org.aitools.programd.parser
Class AIMLReader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.xml.sax.ext.DefaultHandler2
          extended by org.aitools.programd.parser.AIMLReader
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.EntityResolver2, org.xml.sax.ext.LexicalHandler

public class AIMLReader
extends org.xml.sax.ext.DefaultHandler2

This reads in standard AIML and delivers categories to the Graphmaster.

This has been rewritten starting with 4.2 to use SAX.

Author:
Noel Bush

Field Summary
private  Bot bot
           
private static java.lang.String BOT
          The string ""bot"".
private  java.lang.String botid
           
private  java.lang.StringBuilder currentBuffer
          A pointer to the current buffer.
private  java.lang.String defaultNamespaceURI
           
private static java.lang.String EMPTY_STRING
          An empty string.
private  Graphmaster graphmaster
           
protected static java.lang.String LINE_SEPARATOR
          The system line separator.
private static java.lang.String MARKER_END
          The end of a tag marker.
private static java.lang.String MARKER_START
          The start of a tag marker.
private static java.lang.String NAME
          The string ""name"".
private static java.lang.String OPEN_TEMPLATE_START_TAG
           
private  java.net.URL path
           
private  java.lang.String pattern
          The finalized <pattern></pattern> contents.
private static java.lang.String PATTERN
          The string ""pattern"".
private  java.lang.StringBuilder patternBuffer
          The most recently collected <pattern></pattern> contents.
private static java.lang.String QUOTE_MARKER_END
           
private static java.lang.String SLASH
          A slash.
private  java.lang.String template
          The finalized <template></template> contents.
private static java.lang.String TEMPLATE
          The string ""template"".
private static java.lang.String TEMPLATE_END_TAG
          End of a template element.
private  java.lang.StringBuilder templateBuffer
          The most recently collected <template></template> contents.
private  java.lang.String templateStartTag
          The start of a template element.
private  java.lang.String that
          The finalized <that></that> contents.
private static java.lang.String THAT
          The string ""that"".
private  java.lang.StringBuilder thatBuffer
          The most recently collected <that></that> contents.
private  java.lang.String topic
          The finalized <topic></topic> contents.
private static java.lang.String TOPIC
          The string ""topic"".
private static java.lang.String WILDCARD
          The wildcard ("*").
 
Constructor Summary
AIMLReader(Graphmaster graphmasterToUse, java.net.URL url, java.lang.String botidToUse, Bot botToUse, java.lang.String defaultNamespaceURIToUse)
          Creates a new AIMLReader.
 
Method Summary
 void endCDATA()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void error(org.xml.sax.SAXParseException e)
           
 void characters(char[] ch, int start, int length)
           
 void startCDATA()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 
Methods inherited from class org.xml.sax.ext.DefaultHandler2
attributeDecl, comment, elementDecl, endDTD, endEntity, externalEntityDecl, getExternalSubset, internalEntityDecl, resolveEntity, resolveEntity, startDTD, startEntity
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultNamespaceURI

private java.lang.String defaultNamespaceURI

graphmaster

private Graphmaster graphmaster

path

private java.net.URL path

botid

private java.lang.String botid

bot

private Bot bot

MARKER_START

private static final java.lang.String MARKER_START
The start of a tag marker.

See Also:
Constant Field Values

MARKER_END

private static final java.lang.String MARKER_END
The end of a tag marker.

See Also:
Constant Field Values

EMPTY_STRING

private static final java.lang.String EMPTY_STRING
An empty string.

See Also:
Constant Field Values

OPEN_TEMPLATE_START_TAG

private static final java.lang.String OPEN_TEMPLATE_START_TAG
See Also:
Constant Field Values

QUOTE_MARKER_END

private static final java.lang.String QUOTE_MARKER_END
See Also:
Constant Field Values

SLASH

private static final java.lang.String SLASH
A slash.

See Also:
Constant Field Values

TEMPLATE_END_TAG

private static final java.lang.String TEMPLATE_END_TAG
End of a template element.

See Also:
Constant Field Values

LINE_SEPARATOR

protected static final java.lang.String LINE_SEPARATOR
The system line separator.


PATTERN

private static final java.lang.String PATTERN
The string ""pattern"".

See Also:
Constant Field Values

BOT

private static final java.lang.String BOT
The string ""bot"".

See Also:
Constant Field Values

THAT

private static final java.lang.String THAT
The string ""that"".

See Also:
Constant Field Values

TOPIC

private static final java.lang.String TOPIC
The string ""topic"".

See Also:
Constant Field Values

TEMPLATE

private static final java.lang.String TEMPLATE
The string ""template"".

See Also:
Constant Field Values

WILDCARD

private static final java.lang.String WILDCARD
The wildcard ("*").

See Also:
Constant Field Values

NAME

private static final java.lang.String NAME
The string ""name"".

See Also:
Constant Field Values

patternBuffer

private java.lang.StringBuilder patternBuffer
The most recently collected <pattern></pattern> contents.


thatBuffer

private java.lang.StringBuilder thatBuffer
The most recently collected <that></that> contents.


templateBuffer

private java.lang.StringBuilder templateBuffer
The most recently collected <template></template> contents.


currentBuffer

private java.lang.StringBuilder currentBuffer
A pointer to the current buffer.


pattern

private java.lang.String pattern
The finalized <pattern></pattern> contents.


that

private java.lang.String that
The finalized <that></that> contents.


topic

private java.lang.String topic
The finalized <topic></topic> contents.


template

private java.lang.String template
The finalized <template></template> contents.


templateStartTag

private java.lang.String templateStartTag
The start of a template element.

Constructor Detail

AIMLReader

public AIMLReader(Graphmaster graphmasterToUse,
                  java.net.URL url,
                  java.lang.String botidToUse,
                  Bot botToUse,
                  java.lang.String defaultNamespaceURIToUse)
Creates a new AIMLReader.

Parameters:
graphmasterToUse - the graphmaster into which new categories are to be loaded.
url - the path that is being read
botidToUse - the id of the bot into whom categories are being loaded
botToUse - the bot itself
defaultNamespaceURIToUse - the namespace URI to use when none other is specified (?)
Method Detail

characters

public void characters(char[] ch,
                       int start,
                       int length)
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.characters(char[], int, int)

startCDATA

public void startCDATA()
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Overrides:
startCDATA in class org.xml.sax.ext.DefaultHandler2
See Also:
DefaultHandler2.startCDATA()

endCDATA

public void endCDATA()
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Overrides:
endCDATA in class org.xml.sax.ext.DefaultHandler2
See Also:
DefaultHandler2.endCDATA()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

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
See Also:
DefaultHandler.error(org.xml.sax.SAXParseException)