kaos.ontology.util
Class KAoSClassBuilderImpl

java.lang.Object
  extended by kaos.ontology.util.KAoSClassBuilderImpl
Direct Known Subclasses:
ActionHistoryBuilder, KAoSConditionStateBuilder, ObligationConstraintsBuilder

public class KAoSClassBuilderImpl
extends java.lang.Object

Class building an Ontology definition of class within (OWL or DAML, depending on the specified ontologyLanguage) com.hp.hpl.jena.ontology.OntModel


Field Summary
static java.lang.String _classLable
           
protected  java.lang.String _classNameSpace
           
protected  OntClass _compClass
           
protected  int _counter
           
protected  OntClass _currentClass
           
protected  SerializableOntModelImpl _currentClassModel
           
protected  java.lang.String _immediateBaseClassName
           
protected  OntClass _instBaseClass
           
protected  OntClass _prevCompClass
           
protected  java.util.HashSet _propertyNames
           
protected  java.util.Hashtable _restrictions
           
 
Constructor Summary
KAoSClassBuilderImpl(SerializableOntModelImpl dcm, java.lang.String classURI)
           
KAoSClassBuilderImpl(java.lang.String classURI)
          Starts building the new classdefinition, delete any existing state of the previously built definition.
KAoSClassBuilderImpl(java.lang.String dcm, java.lang.String classURI)
           
 
Method Summary
 void addBaseClass(java.lang.String baseClassName)
          Add this class as a superclass to the class being built.
 void addBaseClassComplement(java.lang.String baseClassName)
          Add the complement of the base Action class to be controlled by this policy.
 void addClassInstance(java.lang.String instanceURI)
          Add the given instance to the set of individuals that extensionally define the class
 void addImmediateBaseClass(java.lang.String baseClassName)
          Add this class as a superclass to the class being built.
 void addPropertyRangeInstance(java.lang.String propertyName, java.lang.String instanceName)
           
 void addPropertyRangeInstance(java.lang.String propertyName, java.lang.String instanceName, java.lang.String type)
          Add the provided instance to the class being the range of the specified property.
 void addRequiredValueOnProperty(java.lang.String propertyName, java.lang.String instanceName)
          Add the provided instance to the hasValue property of restriction on the specified property.
 void copyPropertyRangeFromOtherPolicy(KAoSClassBuilderImpl sourcePolicy, java.lang.String propertyName)
          Copies the property range data for the specified range to the current policy from the provided source policy
 java.util.Vector getBaseClasses()
          Get the superclasses of the current class.
 java.lang.String getBasePropertyRangeClass(java.lang.String propertyName)
          Get the name of the class on which the range of the given property is set.
 java.lang.String getClassName()
          Get the name of the current class.
 java.lang.String getCurrentPropertyRangeClass(java.lang.String propertyName)
          Get the name of the class on which the range of the given property is set.
 java.lang.String getImmediateBaseClass()
          Get the immediate base class of this class.
 SerializableOntModelImpl getOntClass()
          Return the defined class as OntModel.
 java.lang.String getOntClassAsText()
          Return the defined class as text.
 java.lang.String getParentPropertyRangeClass(java.lang.String propertyName)
          Get the name of the parent class of the class on which the range of the given property is set.
 java.util.Vector getPropertyNames()
           
 java.lang.String[] getPropertyRangeInstance(java.lang.String propertyName)
          Get the instances defining the range of the specified property.
 java.lang.String getRangeComplementParentClass(java.lang.String propertyName)
          Get the parent class of the complement of the given property range.
 java.lang.String getRestrictionTypeName(java.lang.String propertyName)
           
 boolean isPropertyRangeBasedOnClass(java.lang.String propertyName)
          Check if the range of the specified property is class based or instance based.
 boolean isRangeComplement(java.lang.String propertyName)
          Check if the range of the property is a complement.
 void makeRangeComplement(java.lang.String propertyName, java.lang.String propertyClassName)
          Make the range of the property complement of the current range.
