kaos.core.csi
Class OntInstanceDescriptionImpl

java.lang.Object
  extended by kaos.core.csi.OntInstanceDescriptionImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, OntInstanceDescription
Direct Known Subclasses:
ActionInstanceDescriptionImpl, ActionSituationCharacteristicImpl, DateTimeDescriptionImpl, DurationDescriptionImpl, MetricForConsequenceStatusImpl, MetricForResourceStatusImpl, ObligationConstraintsDescription, TemporalEntityImpl

public class OntInstanceDescriptionImpl
extends java.lang.Object
implements OntInstanceDescription, java.lang.Cloneable, java.io.Serializable

Represents an instance of an ontology class. Each property's value may have description, which can be another OntInstanceDescriptionImpl thus allowing for unlimited nesting of OntInstanceDescriptionImpl's.

See Also:
$Revision: 1.41 $, Serialized Form

Constructor Summary
OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel)
          Constructor creating an instance based on ontology model containing OWL defining this instance.
OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel, boolean findValueDescriptions)
          Constructor creating an instance based on ontology model containing OWL defining this instance.
OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel, OntologyService myOntologyService)
          Constructor creating an instance based on ontology model containing OWL defining this instance.
OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel, OntologyService myOntologyService, java.util.Map<java.lang.String,java.util.List<OntPropertyDescription>> createdValueDescs)
          Constructor creating an instance based on ontology model containing OWL defining this instance.
OntInstanceDescriptionImpl(java.lang.String owlString)
          Constructor creating an instance from OWL.
OntInstanceDescriptionImpl(java.lang.String owlString, OntologyService myOntologyService)
          Constructor creating an instance from OWL.
OntInstanceDescriptionImpl(java.lang.String instanceName, java.lang.String className)
          Basic constructor
 
Method Summary
 void addProperty(OntPropertyDescription newProperty)
          Add property to the instance
 OntPropertyDescription addProperty(java.lang.String newPropertyName, java.lang.String value)
          Add property to the instance, providing name and value.
 void addType(java.lang.String className)
          Add the ontology type of this instance.
 void addValueForProperty(java.lang.String propertyURI, java.lang.String propertyValue)
           
 void addValueForProperty(java.lang.String propertyURI, java.lang.String propertyValue, java.lang.Object propertyValueDesc)
           
 java.lang.Object clone()
          Implementation of the clone method
 OntInstanceDescription createValueDescription(java.lang.String propertyURI, SerializableOntModelImpl model, OntologyService ontService, java.util.Map<java.lang.String,java.util.List<OntPropertyDescription>> createdValueDescs)
           
 boolean equals(java.lang.Object obj)
           
 java.util.Vector<java.lang.Object> getAllValueDescriptionsForProperty(java.lang.String propertyURI)
           
 java.util.Vector<java.lang.String> getAllValuesForProperty(java.lang.String propertyURI)
           
 java.lang.Object getDescriptionOfFirstValueForProperty(java.lang.String propertyURI)
           
 java.lang.String getFirstType()
          Get first type of the instance
 java.lang.String getFirstValueForProperty(java.lang.String propertyURI)
           
 java.lang.String getInstanceID()
           
 SerializableOntModelImpl getInstanceOntModel()
          Get the Jena-based Ontology Model object for this instance.
 java.lang.String getName()
          Get name of the instance
 OntPropertyDescription getNestedProperty(java.lang.String propertyName)
          Get the given property if nested in the path of interrelated instances.
 java.util.Set<OntPropertyDescription> getProperties()
          Get properties of the instance
 java.util.HashMap<java.lang.String,OntPropertyDescription> getPropertiesMap()
          Get properties of the instance
 OntPropertyDescription getProperty(java.lang.String propertyName)
          Get property of the instance
 java.util.Set<java.lang.String> getTypes()
          Get types of the instance
 int hashCode()
           
 void removeProperty(java.lang.String propertyName)
          Get property from the instance description
 void removeType(java.lang.String name)
          Remove the ontology type of this instance.
 void setProperty(OntPropertyDescription newProperty)
           
 void setValueForProperty(java.lang.String propertyURI, OntInstanceDescription propertyValue)
           
 void setValueForProperty(java.lang.String propertyURI, java.lang.String propertyValue)
           
 java.lang.String toString()
          Returns a string representation of this instance.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(java.lang.String instanceName,
                                  java.lang.String className)
                           throws java.net.URISyntaxException
Basic constructor

Parameters:
instanceName - - instance name
className - - initial class of instance
Throws:
java.net.URISyntaxException - when the class or instance name are not URI

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(java.lang.String owlString)
                           throws java.net.URISyntaxException
