info.sswap.impl.empire.model
Class TypeImpl

java.lang.Object
  extended by info.sswap.impl.empire.model.ModelImpl
      extended by info.sswap.impl.empire.model.ElementImpl
          extended by info.sswap.impl.empire.model.TypeImpl
All Implemented Interfaces:
com.clarkparsia.empire.SupportsRdfId, SSWAPElement, SSWAPModel, SSWAPType

public class TypeImpl
extends ElementImpl
implements SSWAPType

Implementation of SSWAPType.

Author:
Blazej Bulka

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.clarkparsia.empire.SupportsRdfId
com.clarkparsia.empire.SupportsRdfId.BNodeKey, com.clarkparsia.empire.SupportsRdfId.RdfKey<T>, com.clarkparsia.empire.SupportsRdfId.URIKey
 
Field Summary
private  com.clarkparsia.empire.SupportsRdfId.RdfKey rdfKey
          The RDF identifier of this type.
private  com.hp.hpl.jena.rdf.model.Resource resource
          The Jena resource that defines this type (important for fast access to type information).
 
Constructor Summary
TypeImpl(SourceModel parent, java.net.URI uri)
           
TypeImpl(SourceModel parent, java.net.URI uri, boolean preventOWLClass)
           
 
Method Summary
 void addAnnotationPredicate(SSWAPPredicate predicate, SSWAPElement value)
          Annotates a type with the given annotation predicate.
 void addDisjointUnionOf(java.util.Collection<SSWAPType> disjointClasses)
          Adds an owl:disjointUnionOf axiom to this type
 void addDisjointWith(SSWAPType type)
          Adds an owl:disjointWith axiom to this type.
 void addEquivalentClass(SSWAPType type)
          Adds an owl:equivalentClass axiom to this type.
 void addIntersectionOf(java.util.Collection<SSWAPType> types)
          Adds an owl:intersectionOf axiom to this type.
 void addOneOf(java.util.Collection<java.net.URI> oneOf)
          Adds an owl:oneOf axiom to this type
(package private) static void addRestriction(com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource resource, java.lang.String propertyURI, com.hp.hpl.jena.rdf.model.Statement restrictionStatement, boolean objectPredicate, boolean datatypePredicate)
           
private  void addRestriction(SSWAPPredicate predicate, com.hp.hpl.jena.rdf.model.Statement restrictionStatement)
           
 void addRestrictionAllValuesFrom(SSWAPPredicate predicate, SSWAPType type)
          Adds an owl:allValuesFrom restriction to this type on the specified predicate
 void addRestrictionCardinality(SSWAPPredicate predicate, int cardinality)
          Adds a cardinality restriction to this type on the specified predicate.
 void addRestrictionHasSelf(SSWAPPredicate predicate, boolean value)
          Adds an owl:hasSelf restriction to this type on the specified predicate
 void addRestrictionHasValue(SSWAPPredicate predicate, SSWAPElement element)
          Adds an owl:hasValue restriction to this type on the specified predicate
 void addRestrictionMaxCardinality(SSWAPPredicate predicate, int maxCardinality)
          Adds a max cardinality restriction to this type on the specified predicate.
 void addRestrictionMinCardinality(SSWAPPredicate predicate, int minCardinality)
          Adds a min cardinality restriction to this type on the specified predicate.
 void addRestrictionSomeValuesFrom(SSWAPPredicate predicate, SSWAPType type)
          Adds an owl:someValuesFrom restriction to this type on the specified predicate
 void addSubClassOf(SSWAPType type)
          Adds an rdfs:subClassOf axiom to this type.
 void addUnionOf(java.util.Collection<SSWAPType> types)
          Adds an owl:unionOf axiom to this type
 SSWAPType complementOf()
          Creates the complement of the current type.
private static SSWAPType createComplexType(SSWAPModel model, com.hp.hpl.jena.rdf.model.Property connectingProperty, java.util.Collection<SSWAPType> types)
           
