com.clarkparsia.pellet.datatypes
Class DatatypeReasonerImpl

java.lang.Object
  extended by com.clarkparsia.pellet.datatypes.DatatypeReasonerImpl
All Implemented Interfaces:
DatatypeReasoner

public class DatatypeReasonerImpl
extends java.lang.Object
implements DatatypeReasoner

Title: Datatype Reasoner Implementation

Description: Default implementation of interface DatatypeReasoner

Copyright: Copyright (c) 2009

Company: Clark & Parsia, LLC.

Author:
Mike Smith

Constructor Summary
DatatypeReasonerImpl()
           
 
Method Summary
 boolean containsAtLeast(int n, java.util.Collection<aterm.ATermAppl> ranges)
          Check that the intersection of a collection of data ranges contains a minimum number of elements.
 boolean declare(aterm.ATermAppl name)
          Declare a named datatype.
 boolean define(aterm.ATermAppl name, aterm.ATermAppl datarange)
          Name a data range (see OWL 2 DatatypeDefinition)
 aterm.ATermAppl getCanonicalRepresentation(aterm.ATermAppl literal)
          Get the canonical representation of a literal.
 Datatype<?> getDatatype(aterm.ATermAppl uri)
          Get the datatype identified by a uri
 aterm.ATermAppl getDefinition(aterm.ATermAppl name)
          Returns the definition for the given datatype name if it is defined, or null otherwise.
 aterm.ATermAppl getLiteral(java.lang.Object value)
          Get the canonical ATermAppl literal representation for a value space object
 java.lang.Object getValue(aterm.ATermAppl literal)
          Get the Java object representation of the data value.
 boolean isDeclared(aterm.ATermAppl name)
          Check if a specific datatype or named data range has been declared.
 boolean isDefined(aterm.ATermAppl name)
          Check if a specific datatype or named data range can be supported by the datatype reasoner.
 boolean isSatisfiable(java.util.Collection<aterm.ATermAppl> dataranges)
          Shorthand for DatatypeReasoner.isSatisfiable(Collection, Object) where value == null.
 boolean isSatisfiable(java.util.Collection<aterm.ATermAppl> dataranges, java.lang.Object value)
          Check the data ranges on a single literal node are satisfiable (independent of other nodes).
 boolean isSatisfiable(java.util.Set<Literal> nodes, java.util.Map<Literal,java.util.Set<Literal>> neqs)
          Check that the data ranges and inequalities asserted on a collection of literal nodes are satisfiable.
 java.util.Collection<aterm.ATermAppl> listDataRanges()
          Return a collection of all known data ranges.
 boolean validLiteral(aterm.ATermAppl typedLiteral)
          Check if a typed literal is valid (i.e., it is in the lexical space for its datatype)
 java.util.Iterator<?> valueIterator(java.util.Collection<aterm.ATermAppl> dataranges)
          Get an iterator for the values of a finite datarange
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatatypeReasonerImpl

public DatatypeReasonerImpl()
Method Detail

containsAtLeast

public boolean containsAtLeast(int n,
                               java.util.Collection<aterm.ATermAppl> ranges)
                        throws UnrecognizedDatatypeException,
                               InvalidConstrainingFacetException,
                               InvalidLiteralException
Description copied from interface: DatatypeReasoner
Check that the intersection of a collection of data ranges contains a minimum number of elements.

Specified by:
containsAtLeast in interface DatatypeReasoner
Parameters:
n - the minimum number of elements
ranges - the data ranges to intersect
Returns:
true if the intersection of ranges contains at least n elements, false else
Throws:
UnrecognizedDatatypeException
InvalidConstrainingFacetException
InvalidLiteralException

declare

public boolean declare(aterm.ATermAppl name)
Description copied from interface: DatatypeReasoner
Declare a named datatype. See DatatypeReasoner.isDeclared(ATermAppl).

Specified by:
declare in interface DatatypeReasoner
Parameters:
name - the name (normally URI) of the datatype
Returns:
true if name has not been previously declared, false else.

getCanonicalRepresentation

public aterm.ATermAppl getCanonicalRepresentation(aterm.ATermAppl literal)
                                           throws InvalidLiteralException,
                                                  UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Get the canonical representation of a literal. There is a 1:1 mapping from elements in a datatype value space and the canonical representations.

Specified by:
getCanonicalRepresentation in interface DatatypeReasoner
Parameters:
literal - the literal to canonicalize
Returns:
the canonical form of the literal
Throws:
InvalidLiteralException - if the literal is not in the lexical space of the datatype
UnrecognizedDatatypeException - if the datatype is not recognized

getDatatype

public Datatype<?> getDatatype(aterm.ATermAppl uri)
Description copied from interface: DatatypeReasoner
Get the datatype identified by a uri

Specified by:
getDatatype in interface DatatypeReasoner
Parameters:
uri - the datatype identifier (e.g., xsd:integer)
Returns:
the Datatype if uri is recognized, null otherwise

getLiteral

public aterm.ATermAppl getLiteral(java.lang.Object value)
Description copied from interface: DatatypeReasoner
Get the canonical ATermAppl literal representation for a value space object

Specified by:
getLiteral in interface DatatypeReasoner
Parameters:
value - Element of the value space for some datatype
Returns:
The ATermAppl representation of value