Constructor creating an instance from OWL. Only property value descriptions (OntInstances referenced by Object Properties) defined in this OWL String will be included. Note: the OWL may only contain a single 'root' instance definition in other words, only one instance that is not referenced as a value description If your owl defines multiple 'root' instances, then use the SerializedOntModelImpl constructor and set the SerializedOntModelImpl.ontologyStructureId to the one instance you want this class to represent.

Parameters:
owlString - - String containing valid OWL that defines an ontology instance
Throws:
java.net.URISyntaxException

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(java.lang.String owlString,
                                  OntologyService myOntologyService)
                           throws java.net.URISyntaxException
Constructor creating an instance from OWL. Property value descriptions (OntInstances referenced by Object Properties) not defined in the OWL file will be looked-up in the OntologyService

Parameters:
owlString - - String containing valid OWL that defines an ontology instance
myOntologyService - - Ontology service used to lookup the value descriptions not defined in the owlString, may be null in which case the OntologyService lookup is skipped
Throws:
java.net.URISyntaxException

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel)
                           throws java.net.URISyntaxException
Constructor creating an instance based on ontology model containing OWL defining this instance. This only looks in the provided ontology for property value descriptions.

Parameters:
instanceModel - - Ontology model wrapper with the id of instance you want in the ontologyStructureId (see SerializableOntModelImpl.setOntologyStructureId(String)
Throws:
java.net.URISyntaxException

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel,
                                  boolean findValueDescriptions)
                           throws java.net.URISyntaxException
Constructor creating an instance based on ontology model containing OWL defining this instance. This only looks in the provided ontology for property value descriptions.

Parameters:
instanceModel - - Ontology model wrapper with the id of instance you want in the ontologyStructureId (see SerializableOntModelImpl.setOntologyStructureId(String)
findValueDescriptions - - indicates if to parse descriptions of the property values
Throws:
java.net.URISyntaxException

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel,
                                  OntologyService myOntologyService)
                           throws java.net.URISyntaxException
Constructor creating an instance based on ontology model containing OWL defining this instance. Property value descriptions (OntInstances referenced by Object Properties) not defined in the OWL file will be looked-up in the OntologyService

Parameters:
instanceModel - - Ontology model wrapper with the id of instance you want in the ontologyStructureId
myOntologyService - - Ontology service used to lookup the value descriptions not defined in the owlString, may be null in which case the OntologyService lookup is skipped
Throws:
java.net.URISyntaxException

OntInstanceDescriptionImpl

public OntInstanceDescriptionImpl(SerializableOntModelImpl instanceModel,
                                  OntologyService myOntologyService,
                                  java.util.Map<java.lang.String,java.util.List<OntPropertyDescription>> createdValueDescs)
                           throws java.net.URISyntaxException
Constructor creating an instance based on ontology model containing OWL defining this instance. Property value descriptions (OntInstances referenced by Object Properties) not defined in the OWL file will be looked-up in the OntologyService

Parameters:
instanceModel - - Ontology model wrapper with the id of instance you want in the ontologyStructureId
myOntologyService - - Ontology service used to lookup the value descriptions not defined in the owlString, may be null in which case the OntologyService lookup is skipped
Throws:
java.net.URISyntaxException
Method Detail

createValueDescription

public OntInstanceDescription createValueDescription(java.lang.String propertyURI,
                                                     SerializableOntModelImpl model,
                                                     OntologyService ontService,
                                                     java.util.Map<java.lang.String,java.util.List<OntPropertyDescription>> createdValueDescs)
                                              throws java.net.URISyntaxException
Throws:
java.net.URISyntaxException

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

addProperty

public void addProperty(OntPropertyDescription newProperty)
Description copied from interface: OntInstanceDescription
Add property to the instance

Specified by:
addProperty in interface OntInstanceDescription
Parameters:
newProperty - OntPropertyDescription with the property description.
See Also:
OntInstanceDescription.addProperty(kaos.core.csi.OntPropertyDescription)

addProperty

public OntPropertyDescription addProperty(java.lang.String newPropertyName,
                                          java.lang.String value)
Description copied from interface: OntInstanceDescription
Add property to the instance, providing name and value. The method will create OntPropertyDescription and add it to teh instance

Specified by:
addProperty in interface OntInstanceDescription
Parameters:
newPropertyName - string with the property name
Returns:
the created OntPropertyDescription

setProperty

public void setProperty(OntPropertyDescription newProperty)

addType

public void addType(java.lang.String className)
             throws java.net.URISyntaxException
Description copied from interface: OntInstanceDescription
Add the ontology type of this instance.

Specified by:
addType in interface OntInstanceDescription
Parameters:
className - String containing the uri of the ontology type (class).
Throws:
java.net.URISyntaxException - when the name is not a correct URI
See Also:
OntInstanceDescription.addType(java.lang.String)