private static void createComplexType(SSWAPModel model, TypeImpl resultType, com.hp.hpl.jena.rdf.model.Property connectingProperty, java.util.Collection<SSWAPType> types)
          Creates a complex type that consists of multiple other types connected by a property (e.g., owl:intersectionOf or owl:unionOf).
private  com.hp.hpl.jena.rdf.model.Statement createRdfTypeStatement(java.net.URI typeURI)
          Creates a Jena statement that states that this type is an owl:Class.
 boolean equals(java.lang.Object o)
           
 com.clarkparsia.empire.SupportsRdfId.RdfKey getRdfId()
          Gets the RDF identifier of this type.
private  ReasoningServiceImpl getReasoningServiceImpl()
           
(package private)  com.hp.hpl.jena.rdf.model.Resource getResource()
          Gets the corresponding Jena resource for this type.
 int hashCode()
          Overridden hash code method to make sure that the generated hashcodes are consistent with the overriden equals() method.
static SSWAPType intersectionOf(SSWAPModel model, java.util.Collection<SSWAPType> types)
          Creates a complex type that is an intersection of the specified types.
 SSWAPType intersectionOf(SSWAPType a)
          Creates and returns a new type that is an intersection of this type and the given type.
 boolean isIntersection()
           
 boolean isNothing()
          Checks whether this type is unsatisfiable (i.e., whether it is a sub type of owl:Nothing).
 boolean isReserved()
          Checks whether the given type belongs to restricted vocabulary (e.g., types defined in RDF, RDFS, OWL or SSWAP namespaces).
 boolean isStrictSubTypeOf(SSWAPType superType)
          Checks whether this type is a strict subtype of the other.
 boolean isSubTypeOf(SSWAPType superType)
          Checks whether this type is a subtype of the other.
 void serialize(java.io.OutputStream os, RDFRepresentation representation, boolean commentedOutput)
          Serializes the contents of this object to the specified stream.
 void setRdfId(com.clarkparsia.empire.SupportsRdfId.RdfKey rdfKey)
          Sets the RDF identifier of this type.
 java.lang.String toString()
          Returns the string representation of the RDF identifier of this type.
static SSWAPType unionOf(SSWAPModel model, java.util.Collection<SSWAPType> types)
          Creates a complex type that is a union of the specified types.
 SSWAPType unionOf(SSWAPType a)
          Creates and returns a new type that is a union of this type and the given type.
 
Methods inherited from class info.sswap.impl.empire.model.ElementImpl
addComment, addLabel, asBoolean, asDouble, asIndividual, asInteger, asList, asLiteral, asString, getComment, getJenaResource, getLabel, isAnonymous, isIndividual, isList, isLiteral
 
Methods inherited from class info.sswap.impl.empire.model.ModelImpl
addImport, assertModel, assertSourceModel, checkProfile, dereference, dereference, doClosure, getAllDependentObjects, getDependentObject, getDocument, getExpressivity, getImports, getInputStream, getNsPrefixMap, getReasoningService, getSourceModel, getTypeSignature, getURI, hasSourceModel, hasSourceModelWithEntityManager, isDereferenced, persist, rdfIdEquals, rdfIdHashCode, refresh, refreshSiblings, removeImport, removeNsPrefix, serialize, setDereferenced, setNsPrefix, setSourceModel, setURI, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface info.sswap.api.model.SSWAPElement
addComment, addLabel, asBoolean, asDouble, asIndividual, asInteger, asList, asLiteral, asString, getComment, getLabel, isIndividual, isList, isLiteral
 
Methods inherited from interface info.sswap.api.model.SSWAPModel
addImport, checkProfile, dereference, dereference, doClosure, getDocument, getImports, getInputStream, getNsPrefixMap, getReasoningService, getTypeSignature, getURI, isDereferenced, removeImport, removeNsPrefix, serialize, setNsPrefix, validate
 

Field Detail

rdfKey

private com.clarkparsia.empire.SupportsRdfId.RdfKey rdfKey
The RDF identifier of this type. (The types can also be anonymous classes, and therefore they may not have an URI.)


resource

private com.hp.hpl.jena.rdf.model.Resource resource
The Jena resource that defines this type (important for fast access to type information). This field is lazily initialized by getResource(). All accesses to this field should be made via the getResource() method.

