com.bbn.swede.core.dom
Class ClassNode

java.lang.Object
  extended bycom.bbn.swede.core.dom.OASTNode
      extended bycom.bbn.swede.core.dom.TagNode
          extended bycom.bbn.swede.core.dom.ClassNode
Direct Known Subclasses:
AllDifferent, AnnotationProperty, DataRange, DatatypeProperty, DeprecatedClass, DeprecatedProperty, Description, FunctionalProperty, GenericThing, InverseFunctionalProperty, Klass, Klass, List, ObjectProperty, Ontology, OntologyProperty, Property, Restriction, SymmetricProperty, Thing, TransitiveProperty

public abstract class ClassNode
extends TagNode

Common implementation for class nodes. A class node is a tag that is interpreted as an OWL Thing, either due to the type of the tag or based on its position in the document relative to other thing or predicate tags.

Author:
jlerner

Nested Class Summary
 
Nested classes inherited from class com.bbn.swede.core.dom.OASTNode
OASTNode.NodeCleanupVisitor, OASTNode.NodeInitVisitor
 
Field Summary
protected  Resource _resAssoc
          The Jena resource associated with this class node.
protected  Statement _stmtImplicitType
          The rdf:Type statement implied by this tag.
 
Fields inherited from class com.bbn.swede.core.dom.OASTNode
_iLength, _iOffset, _nodeParent, _tree, AS_OWL, AS_RDF, AS_RDFS, BASE, COMMENT, DOCTYPE, DOCUMENT, GENERICATTRIBUTE, GENERICPREDICATE, GENERICTHING, LITERAL, NAMESPACE, OWL, OWL_ALLDIFFERENT, OWL_ALLVALUESFROM, OWL_ANNOTATIONPROPERTY, OWL_BACKWARDCOMPATIBLEWITH, OWL_CARDINALITY, OWL_CLASS, OWL_COMPLEMENTOF, OWL_DATARANGE, OWL_DATATYPEPROPERTY, OWL_DEPRECATEDCLASS, OWL_DEPRECATEDPROPERTY, OWL_DIFFERENTFROM, OWL_DISJOINTWITH, OWL_DISTINCTMEMBERS, OWL_EQUIVALENTCLASS, OWL_EQUIVALENTPROPERTY, OWL_FUNCTIONALPROPERTY, OWL_HASVALUE, OWL_IMPORTS, OWL_INCOMPATIBLEWITH, OWL_INTERSECTIONOF, OWL_INVERSEFUNCTIONALPROPERTY, OWL_INVERSEOF, OWL_MAXCARDINALITY, OWL_MINCARDINALITY, OWL_NOTHING, OWL_OBJECTPROPERTY, OWL_ONEOF, OWL_ONPROPERTY, OWL_ONTOLOGY, OWL_ONTOLOGYPROPERTY, OWL_PRIORVERSION, OWL_RESTRICTION, OWL_SAMEAS, OWL_SOMEVALUESFROM, OWL_SYMMETRICPROPERTY, OWL_THING, OWL_TRANSITIVEPROPERTY, OWL_UNIONOF, OWL_VERSIONINFO, PROCESSING_INSTRUCTION, RDF, RDF_ABOUT, RDF_ALT, RDF_BAG, RDF_DATATYPE, RDF_DESCRIPTION, RDF_FIRST, RDF_ID, RDF_LIST, RDF_NODEID, RDF_OBJECT, RDF_PARSETYPE, RDF_PREDICATE, RDF_PROPERTY, RDF_RDF, RDF_RESOURCE, RDF_REST, RDF_SEQ, RDF_STATEMENT, RDF_SUBJECT, RDF_TYPE, RDF_VALUE, RDF_XMLLITERAL, RDFS, RDFS_CLASS, RDFS_COMMENT, RDFS_CONTAINER, RDFS_CONTAINERMEMBERSHIPPROPERTY, RDFS_DATATYPE, RDFS_DOMAIN, RDFS_ISDEFINEDBY, RDFS_LABEL, RDFS_LITERAL, RDFS_MEMBER, RDFS_RANGE, RDFS_RESOURCE, RDFS_SEEALSO, RDFS_SUBCLASSOF, RDFS_SUBPROPERTYOF, S_OWL_URI, S_RDF_URI, S_RDFS_URI, S_XSD_URI, UNPARSEABLE, XML_VERSION
 
Constructor Summary
ClassNode()
          Default constructor for class nodes.
ClassNode(boolean bSingleton)
          Creates a parentless and childless ClassNode as either a singleton or with discrete begin and end tags.
 
Method Summary
 void addPropertyLiteral(String sQName, String sLiteral)
          Adds a literal property to this individual.
 void addPropertyResource(String sQName, String sResourceURI)
          Adds a property to this individual whose object is a resource defined by a tag elsewhere.
 void addPropertyTag(String sQName, ClassNode nodeObject)
          Adds a property to this individual whose object is another individual.
protected  Resource createJenaResource(Model model)
          Creates a Jena resource to represent the class node.
 Resource getAssociatedResource()
          Retrieve the Jena resource associated with the node.
 Statement getImplicitTypeStatement()
          Retrieves the Jena statement indicating the implicit type of this node.
 PropertyNode[] getProperties(String sQName)
          Retrieves all properties of this individual with a speicifed QName.
protected  void removeJenaResource(Model model)
          Removes the class node's associated resource from the Jena model.
 void removeProperty(PropertyNode property)
          Removes a property from this node.
