ai.krr.propositions
Class XplSentenceAdaptor

java.lang.Object
  extended by inf.compilers.XmlAdaptor<Sentence>
      extended by ai.krr.propositions.XplSentenceAdaptor
All Implemented Interfaces:
inf.compilers.SyntaxAdaptor<Sentence>

public class XplSentenceAdaptor
extends inf.compilers.XmlAdaptor<Sentence>

This class is an adaptor between the ai.krr.propositions.Sentence class that can be used as an internal representation for reasoning and its external form in an XML Syntax. The XMLSchema defining the XPL format ....

Writing

Reading

property possible values default
case-sensitive true, false true

Author:
Gerhard Wickler

Field Summary
 
Fields inherited from class inf.compilers.XmlAdaptor
indentStr, props
 
Constructor Summary
XplSentenceAdaptor()
           This constructor creates a SyntaxAdaptor that can be used to read statements in an XML syntax for propositional logic (XPL) and create a propositional Sentence for it, or it can be used to write out a propositional Sentence in XPL syntax.
 
Method Summary
protected  XplSentenceAdaptor clone()
           This function returns a copy of this SyntaxAdaptor that contains a (shallow) copy of the properties.
protected  org.w3c.dom.Element generateAtomNode(org.w3c.dom.Document doc, Atom atom, java.util.Set<NameSpace> nss)
           
protected  org.w3c.dom.Element generateConnectedSentenceNode(org.w3c.dom.Document doc, ConnectedSentence stmt, java.util.Set<NameSpace> nss)
           
protected  org.w3c.dom.Element generateLiteralNode(org.w3c.dom.Document doc, Literal lit, java.util.Set<NameSpace> nss)
           
protected  org.w3c.dom.Element generateNegatedSentenceNode(org.w3c.dom.Document doc, NegatedSentence stmt, java.util.Set<NameSpace> nss)
           
 org.w3c.dom.Element generateNodeTree(org.w3c.dom.Document doc, Sentence content)
           This function generates an Element Node that is the root for the given content.
 org.w3c.dom.Element generateSentenceNode(org.w3c.dom.Document doc, Sentence content, java.util.Set<NameSpace> nss)
           This function generates an Element Node that is the root for the given content.
protected  org.w3c.dom.Element generateTruthValueNode(org.w3c.dom.Document doc, TruthValue tValue, java.util.Set<NameSpace> nss)
           
 java.lang.Class<Sentence> getInternalClass()
           This function returns the Class that holds the internal representation this adaptor translates to and from.
 java.lang.String getSyntaxName()
           This function returns the name that should identify the syntactical language that this adaptor translates to and from.
protected  Atom parseAtom(org.w3c.dom.Element node, java.util.Map<java.lang.String,NameSpace> proxies)
           
protected  ConnectedSentence parseConnectedSentence(org.w3c.dom.Element node, java.util.Map<java.lang.String,NameSpace> proxies)
           
protected  Literal parseLiteral(org.w3c.dom.Element node, java.util.Map<java.lang.String,NameSpace> proxies)
           
protected  NegatedSentence parseNegatedSentence(org.w3c.dom.Element node, java.util.Map<java.lang.String,NameSpace> proxies)
           
 Sentence parseNodeTree(org.w3c.dom.Element root)
           This function takes a DOM Document and generates an internal representation of the statement in the representation R that represents the content of the given Document.
protected  Sentence parseSentence(org.w3c.dom.Element node, java.util.Map<java.lang.String,NameSpace> proxies)
           
protected  TruthValue parseTruthValue(org.w3c.dom.Element node)
           
 
Methods inherited from class inf.compilers.XmlAdaptor
addContentText, generateContentNodeTree, generateDocument, getContentText, getProperty, parseContentNodeTree, parseDocument, prettyPrint, read, setProperty, setSyntaxAdaptors, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XplSentenceAdaptor

public XplSentenceAdaptor()

This constructor creates a SyntaxAdaptor that can be used to read statements in an XML syntax for propositional logic (XPL) and create a propositional Sentence for it, or it can be used to write out a propositional Sentence in XPL syntax. The given properties must not be null.

Method Detail

clone

protected XplSentenceAdaptor clone()

This function returns a copy of this SyntaxAdaptor that contains a (shallow) copy of the properties.

Overrides:
clone in class java.lang.Object
Returns:
a copy of this SyntaxAdaptor

getInternalClass

public java.lang.Class<Sentence> getInternalClass()

This function returns the Class that holds the internal representation this adaptor translates to and from.

Returns:
the internal representation Class adapted to

getSyntaxName