protected static void printDebugString(java.lang.String msg, int loggerDisplayLevel)
          Utility method to print debug messages.
 void readFromModel(SerializableOntModelImpl dcm, java.lang.String classURI)
          to read from an already constructed DAMLModel
 void removeBaseClass(java.lang.String baseClassName)
          Remove the class from the list of superclasses of the built class.
 void removeClassInstance(java.lang.String instanceURI)
          removes the given instance from the list of instances that extensionally define the class.
 void removePropertyRangeInstance(java.lang.String propertyName, java.lang.String instanceName)
          Remove the provided instance from the class being the range of the specified property.
 void removeRequiredValueOnProperty(java.lang.String propertyName, java.lang.String instanceName)
          Remove the provided instance from the hasValue property of restriction on the specified property.
 void resetClassBuilding()
           
 void setInstanceEnumeration(java.util.Vector instanceURIs, java.lang.String instBaseClass)
          Convert this class to an myEnumerated class where the class is defined extensionally by the given set of instances.
 void setPropertyRangeClass(java.lang.String propertyName, java.lang.String propertyClassName)
           
 void setPropertyRangeClass(java.lang.String propertyName, java.lang.String propertyClassName, java.lang.String type)
          Set the range of the given poperty to the specified class.
 void setPropertyRangeClassDifference(java.lang.String propertyName, java.lang.String baseClassName1, java.lang.String baseClassName2, java.lang.String type)
          Set the range of the property to the Difference of specified classes.
 void setPropertyRangeClassIntersection(java.lang.String propertyName, java.lang.String baseClassName1, java.lang.String baseClassName2, java.lang.String type)
          Set the range of the property to the intersection of specified classes.
 void showClass(Logger log, int level)
          Print the class to the screen in XML format
 java.lang.String toString()
          Rerurn class string in XML format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_currentClassModel

protected SerializableOntModelImpl _currentClassModel

_currentClass

protected OntClass _currentClass

_compClass

protected OntClass _compClass

_prevCompClass

protected OntClass _prevCompClass

_instBaseClass

protected OntClass _instBaseClass

_restrictions

protected java.util.Hashtable _restrictions

_classNameSpace

protected java.lang.String _classNameSpace

_immediateBaseClassName

protected java.lang.String _immediateBaseClassName

_propertyNames

protected java.util.HashSet _propertyNames

_counter

protected int _counter

_classLable

public static final java.lang.String _classLable
See Also:
Constant Field Values
Constructor Detail

KAoSClassBuilderImpl

public KAoSClassBuilderImpl(java.lang.String classURI)
Starts building the new classdefinition, delete any existing state of the previously built definition.


KAoSClassBuilderImpl

public KAoSClassBuilderImpl(java.lang.String dcm,
                            java.lang.String classURI)

KAoSClassBuilderImpl

public KAoSClassBuilderImpl(SerializableOntModelImpl dcm,
                            java.lang.String classURI)
Method Detail

setInstanceEnumeration

public void setInstanceEnumeration(java.util.Vector instanceURIs,
                                   java.lang.String instBaseClass)
                            throws ClassNameNotSet
Convert this class to an myEnumerated class where the class is defined extensionally by the given set of instances.

Parameters:
instances - - Vector of Strings, each of which is a URI for an instance
instBaseClass -
Throws:
ClassNameNotSet

addClassInstance

public void addClassInstance(java.lang.String instanceURI)
                      throws ClassNameNotSet,
                             RangeIsBasedOnAClass
Add the given instance to the set of individuals that extensionally define the class

Parameters:
instanceURI - - the string containing the URI of the instance to add
Throws:
ClassNameNotSet
RangeIsBasedOnAClass - - if this is not an myEnumerated class

removeClassInstance

public void removeClassInstance(java.lang.String instanceURI)
                         throws ClassNameNotSet,
                                RangeIsBasedOnAClass,
                                InstanceNotInThisRange
removes the given instance from the list of instances that extensionally define the class.

Parameters:
instanceURI - - the string containing the URI of the instance to remove
Throws:
ClassNameNotSet
RangeIsBasedOnAClass - - if this is not an myEnumerated class
InstanceNotInThisRange - - if the instance is not in the class

readFromModel

public void readFromModel(SerializableOntModelImpl dcm,
                          java.lang.String classURI)
to read from an already constructed DAMLModel


resetClassBuilding

public void resetClassBuilding()

getOntClass

public SerializableOntModelImpl getOntClass()
                                     throws BuildingNotCompleted
Return the defined class as OntModel.

Returns:
SerializableOntModel containg the class definition
Throws:
BuildingNotCompleted - if the current class is not fully specified

getOntClassAsText

public java.lang.String getOntClassAsText()
                                   throws BuildingNotCompleted
Return the defined class as text.

Returns:
string containg the class definition
Throws:
BuildingNotCompleted - if the current class is not fully specified

getClassName

public java.lang.String getClassName()
                              throws ValueNotSet
Get the name of the current class.

Returns:
the name of the class
Throws:
ValueNotSet - if value of the class name is not known

addBaseClass

public void addBaseClass(java.lang.String baseClassName)
                  throws ClassNameNotSet,
                         DisjointClassWithAlreadyAdded
Add this class as a superclass to the class being built.

Parameters:
baseClassName - the name of the base class
Throws:
ClassNameNotSet - if the class name has not been set before
DisjointClassWithAlreadyAdded - if the provided class is disjoint with the classes already added

addImmediateBaseClass

public void addImmediateBaseClass(java.lang.String baseClassName)
                           throws ClassNameNotSet,
                                  DisjointClassWithAlreadyAdded