getValue

public java.lang.Object getValue(aterm.ATermAppl literal)
                          throws InvalidLiteralException,
                                 UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Get the Java object representation of the data value. E.g., if the literal passed in represents "1"^^xsd:byte, then the object returned is a java.lang.Byte.

Specified by:
getValue in interface DatatypeReasoner
Returns:
Java object representation of literal
Throws:
InvalidLiteralException - if the literal is not in the lexical space of the datatype
UnrecognizedDatatypeException - if the datatype is not recognized

isDeclared

public boolean isDeclared(aterm.ATermAppl name)
Description copied from interface: DatatypeReasoner
Check if a specific datatype or named data range has been declared. Declaratations can happen by

isDefined

public boolean isDefined(aterm.ATermAppl name)
Description copied from interface: DatatypeReasoner
Check if a specific datatype or named data range can be supported by the datatype reasoner. I.e., it is either built-in or was the name parameter of a call DatatypeReasoner.define(ATermAppl, ATermAppl)

Specified by:
isDefined in interface DatatypeReasoner
Parameters:
name - the name (normally URI) of the datatype or named data range
Returns:
true if name is supported, false else

getDefinition

public aterm.ATermAppl getDefinition(aterm.ATermAppl name)
Description copied from interface: DatatypeReasoner
Returns the definition for the given datatype name if it is defined, or null otherwise.

Specified by:
getDefinition in interface DatatypeReasoner
Parameters:
name - the name of the datatype
Returns:
the definition for the given datatype name if it is defined, or null otherwise.

isSatisfiable

public boolean isSatisfiable(java.util.Collection<aterm.ATermAppl> dataranges)
                      throws InvalidConstrainingFacetException,
                             InvalidLiteralException,
                             UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Shorthand for DatatypeReasoner.isSatisfiable(Collection, Object) where value == null.

Specified by:
isSatisfiable in interface DatatypeReasoner
Parameters:
dataranges - The data ranges on the literal node
Returns:
true if the conjunction of the data ranges is satisfiable, false else.
Throws:
InvalidConstrainingFacetException
InvalidLiteralException
UnrecognizedDatatypeException

isSatisfiable

public boolean isSatisfiable(java.util.Collection<aterm.ATermAppl> dataranges,
                             java.lang.Object value)
                      throws InvalidConstrainingFacetException,
                             InvalidLiteralException,
                             UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Check the data ranges on a single literal node are satisfiable (independent of other nodes).

Specified by:
isSatisfiable in interface DatatypeReasoner
value - A constant value asserted for the node or null if no such value is present.
Returns:
true if the conjunction of the data ranges is satisfiable, false else.
Throws:
InvalidConstrainingFacetException
InvalidLiteralException
UnrecognizedDatatypeException

isSatisfiable

public boolean isSatisfiable(java.util.Set<Literal> nodes,
                             java.util.Map<Literal,java.util.Set<Literal>> neqs)
                      throws InvalidConstrainingFacetException,
                             InvalidLiteralException,
                             UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Check that the data ranges and inequalities asserted on a collection of literal nodes are satisfiable.

Specified by:
isSatisfiable in interface DatatypeReasoner
Parameters:
nodes - A set representing all literals with in-edges from a single individual
neqs - A map representing all literal inequality constraints
Returns:
true if the data ranges and inequalities are satisfiable, false else.
Throws:
InvalidConstrainingFacetException
InvalidLiteralException
UnrecognizedDatatypeException

define

public boolean define(aterm.ATermAppl name,
                      aterm.ATermAppl datarange)
Description copied from interface: DatatypeReasoner
Name a data range (see OWL 2 DatatypeDefinition)

Specified by:
define in interface DatatypeReasoner
Parameters:
name - a URI used to refer to the datatype
datarange - the datarange
Returns:
true if successful, false if name is already used

listDataRanges

public java.util.Collection<aterm.ATermAppl> listDataRanges()
Description copied from interface: DatatypeReasoner
Return a collection of all known data ranges.

Specified by:
listDataRanges in interface DatatypeReasoner

validLiteral

public boolean validLiteral(aterm.ATermAppl typedLiteral)
                     throws UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Check if a typed literal is valid (i.e., it is in the lexical space for its datatype)

Specified by:
validLiteral in interface DatatypeReasoner
Returns:
true if the literal is in the lexical space of the datatype, falseelse
Throws:
UnrecognizedDatatypeException

valueIterator

public java.util.Iterator<?> valueIterator(java.util.Collection<aterm.ATermAppl> dataranges)
                                    throws InvalidConstrainingFacetException,
                                           InvalidLiteralException,
                                           UnrecognizedDatatypeException
Description copied from interface: DatatypeReasoner
Get an iterator for the values of a finite datarange

Specified by:
valueIterator in interface DatatypeReasoner
Parameters:
dataranges - the data ranges
Returns:
an Iterator
Throws:
InvalidConstrainingFacetException - if dataranges contains a datatype restriction in which the constraining facet is not valid
InvalidLiteralException - if dataranges references a literal value that is invalid
UnrecognizedDatatypeException - if dataranges references an unrecognized datatype


Copyright © 2004 Evren Sirin. All Rights Reserved.