Package openllet.core.datatypes
Class DatatypeReasonerImpl
- java.lang.Object
-
- openllet.core.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
Constructors Constructor Description DatatypeReasonerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsAtLeast(int n, java.util.Collection<openllet.aterm.ATermAppl> ranges)
Check that the intersection of a collection of _data ranges contains a minimum number of elements.boolean
declare(openllet.aterm.ATermAppl name)
Declare a named datatype.boolean
define(openllet.aterm.ATermAppl name, openllet.aterm.ATermAppl datarange)
Name a _data range (see OWL 2DatatypeDefinition
)openllet.aterm.ATermAppl
getCanonicalRepresentation(openllet.aterm.ATermAppl literal)
Get the canonical representation of a literal.Datatype<?>
getDatatype(openllet.aterm.ATermAppl uri)
Get the datatype identified by a uriopenllet.aterm.ATermAppl
getDefinition(openllet.aterm.ATermAppl name)
Returns the definition for the given datatype name if it is defined, ornull
otherwise.openllet.aterm.ATermAppl
getLiteral(java.lang.Object value)
Get the canonicalATermAppl
literal representation for a value space objectjava.lang.Object
getValue(openllet.aterm.ATermAppl literal)
Get the Java object representation of the _data value.boolean
isDeclared(openllet.aterm.ATermAppl name)
Check if a specific datatype or named _data range has been declared.boolean
isDefined(openllet.aterm.ATermAppl name)
Check if a specific datatype or named _data range can be supported by the datatype reasoner.boolean
isSatisfiable(java.util.Collection<openllet.aterm.ATermAppl> dataranges)
Shorthand forDatatypeReasoner.isSatisfiable(Collection, Object)
wherevalue == null
.boolean
isSatisfiable(java.util.Collection<openllet.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<openllet.aterm.ATermAppl>
listDataRanges()
boolean
validLiteral(openllet.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<openllet.aterm.ATermAppl> dataranges)
Get an iterator for the values of a finite datarange
-
-
-
Method Detail
-
containsAtLeast
public boolean containsAtLeast(int n, java.util.Collection<openllet.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 interfaceDatatypeReasoner
- Parameters:
n
- the minimum number of elementsranges
- the _data ranges to intersect- Returns:
true
if the intersection ofranges
contains at leastn
elements,false
else- Throws:
UnrecognizedDatatypeException
InvalidConstrainingFacetException
InvalidLiteralException
-
declare
public boolean declare(openllet.aterm.ATermAppl name)
Description copied from interface:DatatypeReasoner
Declare a named datatype. SeeDatatypeReasoner.isDeclared(ATermAppl)
.- Specified by:
declare
in interfaceDatatypeReasoner
- Parameters:
name
- the name (normally URI) of the datatype- Returns:
true
ifname
has not been previously declared,false
else.
-
getCanonicalRepresentation
public openllet.aterm.ATermAppl getCanonicalRepresentation(openllet.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 interfaceDatatypeReasoner
- 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 datatypeUnrecognizedDatatypeException
- if the datatype is not recognized
-
getDatatype
public Datatype<?> getDatatype(openllet.aterm.ATermAppl uri)
Description copied from interface:DatatypeReasoner
Get the datatype identified by a uri- Specified by:
getDatatype
in interfaceDatatypeReasoner
- Parameters:
uri
- the datatype identifier (e.g.,xsd:integer
)- Returns:
- the
Datatype
ifuri
is recognized,null
otherwise
-
getLiteral
public openllet.aterm.ATermAppl getLiteral(java.lang.Object value)
Description copied from interface:DatatypeReasoner
Get the canonicalATermAppl
literal representation for a value space object- Specified by:
getLiteral
in interfaceDatatypeReasoner
- Parameters:
value
- Element of the value space for some datatype- Returns:
- The
ATermAppl
representation ofvalue
-
getValue
public java.lang.Object getValue(openllet.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 ajava.lang.Byte
.- Specified by:
getValue
in interfaceDatatypeReasoner
- Returns:
- Java object representation of
literal
- Throws:
InvalidLiteralException
- if the literal is not in the lexical space of the datatypeUnrecognizedDatatypeException
- if the datatype is not recognized
-
isDeclared
public boolean isDeclared(openllet.aterm.ATermAppl name)
Description copied from interface:DatatypeReasoner
Check if a specific datatype or named _data range has been declared. Declaratations can happen by- The datatype being built-in (e.g.,
xsd:integer
) - A call to
DatatypeReasoner.declare(ATermAppl)
, which typically precedes a call toDatatypeReasoner.define(ATermAppl, ATermAppl)
- A call to
DatatypeReasoner.define(ATermAppl, ATermAppl)
- Specified by:
isDeclared
in interfaceDatatypeReasoner
- Parameters:
name
- the name (normally URI) of the datatype- Returns:
true
ifname
has been declared,false
else
- The datatype being built-in (e.g.,
-
isDefined
public boolean isDefined(openllet.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 thename
parameter of a callDatatypeReasoner.define(ATermAppl, ATermAppl)
- Specified by:
isDefined
in interfaceDatatypeReasoner
- Parameters:
name
- the name (normally URI) of the datatype or named _data range- Returns:
true
ifname
is supported,false
else
-
getDefinition
public openllet.aterm.ATermAppl getDefinition(openllet.aterm.ATermAppl name)
Description copied from interface:DatatypeReasoner
Returns the definition for the given datatype name if it is defined, ornull
otherwise.- Specified by:
getDefinition
in interfaceDatatypeReasoner
- 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<openllet.aterm.ATermAppl> dataranges) throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException
Description copied from interface:DatatypeReasoner
Shorthand forDatatypeReasoner.isSatisfiable(Collection, Object)
wherevalue == null
.- Specified by:
isSatisfiable
in interfaceDatatypeReasoner
- 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<openllet.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 interfaceDatatypeReasoner
- Parameters:
dataranges
- The _data ranges on the literal _nodevalue
- A constant value asserted for the _node ornull
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 interfaceDatatypeReasoner
- Parameters:
nodes
- A set representing all literals with in-edges from a single _individualneqs
- 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(openllet.aterm.ATermAppl name, openllet.aterm.ATermAppl datarange)
Description copied from interface:DatatypeReasoner
Name a _data range (see OWL 2DatatypeDefinition
)- Specified by:
define
in interfaceDatatypeReasoner
- Parameters:
name
- a URI used to refer to the datatypedatarange
- the datarange- Returns:
- true if successful, false if
name
is already used
-
listDataRanges
public java.util.Collection<openllet.aterm.ATermAppl> listDataRanges()
- Specified by:
listDataRanges
in interfaceDatatypeReasoner
- Returns:
- a collection of all known _data ranges.
-
validLiteral
public boolean validLiteral(openllet.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 interfaceDatatypeReasoner
- Returns:
true
if the literal is in the lexical space of the datatype,false
else- Throws:
UnrecognizedDatatypeException
-
valueIterator
public java.util.Iterator<?> valueIterator(java.util.Collection<openllet.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 interfaceDatatypeReasoner
- Parameters:
dataranges
- the _data ranges- Returns:
- an
Iterator
- Throws:
InvalidConstrainingFacetException
- ifdataranges
contains a datatype restriction in which the constraining facet is not validInvalidLiteralException
- ifdataranges
references a literal value that is invalidUnrecognizedDatatypeException
- ifdataranges
references an unrecognized datatype
-
-