kaos.policy.information
Class KAoSInstance

java.lang.Object
  extended by kaos.policy.information.KAoSInstance
All Implemented Interfaces:
java.io.Serializable, KAoSInstanceDescription
Direct Known Subclasses:
BasicActionDescription, ObligationConstraintsDescription

public class KAoSInstance
extends java.lang.Object
implements java.io.Serializable, KAoSInstanceDescription

See Also:
Serialized Form

Nested Class Summary
 class KAoSInstance.PropertyNameWithPath
           
 
Field Summary
protected  java.lang.String _instanceNameURI
           
protected  java.lang.String _instanceOfClassURI
           
protected  java.lang.String _originalOWL
           
protected  java.util.Hashtable _properties
          keys are property names, values are KAoSProperties
protected  java.util.Hashtable _propertyClasses
           
 
Constructor Summary
KAoSInstance()
          Create an anonymous KAoSInstance with an empty set of properties
KAoSInstance(KAoSInstance ki)
          Cloning constructor
KAoSInstance(java.lang.String className, java.lang.String instanceName)
          Create an instance of the given ontology class with the given ontology name
 
Method Summary
 void addProperty(KAoSProperty add)
          Adds the given property to the set of properties in this class.
 void addProperty(java.lang.String propertyName, java.lang.Object propertyValue)
          Adds a property to this instance with the given name and propertyValue.
 void addProperty(java.lang.String propertyName, java.util.Set propertyValues)
          Adds a property to this instance with the given name and set of propertyValues.
 int compareProperty(KAoSProperty other)
          Compare the given property to a matching property found in this instance.
 int comparePropertyOtherWay(KAoSProperty other)
          Compare the given property to a matching property found in this instance.
 java.util.Enumeration getAllProperties()
          Get all of the properties for this instance.
 java.util.Enumeration getAllPropertyNames()
          get all the property names of this instance
 java.util.HashMap getAllPropertyValuesWithPaths(java.util.Vector propertyPathVector)
          Flatten all of the properties in this instance as well as all nested instances into a single HashMap.
 java.lang.String getClassNameURI()
          get the URI for the ontology class this is an instance of
 java.lang.String getInstanceNameURI()
          Get the URI that is the name of this instance
 KAoSProperty getNestedProperty(java.lang.String propertyName)
          Get the KAoSProperty with the given name from this instance's set of properties.
 java.lang.Object getNestedPropertyValue(java.lang.String propertyName)
          Get the first value from the set of values for the given property name.
 java.util.Set getNestedPropertyValues(java.lang.String propertyName)
          Get the set of values for the given property name.
 java.lang.String getOriginalOWL()
          If this KAoSInstance was created by parsing an OWL document, return the original OWL for this instance, otherwise null.
 KAoSProperty getProperty(java.lang.String propertyName)
          Get the KAoSProperty with the given name from this instance's set of properties.
 int numberOfProperties()
          This function returns the number of properties held in this description.
 void removeProperty(java.lang.String propertyName)
          Remove the property with the given name from the set of this instance's properties.
 KAoSInstance returnCopy()
          Return a clone of this instance.
 void setOriginalOWL(java.lang.String owl)
          If this KAoSInstance was created by parsing an OWL document, store the original OWL.
 void setPropertyValue(java.lang.String propertyName, java.lang.Object propertyValue)
          Replace the value of an existing property with the given value
 void setPropertyValues(java.lang.String propertyName, java.util.Set propertyValues)
          Replace the value of an existing property with the given set of values
 java.lang.String toString()
          Return a string representation of this instance.
 void updateInstancesForClass(java.lang.String className, java.util.Collection inst)
          update the class instances of a property contained in this instance
 void updateSubpropertyNamesForProperty(java.lang.String propName, java.util.Collection subProps)
          update the cached subproperties of the given property
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_properties

protected java.util.Hashtable _properties
keys are property names, values are KAoSProperties


_instanceNameURI

protected java.lang.String _instanceNameURI

_instanceOfClassURI

protected java.lang.String _instanceOfClassURI

_originalOWL

protected java.lang.String _originalOWL

_propertyClasses

protected java.util.Hashtable _propertyClasses
Constructor Detail

KAoSInstance

public KAoSInstance()
Create an anonymous KAoSInstance with an empty set of properties


KAoSInstance

public KAoSInstance(java.lang.String className,
                    java.lang.String instanceName)
Create an instance of the given ontology class with the given ontology name

Parameters:
className - - URI specifying the ontology class this is an instance of
instanceName - - URI for the name of this instance

KAoSInstance

public KAoSInstance(KAoSInstance ki)
Cloning constructor

Parameters:
ki -
Method Detail

getInstanceNameURI

public java.lang.String getInstanceNameURI()
Get the URI that is the name of this instance

Returns:

getClassNameURI

public java.lang.String getClassNameURI()
get the URI for the ontology class this is an instance of

Returns:

addProperty

public void addProperty(KAoSProperty add)
Adds the given property to the set of properties in this class. If a property with that name already exists, it is replaced with the current property.

Parameters:
add - - the KAoSProperty to add to this instance

addProperty

public void addProperty(java.lang.String propertyName,
                        java.util.Set propertyValues)
