/*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version. You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.aitools.programd.processor.aiml;
import org.aitools.programd.Core;
import org.aitools.programd.parser.GenericParser;
import org.aitools.programd.parser.TemplateParser;
import org.aitools.programd.processor.Processor;
import org.aitools.programd.processor.ProcessorException;
import org.apache.log4j.Logger;
import org.jdom.Element;
/**
* An <code>AIMLProcessor</code> is responsible for processing a particular AIML element.
*
* @author <a href="mailto:noel@aitools.org">Noel Bush</a>
*/
abstract public class AIMLProcessor extends Processor {
protected static final Logger logger = Logger.getLogger("programd");
protected static final Logger aimlLogger = Logger.getLogger("programd.aiml-processing");
/**
* Creates a new AIMLProcessor using the given Core.
*
* @param core the Core object to use with the new AIMLProcessor
*/
public AIMLProcessor(Core core) {
super(core);
}
/**
* @see org.aitools.programd.processor.Processor#process(org.jdom.Element, org.aitools.programd.parser.GenericParser)
*/
@Override
@SuppressWarnings("rawtypes")
public String process(Element element, GenericParser parser) throws ProcessorException {
try {
return this.process(element, (TemplateParser) parser);
}
catch (ClassCastException e) {
throw new ProcessorException("Tried to pass a non-TemplateParser to an AIMLProcessor.", e);
}
}
/**
* Processes the given element, using the given parser if needed.
*
* @param element the element to process
* @param parser the parser that has ordered the processing
* @return the result of processing the element
* @throws ProcessorException if there is an unrecoverable problem processing the element
*/
abstract public String process(Element element, TemplateParser parser) throws ProcessorException;
}