Constructor Detail

TypeImpl

public TypeImpl(SourceModel parent,
                java.net.URI uri)

TypeImpl

public TypeImpl(SourceModel parent,
                java.net.URI uri,
                boolean preventOWLClass)
Method Detail

getResource

com.hp.hpl.jena.rdf.model.Resource getResource()
Gets the corresponding Jena resource for this type. (Since types can be anonymous classes, the Jena resource effectively provides a handle to such resources.) This method lazily initializes the "resource" field of this class.

Returns:
Jena Resource representation

createRdfTypeStatement

private com.hp.hpl.jena.rdf.model.Statement createRdfTypeStatement(java.net.URI typeURI)
Creates a Jena statement that states that this type is an owl:Class. The statement is of form: this.rdfKey rdf:type owl:Class .

Returns:
the statement created for the source model of this type

complementOf

public SSWAPType complementOf()
Description copied from interface: SSWAPType
Creates the complement of the current type. (That is, the new type contains all the individuals that do NOT belong to the current type.)

Specified by:
complementOf in interface SSWAPType
Returns:
the new type that is the complement of the current type.

createComplexType

private static void createComplexType(SSWAPModel model,
                                      TypeImpl resultType,
                                      com.hp.hpl.jena.rdf.model.Property connectingProperty,
                                      java.util.Collection<SSWAPType> types)
                               throws java.lang.IllegalArgumentException
Creates a complex type that consists of multiple other types connected by a property (e.g., owl:intersectionOf or owl:unionOf).

Parameters:
model - the model where the type should be stored
resultType - the type to which the resultant type will be added
connectingProperty - the property (currently only owl:intersectionOf and owl:unionOf make sense)
types - the types to be connected -- must be a list of at least two types
Throws:
java.lang.IllegalArgumentException - if the list of types does not contain at least two types or the objects were not created by this API implementation

createComplexType

private static SSWAPType createComplexType(SSWAPModel model,
                                           com.hp.hpl.jena.rdf.model.Property connectingProperty,
                                           java.util.Collection<SSWAPType> types)

intersectionOf

public static SSWAPType intersectionOf(SSWAPModel model,
                                       java.util.Collection<SSWAPType> types)
Creates a complex type that is an intersection of the specified types.

Parameters:
model - the model that will store the types
types - the types to be included in the intersection
Returns:
a complex type: the intersection of multiple types

intersectionOf

public SSWAPType intersectionOf(SSWAPType a)
Description copied from interface: SSWAPType
Creates and returns a new type that is an intersection of this type and the given type. (That is, the new type contains all the individuals that BOTH belong to this type AND the other type.)

Specified by:
intersectionOf in interface SSWAPType
Parameters:
a - the other type, with which the intersection is taken
Returns:
the new type that is the intersection of the current type and the given type.

unionOf

public static SSWAPType unionOf(SSWAPModel model,
                                java.util.Collection<SSWAPType> types)
Creates a complex type that is a union of the specified types.

Parameters:
model - the model that will store the types
types - the types to be included in the union
Returns:
a complex type: the intersection of multiple types

unionOf

public SSWAPType unionOf(SSWAPType a)
Description copied from interface: SSWAPType
Creates and returns a new type that is a union of this type and the given type. (That is, the new type contains all the individuals that belong to this type, the other type, OR both).

Specified by:
unionOf in interface SSWAPType
Parameters:
a - the other type, with which the union is taken.
Returns:
the new type that is the union of the current type and the given type.

getRdfId

public com.clarkparsia.empire.SupportsRdfId.RdfKey getRdfId()
Gets the RDF identifier of this type.

Specified by:
getRdfId in interface com.clarkparsia.empire.SupportsRdfId
Returns:
the RDF identifier of this type (URL or BNode identifier)

setRdfId

public void setRdfId(com.clarkparsia.empire.SupportsRdfId.RdfKey rdfKey)
Sets the RDF identifier of this type.

Specified by:
setRdfId in interface com.clarkparsia.empire.SupportsRdfId
Parameters:
rdfKey - the RDF identifier of this type (URL or BNode identifier).

