org.aitools.programd.parser
Class TemplateParser

java.lang.Object
  extended by org.aitools.programd.parser.GenericParser<AIMLProcessor>
      extended by org.aitools.programd.parser.TemplateParser

public class TemplateParser
extends GenericParser<AIMLProcessor>

TemplateParser has been rewritten (starting in 4.5) to use DOM for parsing. It also eliminates handling of "deprecated AIML" (this will be possible to handle again later with an extensible version of D).


Field Summary
private  java.lang.String botid
          The botid on whose behalf this parser is working.
private  java.util.ArrayList<java.lang.String> inputs
          The input that matched the pattern associated with this template (helps to avoid endless loops).
private  java.util.ArrayList<java.lang.String> inputStars
          The values captured from the input by wildcards in the pattern.
private  java.util.ArrayList<java.lang.String> thatStars
          The values captured from the input path by wildcards in the that.
private  java.util.ArrayList<java.lang.String> topicStars
          The values captured from the input path by wildcards in the topic.
private  java.lang.String userid
          The userid for which this parser is used.
 
Fields inherited from class org.aitools.programd.parser.GenericParser
COMMA, core, docURL, EMPTY_STRING, INDEX, logger, utilDocBuilder
 
Constructor Summary
TemplateParser(java.lang.String input, java.lang.String useridToUse, java.lang.String botidToUse, Core coreToUse)
          Initializes an TemplateParser.
 
Method Summary
 void addInput(java.lang.String input)
          Adds an input to the inputs list (for avoiding infinite loops).
 java.lang.String getBotID()
           
 java.util.ArrayList<java.lang.String> getInputs()
          Returns the input that matched the pattern associated with this template.
 java.util.ArrayList<java.lang.String> getInputStars()
          Returns the values captured from the input path by wildcards in the pattern.
 java.util.ArrayList<java.lang.String> getThatStars()
          Returns the the values captured from the input path by wildcards in the that.
 java.util.ArrayList<java.lang.String> getTopicStars()
          Returns the values captured from the input path by wildcards in the topic name.
 java.lang.String getUserID()
           
 java.lang.String processResponse(java.lang.String templateContent)
          Processes an XML fragment provided in a string.
 java.lang.String processTag(org.w3c.dom.Element element)
          Processes the AIML within and including a given AIML element.
 void setInputStars(java.util.ArrayList<java.lang.String> stars)
          Sets the inputStars list.
 void setThatStars(java.util.ArrayList<java.lang.String> stars)
          Sets the thatStars list.
 void setTopicStars(java.util.ArrayList<java.lang.String> stars)
          Sets the topicStars Vector.
 
Methods inherited from class org.aitools.programd.parser.GenericParser
evaluate, evaluate, evaluate, getCore, getCurrentDocURL, getValid1dIndex, getValid2dIndex, handleUnknownElement, process, processElement, processResponse, shortcutTag, verifyAndProcess, verifyAndProcess, verifyAndProcessResponse, verifyAndProcessResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStars

private java.util.ArrayList<java.lang.String> inputStars
The values captured from the input by wildcards in the pattern.


thatStars

private java.util.ArrayList<java.lang.String> thatStars
The values captured from the input path by wildcards in the that.


topicStars

private java.util.ArrayList<java.lang.String> topicStars
The values captured from the input path by wildcards in the topic.


inputs

private java.util.ArrayList<java.lang.String> inputs
The input that matched the pattern associated with this template (helps to avoid endless loops).


userid

private java.lang.String userid
The userid for which this parser is used.


botid

private java.lang.String botid
The botid on whose behalf this parser is working.

Constructor Detail

TemplateParser

public TemplateParser(java.lang.String input,
                      java.lang.String useridToUse,
                      java.lang.String botidToUse,
                      Core coreToUse)
               throws TemplateParserException
Initializes an TemplateParser. The input is a required parameter!

Parameters:
input - the input that matched the pattern associated with this template (helps to avoid endless loops)
useridToUse - the userid for whom the template is being parsed
botidToUse - the botid for whom the template is being parsed
coreToUse - the Core in use
Throws:
TemplateParserException - if the input is null
Method Detail

processTag

public java.lang.String processTag(org.w3c.dom.Element element)
                            throws ProcessorException
Processes the AIML within and including a given AIML element.

Parameters:
element - the elment to process
Returns:
the result of processing the tag
Throws:
ProcessorException - if the AIML cannot be processed

processResponse

public java.lang.String processResponse(java.lang.String templateContent)
                                 throws ProcessorException
Description copied from class: GenericParser
Processes an XML fragment provided in a string.

Overrides:
processResponse in class GenericParser<AIMLProcessor>
Parameters:
templateContent - the string from which to create the document fragment
Returns:
the result of processing the document fragment created from the given string
Throws:
ProcessorException - if there was a problem processing the document fragment created from the given string
See Also:
GenericParser.processResponse(java.lang.String)

addInput

public void addInput(java.lang.String input)
Adds an input to the inputs list (for avoiding infinite loops).

Parameters:
input - the input to add

getInputs

public java.util.ArrayList<java.lang.String> getInputs()
Returns the input that matched the pattern associated with this template.

Returns:
the input that matched the pattern associated with this template

getInputStars

public java.util.ArrayList<java.lang.String> getInputStars()
Returns the values captured from the input path by wildcards in the pattern.

Returns:
the values captured from the input path by wildcards in the pattern

getThatStars

public java.util.ArrayList<java.lang.String> getThatStars()
Returns the the values captured from the input path by wildcards in the that.

Returns:
the values captured from the input path by wildcards in the that

getTopicStars

public java.util.ArrayList<java.lang.String> getTopicStars()
Returns the values captured from the input path by wildcards in the topic name.

Returns:
the values captured from the input path by wildcards in the topic name

setInputStars

public void setInputStars(java.util.ArrayList<java.lang.String> stars)
Sets the inputStars list.

Parameters:
stars - values captured from the input path by wildcards in the pattern

setThatStars

public void setThatStars(java.util.ArrayList<java.lang.String> stars)
Sets the thatStars list.

Parameters:
stars - values captured from the input path by wildcards in the that

setTopicStars

public void setTopicStars(java.util.ArrayList<java.lang.String> stars)
Sets the topicStars Vector.

Parameters:
stars - captured from the input path by wildcards in the topic name

getUserID

public java.lang.String getUserID()
Returns:
the userid

getBotID

public java.lang.String getBotID()
Returns:
the botid