org.semwebcentral.sweetrules.sweetonto
Class SweetDLPSerializers

java.lang.Object
  extended byorg.semwebcentral.sweetrules.sweetonto.SweetDLPSerializers

public class SweetDLPSerializers
extends java.lang.Object


Field Summary
private static java.lang.String LINE_BREAK
           
private static java.lang.String OWLX_NAMESPACE_PREFIX
           
private static java.lang.String RULEML_NAMESPACE_PREFIX
           
private static java.lang.String SWEET_DOCTYPE_ENTITYDECLARATION
           
private static java.lang.String SWRL_PROPERTY_ATTRIBUTE
           
private static java.lang.String SWRLX_NAMESPACE_PREFIX
           
 
Constructor Summary
SweetDLPSerializers()
           
 
Method Summary
private static void declareVariables(SweetDLPCompiler compiler, java.io.Writer writer)
          Declares the variables for SWRL
protected static java.lang.String getIndent(int indent)
           
private static java.lang.String getOWLXNamespacePrefixWithSeparator()
           
private static java.lang.String getRuleMLNamespacePrefixWithSeparator()
           
private static java.lang.String getSWRLPropertyAttribute()
           
private static java.lang.String getSWRLXNamespacePrefixWithSeparator()
           
private static java.lang.String getTermTypeTag(Term term, SweetLiteralWrapper literal)
           
private static java.lang.String getVariableNameOrConstantValue(Term term)
           
static void printAsDLV(Program program, MemoryExtensionalDatabase instancesDatabase, java.io.PrintWriter writer)
           
static void printAsRuleML(Program program, java.io.PrintWriter writer)
           
static void printAsXSB(Program program, MemoryExtensionalDatabase instancesDatabase, java.io.PrintWriter writer)
           
protected static void printLiteral(Literal literal, java.io.PrintWriter writer)
           
protected static void printRuleMLLiteral(Literal literal, java.io.PrintWriter writer, int indent)
           
protected static void printTerm(Term term, java.io.PrintWriter writer)
           
static void writeAsRuleML(SweetDLPCompiler compiler, Program program, MemoryExtensionalDatabase instancesDatabase, java.io.Writer writer)
          Method to write the program as RuleML output.
static void writeAsSWRL(SweetDLPCompiler compiler, Program program, MemoryExtensionalDatabase instancesDatabase, java.io.Writer writer)
          This writes the program as SWRL
private static void writeDocTypeDeclarations(java.lang.String docType, java.io.Writer writer)
          Writes the entity declarations for all namespaces currently seen
protected static void writeRuleMLPredicate(Literal literal, java.io.Writer writer, int indent)
          Writes a RuleML literal.
private static void writeSWRLPredicate(SweetLiteralWrapper literal, java.io.Writer writer, int indent)
          Writes a SWRL literal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RULEML_NAMESPACE_PREFIX

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

OWLX_NAMESPACE_PREFIX

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

SWRLX_NAMESPACE_PREFIX

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

LINE_BREAK

private static final java.lang.String LINE_BREAK

SWRL_PROPERTY_ATTRIBUTE

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

SWEET_DOCTYPE_ENTITYDECLARATION

private static final java.lang.String SWEET_DOCTYPE_ENTITYDECLARATION
See Also:
Constant Field Values
Constructor Detail

SweetDLPSerializers

public SweetDLPSerializers()
Method Detail

printAsDLV

public static void printAsDLV(Program program,
                              MemoryExtensionalDatabase instancesDatabase,
                              java.io.PrintWriter writer)
                       throws java.io.IOException
Throws:
java.io.IOException

printAsXSB

public static void printAsXSB(Program program,
                              MemoryExtensionalDatabase instancesDatabase,
                              java.io.PrintWriter writer)
                       throws java.io.IOException
Throws:
java.io.IOException

printLiteral

protected static void printLiteral(Literal literal,
                                   java.io.PrintWriter writer)

printTerm

protected static void printTerm(Term term,
                                java.io.PrintWriter writer)

writeAsSWRL

public static void writeAsSWRL(SweetDLPCompiler compiler,
                               Program program,
                               MemoryExtensionalDatabase instancesDatabase,
                               java.io.Writer writer)
                        throws java.io.IOException,
                               SweetException,
                               SweetDLPCompilerException