toString

public java.lang.String toString()
Returns the string representation of the RDF identifier of this type.

Overrides:
toString in class java.lang.Object

addUnionOf

public void addUnionOf(java.util.Collection<SSWAPType> types)
Description copied from interface: SSWAPType
Adds an owl:unionOf axiom to this type

Specified by:
addUnionOf in interface SSWAPType
Parameters:
types - SSWAPTypes that compose the union

addIntersectionOf

public void addIntersectionOf(java.util.Collection<SSWAPType> types)
Description copied from interface: SSWAPType
Adds an owl:intersectionOf axiom to this type.

Specified by:
addIntersectionOf in interface SSWAPType
Parameters:
types - SSWAPTypes that compose the intersection

addDisjointUnionOf

public void addDisjointUnionOf(java.util.Collection<SSWAPType> disjointClasses)
Description copied from interface: SSWAPType
Adds an owl:disjointUnionOf axiom to this type

Specified by:
addDisjointUnionOf in interface SSWAPType
Parameters:
disjointClasses - SSWAPTypes that compose the disjointedness

addDisjointWith

public void addDisjointWith(SSWAPType type)
Description copied from interface: SSWAPType
Adds an owl:disjointWith axiom to this type.

Specified by:
addDisjointWith in interface SSWAPType
Parameters:
type - the disjoint type with this one

addEquivalentClass

public void addEquivalentClass(SSWAPType type)
Description copied from interface: SSWAPType
Adds an owl:equivalentClass axiom to this type.

Specified by:
addEquivalentClass in interface SSWAPType
Parameters:
type - the equivalent type

addOneOf

public void addOneOf(java.util.Collection<java.net.URI> oneOf)
Description copied from interface: SSWAPType
Adds an owl:oneOf axiom to this type

Specified by:
addOneOf in interface SSWAPType
Parameters:
oneOf - the collection of URIs that will be converted into argument to owl:oneOf

addRestrictionAllValuesFrom

public void addRestrictionAllValuesFrom(SSWAPPredicate predicate,
                                        SSWAPType type)
Description copied from interface: SSWAPType
Adds an owl:allValuesFrom restriction to this type on the specified predicate

Specified by:
addRestrictionAllValuesFrom in interface SSWAPType
Parameters:
predicate - predicate to which the restriction applies
type - the argument for owl:allValuesFrom

addRestrictionHasSelf

public void addRestrictionHasSelf(SSWAPPredicate predicate,
                                  boolean value)
Description copied from interface: SSWAPType
Adds an owl:hasSelf restriction to this type on the specified predicate

Specified by:
addRestrictionHasSelf in interface SSWAPType
Parameters:
predicate - predicate to which the restriction applies
value - a boolean value (argument to owl:hasSelf)

addRestrictionHasValue

public void addRestrictionHasValue(SSWAPPredicate predicate,
                                   SSWAPElement element)
Description copied from interface: SSWAPType
Adds an owl:hasValue restriction to this type on the specified predicate

Specified by:
addRestrictionHasValue in interface SSWAPType
Parameters:
predicate - predicate to which the restriction applies
element - the value for owl:hasValue

addRestrictionMaxCardinality

public void addRestrictionMaxCardinality(SSWAPPredicate predicate,
                                         int maxCardinality)
Description copied from interface: SSWAPType
Adds a max cardinality restriction to this type on the specified predicate.

Specified by:
addRestrictionMaxCardinality in interface SSWAPType
Parameters:
predicate - predicate to which the cardinality restriction applies
maxCardinality - the value of the maxCardinality

addRestrictionMinCardinality

public void addRestrictionMinCardinality(SSWAPPredicate predicate,
                                         int minCardinality)
Description copied from interface: SSWAPType
Adds a min cardinality restriction to this type on the specified predicate.

Specified by:
addRestrictionMinCardinality in interface SSWAPType
Parameters:
predicate - predicate to which the cardinality restriction applies
minCardinality - the value of the minCardinality

addRestrictionCardinality

public void addRestrictionCardinality(SSWAPPredicate predicate,
                                      int cardinality)