protected  void setAssociatedResource(Resource res)
          Associate the node with a Jena resource.
protected  void setImplicitTypeStatement(Statement stmt)
          Associates the node with an implicit type statement.
 
Methods inherited from class com.bbn.swede.core.dom.TagNode
addAttribute, appendChildAttribute, appendChildTag, clone, create, create, createRegions, createSingletonRegion, displace, duplicateType, generateNodeText, getAttribute, getAttributes, initRegions, isSingleton, prependChildAttribute, prependChildTag, removeAttribute, removeAttribute, setAttribute, setBeginRegion, setEndRegion, simplePartitioning, splitSingleton
 
Methods inherited from class com.bbn.swede.core.dom.OASTNode
accept, allowedChildren, appendChild, attach, cleanup, createChild, createChildAttribute, detach, displace, endsBefore, findCommonAncestor, findXmlBase, getChildren, getContainingChild, getDefaultNamespace, getFirstChild, getLastAttribute, getLength, getLevel, getLockObject, getName, getNamespace, getNamespaces, getNextChild, getNodesOfType, getNodesOfType, getNodeType, getOffset, getOWLAbstractSyntaxTree, getOWLDocument, getParent, getPreviousChild, getQName, getQName, getRoot, getUri, getXmlBase, init, insert, match, remove, replace, setLength, setOffset, startsAfter, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_resAssoc

protected Resource _resAssoc
The Jena resource associated with this class node.


_stmtImplicitType

protected Statement _stmtImplicitType
The rdf:Type statement implied by this tag. May be null if no type is implied (i.e. for rdf:Description rdf:about= nodes).

Constructor Detail

ClassNode

public ClassNode()
Default constructor for class nodes. Creates a parentless and childless node with discrete begin/end tags.


ClassNode

public ClassNode(boolean bSingleton)
Creates a parentless and childless ClassNode as either a singleton or with discrete begin and end tags.

Parameters:
bSingleton - true to create a singleton tag, false to create discrete begin and end tags.
Method Detail

setAssociatedResource

protected void setAssociatedResource(Resource res)
Associate the node with a Jena resource.

Parameters:
res - The resource to associate. May be null to disassociate the previous resource without setting a new one.

setImplicitTypeStatement

protected void setImplicitTypeStatement(Statement stmt)
Associates the node with an implicit type statement.

Parameters:
stmt - The implicit type statement to associate. May be null to disassociate the previous implicit type without setting a new one.

getAssociatedResource

public Resource getAssociatedResource()
Retrieve the Jena resource associated with the node.

Returns:
The associated resource, or null if no resource is associated with this node.

getImplicitTypeStatement

public Statement getImplicitTypeStatement()
Retrieves the Jena statement indicating the implicit type of this node.

Returns:
The implicit type statement, or null if this class node does not imply a type.

createJenaResource

protected Resource createJenaResource(Model model)

Creates a Jena resource to represent the class node. If one of the node's children is an rdf:ID, or rdf:about node, the corresponding attribute value will be used as the resource's URI. If one of its children is an rdf:NodeID, the corresponding attribute value will be used as the resource's anonymous ID. If none of these is present, an anonymous resource is created. If more than one of these attributes is present, the behavior is undefined.

If an rdf:ID or rdf:about attribute specifies a URI that already exists in the model, the existing resource will be used rather than creating a new one.

For all class nodes except rdf:Description, a statement will automatically be added to the resource to reflect its implicity type.

Parameters:
model - The model in which to create the resource.
Returns:
The created resource

removeJenaResource

protected void removeJenaResource(Model model)
Removes the class node's associated resource from the Jena model. If the node has no associated resource, nothing happens.

Parameters:
model - The model to remove the resource from.

addPropertyLiteral

public void addPropertyLiteral(String sQName,
                               String sLiteral)
                        throws OASTException
Adds a literal property to this individual. An individual may have multiple properties with the same QName.

Parameters:
sQName - the qualified name of the property
sLiteral - the text to use as the property's object. If this is an empty string, a property will be created with a zero-length literal as its object. If this is null, no property will be created.
Throws:
OASTException - if this node is attached to a read-only OAST or sQName does not specifies a non-property node type from one of the language namespaces.

addPropertyTag

public void addPropertyTag(String sQName,
                           ClassNode nodeObject)
                    throws OASTException
Adds a property to this individual whose object is another individual. The tags for the object will be nested inside of the property tags

Parameters:
sQName - the qualified name of the property
nodeObject - the tag to use as the property's object
Throws:
OASTException - if this node is attached to a read-only OAST or sQName does not specifies a non-property node type from one of the language namespaces.

addPropertyResource

public void addPropertyResource(String sQName,
                                String sResourceURI)
                         throws OASTException
Adds a property to this individual whose object is a resource defined by a tag elsewhere.

Parameters:
sQName - the qualified name of the property
sResourceURI - the URI of the resource to use as the property's object
Throws:
OASTException - if this node is attached to a read-only OAST or sQName does not specifies a non-property node type from one of the language namespaces.

getProperties

public PropertyNode[] getProperties(String sQName)
Retrieves all properties of this individual with a speicifed QName.

Parameters:
sQName - the qualified name of the properties to retrieve
Returns:
An array (possibly empty) of all properties with the specified QName.

removeProperty

public void removeProperty(PropertyNode property)
                    throws OASTException
Removes a property from this node.

Parameters:
property - The property to remove
Throws:
OASTException - if this node is attached to a read-only OAST


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.