public java.lang.String getSyntaxName()

This function returns the name that should identify the syntactical language that this adaptor translates to and from.

Returns:
the name of the language adapted to

parseNodeTree

public Sentence parseNodeTree(org.w3c.dom.Element root)
                       throws inf.compilers.ExpressivenessException,
                              java.text.ParseException

This function takes a DOM Document and generates an internal representation of the statement in the representation R that represents the content of the given Document. No validation will be performed here.

Specified by:
parseNodeTree in class inf.compilers.XmlAdaptor<Sentence>
Parameters:
root - the root Element of the Document to be transformed here
Returns:
the internal representation of that Document in the representation R
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException

generateNodeTree

public org.w3c.dom.Element generateNodeTree(org.w3c.dom.Document doc,
                                            Sentence content)
                                     throws inf.compilers.ExpressivenessException

This function generates an Element Node that is the root for the given content. The way it is generated depends on the type of sentence this is.

Specified by:
generateNodeTree in class inf.compilers.XmlAdaptor<Sentence>
Parameters:
doc - the Document to which the Node will belong
content - a statement in the internal representation language
Throws:
inf.compilers.ExpressivenessException - if the XML cannot represent the given statement

generateSentenceNode

public org.w3c.dom.Element generateSentenceNode(org.w3c.dom.Document doc,
                                                Sentence content,
                                                java.util.Set<NameSpace> nss)
                                         throws inf.compilers.ExpressivenessException

This function generates an Element Node that is the root for the given content. The way it is generated depends on the type of sentence this is.

Parameters:
doc - the Document to which the Node will belong
content - a statement in the internal representation language
nss - the set of all NameSpaces used in the given Sentence
Throws:
inf.compilers.ExpressivenessException - if any contained NamedSymbol is internal

generateConnectedSentenceNode

protected org.w3c.dom.Element generateConnectedSentenceNode(org.w3c.dom.Document doc,
                                                            ConnectedSentence stmt,
                                                            java.util.Set<NameSpace> nss)
                                                     throws inf.compilers.ExpressivenessException
Throws:
inf.compilers.ExpressivenessException

generateNegatedSentenceNode

protected org.w3c.dom.Element generateNegatedSentenceNode(org.w3c.dom.Document doc,
                                                          NegatedSentence stmt,
                                                          java.util.Set<NameSpace> nss)
                                                   throws inf.compilers.ExpressivenessException
Throws:
inf.compilers.ExpressivenessException

generateLiteralNode

protected org.w3c.dom.Element generateLiteralNode(org.w3c.dom.Document doc,
                                                  Literal lit,
                                                  java.util.Set<NameSpace> nss)
                                           throws inf.compilers.ExpressivenessException
Throws:
inf.compilers.ExpressivenessException

generateAtomNode

protected org.w3c.dom.Element generateAtomNode(org.w3c.dom.Document doc,
                                               Atom atom,
                                               java.util.Set<NameSpace> nss)
                                        throws inf.compilers.ExpressivenessException
Throws:
inf.compilers.ExpressivenessException

generateTruthValueNode

protected org.w3c.dom.Element generateTruthValueNode(org.w3c.dom.Document doc,
                                                     TruthValue tValue,
                                                     java.util.Set<NameSpace> nss)
                                              throws inf.compilers.ExpressivenessException
Throws:
inf.compilers.ExpressivenessException

parseSentence

protected Sentence parseSentence(org.w3c.dom.Element node,
                                 java.util.Map<java.lang.String,NameSpace> proxies)
                          throws java.text.ParseException
Throws:
java.text.ParseException

parseTruthValue

protected TruthValue parseTruthValue(org.w3c.dom.Element node)

parseAtom

protected Atom parseAtom(org.w3c.dom.Element node,
                         java.util.Map<java.lang.String,NameSpace> proxies)
                  throws java.text.ParseException
Throws:
java.text.ParseException

parseLiteral

protected Literal parseLiteral(org.w3c.dom.Element node,
                               java.util.Map<java.lang.String,NameSpace> proxies)
                        throws java.text.ParseException
Throws:
java.text.ParseException

parseNegatedSentence

protected NegatedSentence parseNegatedSentence(org.w3c.dom.Element node,
                                               java.util.Map<java.lang.String,NameSpace> proxies)
                                        throws java.text.ParseException
Throws:
java.text.ParseException

parseConnectedSentence

protected ConnectedSentence parseConnectedSentence(org.w3c.dom.Element node,
                                                   java.util.Map<java.lang.String,NameSpace> proxies)
                                            throws java.text.ParseException
Throws:
java.text.ParseException