Adds a property to this instance with the given name and set of propertyValues. If a property with the given name already exists, the values are added to the existing property's set of values.

Parameters:
propertyName - - name of the property to add
propertyValues - - set of property values for the new property, set members are Objects

addProperty

public void addProperty(java.lang.String propertyName,
                        java.lang.Object propertyValue)
Adds a property to this instance with the given name and propertyValue. If a property with the given name already exists, the value is added to the existing property's set of values.

Parameters:
propertyName - - name of the property to add
propertyValue - - string value for the new property

removeProperty

public void removeProperty(java.lang.String propertyName)
Remove the property with the given name from the set of this instance's properties. Only looks at properties of this instance and not properties of instances nested within this one

Parameters:
name - - URI for the name of the property to remove

getProperty

public KAoSProperty getProperty(java.lang.String propertyName)
Get the KAoSProperty with the given name from this instance's set of properties. Does not look for properties of nested KAoSInstances.

Parameters:
propertyName -
Returns:

updateSubpropertyNamesForProperty

public void updateSubpropertyNamesForProperty(java.lang.String propName,
                                              java.util.Collection subProps)
update the cached subproperties of the given property

Parameters:
propName - the given property
subProps - names of its subproperties

getNestedProperty

public KAoSProperty getNestedProperty(java.lang.String propertyName)
Get the KAoSProperty with the given name from this instance's set of properties. If the property is not found in this instance, recursively search for the property in KAoSInstances nested within this one.

Parameters:
propertyName - - URI for the property to get
Returns:

getNestedPropertyValues

public java.util.Set getNestedPropertyValues(java.lang.String propertyName)
                                      throws ValueNotSet
Get the set of values for the given property name. If the property is not found in this instance, recursively search for the property in KAoSInstances nested within this one.

Parameters:
propertyName - - URI for the property to find
Returns:
- the set of property values (called instances) associated with the property
Throws:
ValueNotSet

getNestedPropertyValue

public java.lang.Object getNestedPropertyValue(java.lang.String propertyName)
                                        throws ValueNotSet
Get the first value from the set of values for the given property name. If the property is not found in this instance, recursively search for the property in KAoSInstances nested within this one.

Parameters:
propertyName - - URI for the property to find
Returns:
- the first property value associated with the property
Throws:
ValueNotSet

setPropertyValue

public void setPropertyValue(java.lang.String propertyName,
                             java.lang.Object propertyValue)
                      throws ValueNotSet
Replace the value of an existing property with the given value

Parameters:
propertyName - - URI for the property name
propertyValue - - new value for the property
Throws:
ValueNotSet - if the property does not exist

setPropertyValues

public void setPropertyValues(java.lang.String propertyName,
                              java.util.Set propertyValues)
                       throws ValueNotSet
Replace the value of an existing property with the given set of values

Parameters:
propertyName - - URI for the property name
propertyValues - - set of new values for the property
Throws:
ValueNotSet - if the property does not exist

updateInstancesForClass

public void updateInstancesForClass(java.lang.String className,
                                    java.util.Collection inst)
update the class instances of a property contained in this instance


getAllProperties

public java.util.Enumeration getAllProperties()
Get all of the properties for this instance. Excluding nested properties

Returns:

getAllPropertyNames

public java.util.Enumeration getAllPropertyNames()
get all the property names of this instance

Returns:
Enumeration of all property names excluding nested properties

getAllPropertyValuesWithPaths

public java.util.HashMap getAllPropertyValuesWithPaths(java.util.Vector propertyPathVector)
Flatten all of the properties in this instance as well as all nested instances into a single HashMap. The keys of the returned Hashmap are KAoSInstance.PropertyNameWithPath objects. If a property is nested, the path to the property is included in the path vector from top to bottom (root to leaf): example key: [http://ontology.ihmc.us/Action.owl#movingTo|http://ontology.ihmc.us/Place.owl#hasAddress|http://ontology.ihmc.us/Spatial/PhysicalAddress.owl#XCoordinate] The vertical bar '|' is the path separator token in the toString for PropertyNameWithPath.

Parameters:
propertyNamePrefix - - String prefix for property name (e.g. 'path-root.'), typically null except for the recursive calls which use this to build paths to nested properties
Returns:
HashMap of PropertyNameWithPath keys (property name, vector containing path if nested) to Object values (Set if more than one value for property, otherwise a single object - typically a String)

compareProperty

public int compareProperty(KAoSProperty other)
Compare the given property to a matching property found in this instance.

Parameters:
other -
Returns:

comparePropertyOtherWay

public int comparePropertyOtherWay(KAoSProperty other)
Compare the given property to a matching property found in this instance.

Parameters:
other -
Returns:

numberOfProperties

public int numberOfProperties()
This function returns the number of properties held in this description.


getOriginalOWL

public java.lang.String getOriginalOWL()
If this KAoSInstance was created by parsing an OWL document, return the original OWL for this instance, otherwise null.

Returns:

setOriginalOWL

public void setOriginalOWL(java.lang.String owl)
If this KAoSInstance was created by parsing an OWL document, store the original OWL.

Parameters:
owl -

returnCopy

public KAoSInstance returnCopy()
Return a clone of this instance.

Returns:

toString

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

Overrides:
toString in class java.lang.Object