Add this class as a superclass to the class being built. Please note that this method should be called onlu once, and the class name passed to it inidcates the immediate parent of this class. E.g. this KAoS class is = + hence the class name passed to this method = the actual class name. i.e. for a policy 'test' which controls say 'AccessAction', this KAoS Class name would be 'testAccessAction' and the name passed to this method would be 'AccessAction'

Parameters:
baseClassName - the name of the base class
Throws:
ClassNameNotSet - if the class name has not been set before
DisjointClassWithAlreadyAdded - if the provided class is disjoint with the classes already added

addBaseClassComplement

public void addBaseClassComplement(java.lang.String baseClassName)
                            throws DisjointClassWithAlreadyAdded
Add the complement of the base Action class to be controlled by this policy. As a result a new action class will be created, and will be set as a subclass of the given class complement. If this is the first call to this method a new action class is created. If this is a subsequent call, the given class complement will be added to the list of superclasses of the already created action class.

Parameters:
actionBaseClassName - the name of the action superclass whose complemet is to be taken
Throws:
PolicyNameNotSet - if the policy name has not been set before
DisjointClassWithAlreadyAdded - if the provided Action class is disjoint with the classes already added

removeBaseClass

public void removeBaseClass(java.lang.String baseClassName)
                     throws ClassNotSuperClass
Remove the class from the list of superclasses of the built class.

Parameters:
baseClassName - the name of the base class
Throws:
ClassNotSuperClass - if the class was not previously added to the list of superclasses

getBaseClasses

public java.util.Vector getBaseClasses()
                                throws ValueNotSet
Get the superclasses of the current class.

Returns:
the vector containg names of the superclasses
Throws:
ValueNotSet - if superclasses are not known

getImmediateBaseClass

public java.lang.String getImmediateBaseClass()
                                       throws ValueNotSet
Get the immediate base class of this class.

Returns:
the name of the imm. superclasses
Throws:
ValueNotSet - if superclasses are not known

isPropertyRangeBasedOnClass

public boolean isPropertyRangeBasedOnClass(java.lang.String propertyName)
                                    throws ValueNotSet
Check if the range of the specified property is class based or instance based.

Returns:
true if based on a class, false if based on instances
Throws:
ValueNotSet - if the range is not set

setPropertyRangeClass

public void setPropertyRangeClass(java.lang.String propertyName,
                                  java.lang.String propertyClassName)
                           throws ClassNameNotSet
Throws:
ClassNameNotSet

setPropertyRangeClass

public void setPropertyRangeClass(java.lang.String propertyName,
                                  java.lang.String propertyClassName,
                                  java.lang.String type)
                           throws ClassNameNotSet
Set the range of the given poperty to the specified class. If the class is already set it will replace it with the provided one.

Parameters:
propertyName - the name of the property
propertyClassName - the name of the class
Throws:
ClassNameNotSet - if the class name has not been set before

setPropertyRangeClassIntersection

public void setPropertyRangeClassIntersection(java.lang.String propertyName,
                                              java.lang.String baseClassName1,
                                              java.lang.String baseClassName2,
                                              java.lang.String type)
                                       throws ClassNameNotSet
Set the range of the property to the intersection of specified classes.

Parameters:
baseClassName1 - the name of the Actor subclass
baseClassName2 - the name of the Actor subclass
Throws:
ValueNotSet - if the class has not been set before
ClassNameNotSet

setPropertyRangeClassDifference

public void setPropertyRangeClassDifference(java.lang.String propertyName,
                                            java.lang.String baseClassName1,
                                            java.lang.String baseClassName2,
                                            java.lang.String type)
                                     throws ClassNameNotSet
Set the range of the property to the Difference of specified classes. This is done by creating the intersection of the first class and the complement of the other.

Parameters:
baseClassName1 - the name of the Actor subclass
baseClassName2 - the name of the Actor subclass
Throws:
ValueNotSet - if the class has not been set before
ClassNameNotSet

getParentPropertyRangeClass

public java.lang.String getParentPropertyRangeClass(java.lang.String propertyName)
Get the name of the parent class of the class on which the range of the given property is set.

Parameters:
propertyName - the name of the property
Returns:
the name of the parent class

getBasePropertyRangeClass

public java.lang.String getBasePropertyRangeClass(java.lang.String propertyName)
                                           throws ValueNotSet,
                                                  RangeIsBasedOnInstances
Get the name of the class on which the range of the given property is set.

Parameters:
propertyName - the name of the property
Returns:
the name of the class
Throws:
ValueNotSet - if the class is not known
RangeIsBasedOnInstances - if the range is based on instances

getCurrentPropertyRangeClass

public java.lang.String getCurrentPropertyRangeClass(java.lang.String propertyName)
                                              throws ValueNotSet
Get the name of the class on which the range of the given property is set. The difference between this method and getBasePropertyRangeClass() is that this method returns the name of the instance holder class evenif the range is based on instances.

