org.alicebot.server.core.parser
Class AIMLReader

java.lang.Object
  extended by org.alicebot.server.core.parser.GenericReader
      extended by org.alicebot.server.core.parser.AIMLReader

public class AIMLReader
extends GenericReader

AIMLReader reads an AIML file, searching for topic, category, pattern, pattern-side that and template elements. The expected occurence of these elements is described in GenericReader.read(), which is the main method of this class. If the elements occur in the correct sequence/structure, their contents are delivered to the newCategory method of whatever AIMLReaderListener is assigned to this AIMLReader.

This version is a refactoring of Kris Drent's original parser (including changes made by Thomas Ringate and Pedro Colla).

Kris Drent originally wrote, "Yes, I know.... It isn't very elegant, it isn't an extensible XML parser. It's a brute force AIML parser. That's what it was designed to be."

Version:
4.1.3
Author:
Kris Drent, Thomas Ringate, Pedro Colla, Noel Bush
See Also:
AIMLReaderListener

Nested Class Summary
 
Nested classes/interfaces inherited from class org.alicebot.server.core.parser.GenericReader
GenericReader.TransitionMade
 
Field Summary
protected  java.lang.String pattern
          The most recently collected <pattern></pattern> contents.
protected  java.lang.reflect.Field patternField
          A reference to pattern.
protected  java.lang.String template
          The most recently collected <template></template> contents.
protected  java.lang.reflect.Field templateField
          A reference to template.
protected  java.lang.String that
          The most recently collected <that></that> contents.
protected  java.lang.reflect.Field thatField
          A reference to that.
protected  java.lang.String topic
          The most recently collected <topic></topic> contents.
protected  java.lang.reflect.Field topicField
          A reference to topic.
 
Fields inherited from class org.alicebot.server.core.parser.GenericReader
ASTERISK, buffer, bufferStartCapacity, bufferString, buffReader, byteCount, COLON, COMMENT_MARK, done, EMPTY_STRING, encoding, fileName, LINE_SEPARATOR, lineNumber, listener, MARKER_END, MARKER_START, QUOTE_MARK, readerInstance, searching, searchStart, SLASH, SPACE, state, tagLength, tagStart, TRANSITION_MADE
 
Constructor Summary
AIMLReader(java.lang.String fileName, java.io.BufferedReader buffReader, AIMLReaderListener readerListener, boolean warnNonAIML)
          Constructs a new AIMLReader, given a BufferedReader handle to some input stream (buffReader), a filename to use in printing error messages (fileName), and an AIMLReaderListener that will handle creation of new categories as they are discovered.
 
Method Summary
protected  void initialize()
           
protected  void tryStates()
           
 
Methods inherited from class org.alicebot.server.core.parser.GenericReader
read, succeed, transition, transition, transition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pattern

protected java.lang.String pattern
The most recently collected <pattern></pattern> contents.


patternField

protected java.lang.reflect.Field patternField
A reference to pattern.


that

protected java.lang.String that
The most recently collected <that></that> contents.


thatField

protected java.lang.reflect.Field thatField
A reference to that.


topic

protected java.lang.String topic
The most recently collected <topic></topic> contents.


topicField

protected java.lang.reflect.Field topicField
A reference to topic.


template

protected java.lang.String template
The most recently collected <template></template> contents.


templateField

protected java.lang.reflect.Field templateField
A reference to template.

Constructor Detail

AIMLReader

public AIMLReader(java.lang.String fileName,
                  java.io.BufferedReader buffReader,
                  AIMLReaderListener readerListener,
                  boolean warnNonAIML)
Constructs a new AIMLReader, given a BufferedReader handle to some input stream (buffReader), a filename to use in printing error messages (fileName), and an AIMLReaderListener that will handle creation of new categories as they are discovered.

Parameters:
fileName - name of the AIML file to be read
buffReader - a BufferedReader already open to the file (could be remote)
readerListener - will handle new categories
warnNonAIML - whether to warn about non-AIML elements directly beneath <aiml>
See Also:
AIMLReaderListener
Method Detail

initialize

protected void initialize()
Specified by:
initialize in class GenericReader

tryStates

protected void tryStates()
                  throws GenericReader.TransitionMade
Specified by:
tryStates in class GenericReader
Throws:
GenericReader.TransitionMade