getName

public java.lang.String getName()
Description copied from interface: OntInstanceDescription
Get name of the instance

Specified by:
getName in interface OntInstanceDescription
Returns:
String representing the name in URI format.
See Also:
OntInstanceDescription.getName()

getTypes

public java.util.Set<java.lang.String> getTypes()
Description copied from interface: OntInstanceDescription
Get types of the instance

Specified by:
getTypes in interface OntInstanceDescription
Returns:
Set containing the strings with URIs of the types.
See Also:
OntInstanceDescription.getTypes()

getFirstType

public java.lang.String getFirstType()
Description copied from interface: OntInstanceDescription
Get first type of the instance

Specified by:
getFirstType in interface OntInstanceDescription
Returns:
URI of the types.
See Also:
OntInstanceDescription.getFirstType()

getProperties

public java.util.Set<OntPropertyDescription> getProperties()
Description copied from interface: OntInstanceDescription
Get properties of the instance

Specified by:
getProperties in interface OntInstanceDescription
Returns:
Set containing the OntPropertyDescriptions.
See Also:
OntInstanceDescription.getProperties()

getPropertiesMap

public java.util.HashMap<java.lang.String,OntPropertyDescription> getPropertiesMap()
Description copied from interface: OntInstanceDescription
Get properties of the instance

Specified by:
getPropertiesMap in interface OntInstanceDescription
Returns:
Map containing the OntPropertyDescriptions.
See Also:
OntInstanceDescription.getPropertiesMap()

getProperty

public OntPropertyDescription getProperty(java.lang.String propertyName)
Description copied from interface: OntInstanceDescription
Get property of the instance

Specified by:
getProperty in interface OntInstanceDescription
Parameters:
propertyName - name of the property.
Returns:
OntPropertyDescription.
See Also:
OntInstanceDescription.getProperty(java.lang.String)

getNestedProperty

public OntPropertyDescription getNestedProperty(java.lang.String propertyName)
Get the given property if nested in the path of interrelated instances. If the property is not found in this instance, recursively search for the property in OntInstanceDescriptions if nested within this one.

Specified by:
getNestedProperty in interface OntInstanceDescription
Parameters:
propertyName - - URI for the property to find
Returns:
- the property description

removeType

public void removeType(java.lang.String name)
Description copied from interface: OntInstanceDescription
Remove the ontology type of this instance.

Specified by:
removeType in interface OntInstanceDescription
Parameters:
name - String containing the uri of the ontology type (class).
See Also:
OntInstanceDescription.removeType(java.lang.String)

removeProperty

public void removeProperty(java.lang.String propertyName)
Description copied from interface: OntInstanceDescription
Get property from the instance description

Specified by:
removeProperty in interface OntInstanceDescription
Parameters:
propertyName - property name.
See Also:
OntInstanceDescription.removeProperty(java.lang.String)

clone

public java.lang.Object clone()
Implementation of the clone method

Specified by:
clone in interface OntInstanceDescription
Overrides:
clone in class java.lang.Object
Returns:
clone of the object

getInstanceID

public java.lang.String getInstanceID()
Returns:
String containing the unique ID for the instance.

toString

public java.lang.String toString()
Returns a string representation of this instance.

Overrides:
toString in class java.lang.Object

getInstanceOntModel

public SerializableOntModelImpl getInstanceOntModel()
Description copied from interface: OntInstanceDescription
Get the Jena-based Ontology Model object for this instance.

Specified by:
getInstanceOntModel in interface OntInstanceDescription
Returns:
Jena-based Ontology Model
See Also:
OntInstanceDescription.getInstanceOntModel()

getFirstValueForProperty

public java.lang.String getFirstValueForProperty(java.lang.String propertyURI)

getDescriptionOfFirstValueForProperty

public java.lang.Object getDescriptionOfFirstValueForProperty(java.lang.String propertyURI)

getAllValueDescriptionsForProperty

public java.util.Vector<java.lang.Object> getAllValueDescriptionsForProperty(java.lang.String propertyURI)

getAllValuesForProperty

public java.util.Vector<java.lang.String> getAllValuesForProperty(java.lang.String propertyURI)

setValueForProperty

public void setValueForProperty(java.lang.String propertyURI,
                                OntInstanceDescription propertyValue)

setValueForProperty

public void setValueForProperty(java.lang.String propertyURI,
                                java.lang.String propertyValue)

addValueForProperty

public void addValueForProperty(java.lang.String propertyURI,
                                java.lang.String propertyValue)

addValueForProperty

public void addValueForProperty(java.lang.String propertyURI,
                                java.lang.String propertyValue,
                                java.lang.Object propertyValueDesc)