Parameters:
propertyName - the name of the property
Returns:
the name of the class
Throws:
ValueNotSet - if the class is not known

addPropertyRangeInstance

public void addPropertyRangeInstance(java.lang.String propertyName,
                                     java.lang.String instanceName)
                              throws ClassNameNotSet,
                                     RangeIsBasedOnAClass
Throws:
ClassNameNotSet
RangeIsBasedOnAClass

addPropertyRangeInstance

public void addPropertyRangeInstance(java.lang.String propertyName,
                                     java.lang.String instanceName,
                                     java.lang.String type)
                              throws ClassNameNotSet,
                                     RangeIsBasedOnAClass
Add the provided instance to the class being the range of the specified property. If this is a first call to this method a new class is created if this is a subsequent call the provided instance will be added to the list of instances of the already created class.

Parameters:
propertyName - the name of the property
instanceName - the name of the instance to define a range of possible values for this property
Throws:
ClassNameNotSet - if the class name has not been set before
RangeIsBasedOnAClass - if the target range was already set to class

removePropertyRangeInstance

public void removePropertyRangeInstance(java.lang.String propertyName,
                                        java.lang.String instanceName)
                                 throws RangeIsBasedOnAClass,
                                        InstanceNotInThisRange
Remove the provided instance from the class being the range of the specified property. If as the result the class became empty it is removed and the property range is not set.

Parameters:
propertyName - the name of the property
instanceName - the name of the instance to define a range of possible values for this property
Throws:
RangeIsBasedOnAClass - if the property range was already set to class
InstanceNotInThisRange - if the instance was not previously added

getPropertyRangeInstance

public java.lang.String[] getPropertyRangeInstance(java.lang.String propertyName)
                                            throws ValueNotSet,
                                                   RangeIsBasedOnAClass
Get the instances defining the range of the specified property.

Parameters:
propertyName - the name of the property
Returns:
a String array containing names of the instances
Throws:
ValueNotSet - if property range instances are not known
RangeIsBasedOnAClass - if the range is based on class

addRequiredValueOnProperty

public void addRequiredValueOnProperty(java.lang.String propertyName,
                                       java.lang.String instanceName)
                                throws ClassNameNotSet
Add the provided instance to the hasValue property of restriction on the specified property. If this is a first call to this method a new restriction is created, if this is a subsequent call the provided instance will be added to the restriction already created.

Parameters:
propertyName - the name of the property
instanceName - the name of the instance to define a range of possible values for this property
Throws:
ClassNameNotSet - if the class name has not been set before

removeRequiredValueOnProperty

public void removeRequiredValueOnProperty(java.lang.String propertyName,
                                          java.lang.String instanceName)
                                   throws ClassNameNotSet,
                                          ValueNotSet
Remove the provided instance from the hasValue property of restriction on the specified property.

Parameters:
propertyName - the name of the property
instanceName - the name of the instance to define a range of possible values for this property
Throws:
ClassNameNotSet - if the class name has not been set before
ValueNotSet - if the specified value is not found

makeRangeComplement

public void makeRangeComplement(java.lang.String propertyName,
                                java.lang.String propertyClassName)
                         throws AlreadyComplement
Make the range of the property complement of the current range.

Parameters:
propertyName - the name of the property
Throws:
AlreadyComplement - if property range was already made complement

copyPropertyRangeFromOtherPolicy

public void copyPropertyRangeFromOtherPolicy(KAoSClassBuilderImpl sourcePolicy,
                                             java.lang.String propertyName)
Copies the property range data for the specified range to the current policy from the provided source policy

Parameters:
sourcePolicy - KAoSPolicyBuilder containing the source policy
propertyName - the name of the property

getRangeComplementParentClass

public java.lang.String getRangeComplementParentClass(java.lang.String propertyName)
                                               throws ValueNotSet
Get the parent class of the complement of the given property range.

Parameters:
propertyName - the name of the property
Returns:
the name of the said parent class
Throws:
ValueNotSet - if the complement or the parent class is not set

isRangeComplement

public boolean isRangeComplement(java.lang.String propertyName)
Check if the range of the property is a complement.

Parameters:
propertyName - the name of the property
Returns:
true if complement, false if not

getPropertyNames

public java.util.Vector getPropertyNames()

getRestrictionTypeName

public java.lang.String getRestrictionTypeName(java.lang.String propertyName)
                                        throws ValueNotSet
Throws:
ValueNotSet

showClass

public void showClass(Logger log,
                      int level)
Print the class to the screen in XML format


toString

public java.lang.String toString()
Rerurn class string in XML format

Overrides:
toString in class java.lang.Object

printDebugString

protected static void printDebugString(java.lang.String msg,
                                       int loggerDisplayLevel)
Utility method to print debug messages.