This writes the program as SWRL

Parameters:
compiler - The compiler which produced the program (helpful to declare variables)
program - The program to be serialized to SWRL
instancesDatabase - The instance data of the program
writer - The writer to write to
Throws:
java.io.IOException - if an error occurs
SweetDLPCompilerException - if input is not in DLP subset
SweetException

writeDocTypeDeclarations

private static void writeDocTypeDeclarations(java.lang.String docType,
                                             java.io.Writer writer)
                                      throws java.io.IOException
Writes the entity declarations for all namespaces currently seen

Parameters:
docType - The doc type for the declarations
writer - The writer to write to
Throws:
java.io.IOException - if an error occurs

declareVariables

private static void declareVariables(SweetDLPCompiler compiler,
                                     java.io.Writer writer)
                              throws java.io.IOException
Declares the variables for SWRL

Parameters:
compiler - The compiler which produced the program, and has info about the variables used
writer - The writer to write to
Throws:
java.io.IOException

writeSWRLPredicate

private static void writeSWRLPredicate(SweetLiteralWrapper literal,
                                       java.io.Writer writer,
                                       int indent)
                                throws java.io.IOException,
                                       SweetException,
                                       SweetDLPCompilerException
Writes a SWRL literal. This works for literals which have been imported from OWL only due to the fact that there is an assumption that every individual/class has a URI.

Parameters:
literal - The literal to be written
writer - The writer object
indent - Text to pretty print
Throws:
java.io.IOException - if an error occurs
SweetDLPCompilerException - if input is not in DLP subset
SweetException

writeAsRuleML

public static void writeAsRuleML(SweetDLPCompiler compiler,
                                 Program program,
                                 MemoryExtensionalDatabase instancesDatabase,
                                 java.io.Writer writer)
                          throws java.io.IOException,
                                 SweetDLPCompilerException
Method to write the program as RuleML output. This is based on printAsRuleML method

Parameters:
compiler - The compiler which produced the program
program - The program to write
writer - The writer into which the target RuleML is to be written
Throws:
java.io.IOException - if an error occurs
SweetDLPCompilerException - if input is not in DLP subset

printAsRuleML

public static void printAsRuleML(Program program,
                                 java.io.PrintWriter writer)
                          throws java.io.IOException,
                                 SweetDLPCompilerException
Throws:
java.io.IOException
SweetDLPCompilerException

getVariableNameOrConstantValue

private static java.lang.String getVariableNameOrConstantValue(Term term)
                                                        throws SweetException
Throws:
SweetException

getSWRLPropertyAttribute

private static java.lang.String getSWRLPropertyAttribute()

getRuleMLNamespacePrefixWithSeparator

private static java.lang.String getRuleMLNamespacePrefixWithSeparator()

getOWLXNamespacePrefixWithSeparator

private static java.lang.String getOWLXNamespacePrefixWithSeparator()

getSWRLXNamespacePrefixWithSeparator

private static java.lang.String getSWRLXNamespacePrefixWithSeparator()

getTermTypeTag

private static java.lang.String getTermTypeTag(Term term,
                                               SweetLiteralWrapper literal)
                                        throws SweetException
Throws:
SweetException

writeRuleMLPredicate

protected static void writeRuleMLPredicate(Literal literal,
                                           java.io.Writer writer,
                                           int indent)
                                    throws java.io.IOException,
                                           SweetDLPCompilerException
Writes a RuleML literal. This works for literals which have been imported from OWL only due to the fact that there is an assumption that every individual/class has a URI.

Parameters:
literal - The literal to be written
writer - The writer object
indent - Text to pretty print
Throws:
java.io.IOException - if an error occurs
SweetDLPCompilerException - if input is not in DLP subset

printRuleMLLiteral

protected static void printRuleMLLiteral(Literal literal,
                                         java.io.PrintWriter writer,
                                         int indent)
                                  throws java.io.IOException,
                                         SweetDLPCompilerException
Throws:
java.io.IOException
SweetDLPCompilerException

getIndent

protected static java.lang.String getIndent(int indent)