Description copied from interface: SSWAPType
Adds a cardinality restriction to this type on the specified predicate.

Specified by:
addRestrictionCardinality in interface SSWAPType
Parameters:
predicate - predicate to which the cardinality restriction applies
cardinality - the cardinality value

addRestrictionSomeValuesFrom

public void addRestrictionSomeValuesFrom(SSWAPPredicate predicate,
                                         SSWAPType type)
Description copied from interface: SSWAPType
Adds an owl:someValuesFrom restriction to this type on the specified predicate

Specified by:
addRestrictionSomeValuesFrom in interface SSWAPType
Parameters:
predicate - predicate to which the restriction applies
type - the argument for owl:someValuesFrom

addRestriction

private void addRestriction(SSWAPPredicate predicate,
                            com.hp.hpl.jena.rdf.model.Statement restrictionStatement)

addRestriction

static void addRestriction(com.hp.hpl.jena.rdf.model.Model model,
                           com.hp.hpl.jena.rdf.model.Resource resource,
                           java.lang.String propertyURI,
                           com.hp.hpl.jena.rdf.model.Statement restrictionStatement,
                           boolean objectPredicate,
                           boolean datatypePredicate)

addSubClassOf

public void addSubClassOf(SSWAPType type)
Description copied from interface: SSWAPType
Adds an rdfs:subClassOf axiom to this type.

Specified by:
addSubClassOf in interface SSWAPType
Parameters:
type - the super type

addAnnotationPredicate

public void addAnnotationPredicate(SSWAPPredicate predicate,
                                   SSWAPElement value)
Description copied from interface: SSWAPType
Annotates a type with the given annotation predicate.

Specified by:
addAnnotationPredicate in interface SSWAPType
Parameters:
predicate - the predicate to be used in annotation

getReasoningServiceImpl

private ReasoningServiceImpl getReasoningServiceImpl()

isSubTypeOf

public boolean isSubTypeOf(SSWAPType superType)
Description copied from interface: SSWAPType
Checks whether this type is a subtype of the other. (That is, whether all individuals of this type are necessarily individuals of the other type). By the laws of subsumption, "subtype" includes equivalency, so a type is always a subtype of itself.

Specified by:
isSubTypeOf in interface SSWAPType
Parameters:
superType - the potential super type
Returns:
true if this is a subtype of superType

isStrictSubTypeOf

public boolean isStrictSubTypeOf(SSWAPType superType)
Description copied from interface: SSWAPType
Checks whether this type is a strict subtype of the other. (That is, whether all individuals of this type are necessarily individuals of the other type, yet this type is not equivalent to the other type).

Specified by:
isStrictSubTypeOf in interface SSWAPType
Parameters:
superType - the potential super type
Returns:
true if this is a strict subtype of sup.

isNothing

public boolean isNothing()
Description copied from interface: SSWAPType
Checks whether this type is unsatisfiable (i.e., whether it is a sub type of owl:Nothing).

Specified by:
isNothing in interface SSWAPType
Returns:
true if this type is unsatisfiable, false otherwise

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overridden hash code method to make sure that the generated hashcodes are consistent with the overriden equals() method.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode.

isReserved

public boolean isReserved()
Description copied from interface: SSWAPType
Checks whether the given type belongs to restricted vocabulary (e.g., types defined in RDF, RDFS, OWL or SSWAP namespaces).

Specified by:
isReserved in interface SSWAPType
Returns:
true if the type belongs to restricted vocabulary.

isIntersection

public boolean isIntersection()

serialize

public void serialize(java.io.OutputStream os,
                      RDFRepresentation representation,
                      boolean commentedOutput)
Description copied from interface: SSWAPModel
Serializes the contents of this object to the specified stream.

Specified by:
serialize in interface SSWAPModel
Overrides:
serialize in class ModelImpl
Parameters:
os - output stream
representation - the representation, in which the contents should be written (e.g., RDF/XML).
commentedOutput - true, if the output should contain comments about various standard sections of an RDG (valid only for RDF/XML)


Copyright (c) 2011, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.