com.bbn.swede.core.dom
Class OASTNode

java.lang.Object
  extended bycom.bbn.swede.core.dom.OASTNode
Direct Known Subclasses:
AttributeNode, DocumentRoot, TagNode, TextNode

public abstract class OASTNode
extends Object

Common implementation and factory methods for OAST nodes. This class includes general utility functions and default implementations of many node-specific methods with generic handling for language elements. OASTNode also provides node creation methods that create the correct node type given just a tag or attribute QName.

Author:
jlerner

Nested Class Summary
 class OASTNode.NodeCleanupVisitor
          Calls OASTNode.cleanup() on visited nodes in preparation for their removal.
 class OASTNode.NodeInitVisitor
          Calls OASTNode.init() on visited nodes in response to their insertion.
 
Field Summary
protected  int _iLength
          The length in charactrs of this node within the document.
protected  int _iOffset
          The character offset of this node within the document.
protected  OASTNode _nodeParent
          The parent of this node.
protected  IOWLAbstractSyntaxTree _tree
          The tree to which this node is attached.
static String[] AS_OWL
          Array of element names for items in the OWL namespace.
static String[] AS_RDF
          Array of element names for items in the RDF namespace.
static String[] AS_RDFS
          Array of element names for items in the RDFS namespace.
static int BASE
          Type constant indicating an XML base node.
static int COMMENT
          Type constant indicating an XML comment node.
static int DOCTYPE
          Type constant indicating a DOCTYPE node.
static int DOCUMENT
          Type constant indicating a document root node.
static int GENERICATTRIBUTE
          Type constant indicating a generic attribute node.
static int GENERICPREDICATE
          Type constant indicating a generic predicate node.
static int GENERICTHING
          Type constant indicating a generic thing node.
static int LITERAL
          Type constant indicating a literal node.
static int NAMESPACE
          Type constant indicating an XML namespace node.
static int OWL
          Type constant indicating the start of the OWL node types.
static int OWL_ALLDIFFERENT
          Type constant indicating an owl:AllDifferent node.
static int OWL_ALLVALUESFROM
          Type constant indicating an owl:allValuesFrom node.
static int OWL_ANNOTATIONPROPERTY
          Type constant indicating an owl:AnnotationProperty node.
static int OWL_BACKWARDCOMPATIBLEWITH
          Type constant indicating an owl:backwardCompatibleWith node.
static int OWL_CARDINALITY
          Type constant indicating an owl:cardinality node.
static int OWL_CLASS
          Type constant indicating an owl:Class node.
static int OWL_COMPLEMENTOF
          Type constant indicating an owl:complimentOf node.
static int OWL_DATARANGE
          Type constant indicating an owl:DataRange node.
static int OWL_DATATYPEPROPERTY
          Type constant indicating an owl:DatatypeProperty node.
static int OWL_DEPRECATEDCLASS
          Type constant indicating an owl:DeprecatedClass node.
static int OWL_DEPRECATEDPROPERTY
          Type constant indicating an owl:DeprecatedProperty node.
static int OWL_DIFFERENTFROM
          Type constant indicating an owl:differentFrom node.
static int OWL_DISJOINTWITH
          Type constant indicating an owl:disjointWith node.
static int OWL_DISTINCTMEMBERS
          Type constant indicating an owl:distinctMembers node.
static int OWL_EQUIVALENTCLASS
          Type constant indicating an owl:equivalentClass node.
static int OWL_EQUIVALENTPROPERTY
          Type constant indicating an owl:equivalentProperty node.
static int OWL_FUNCTIONALPROPERTY
          Type constant indicating an owl:FunctionalProperty node.
static int OWL_HASVALUE
          Type constant indicating an owl:hasValue node.
static int OWL_IMPORTS
          Type constant indicating an owl:imports node.
static int OWL_INCOMPATIBLEWITH
          Type constant indicating an owl:incompatibleWith node.
static int OWL_INTERSECTIONOF
          Type constant indicating an owl:intersectionOf node.
static int OWL_INVERSEFUNCTIONALPROPERTY
          Type constant indicating an owl:InverseFunctionalProperty node.
static int OWL_INVERSEOF
          Type constant indicating an owl:inverseOf node.
static int OWL_MAXCARDINALITY
          Type constant indicating an owl:maxCardinality node.
static int OWL_MINCARDINALITY
          Type constant indicating an owl:minCardinality node.
static int OWL_NOTHING
          Type constant indicating an owl:Nothing node.
static int OWL_OBJECTPROPERTY
          Type constant indicating an owl:ObjectProperty node.
static int OWL_ONEOF
          Type constant indicating an owl:oneOf node.
static int OWL_ONPROPERTY
          Type constant indicating an owl:onProperty node.
static int OWL_ONTOLOGY
          Type constant indicating an owl:Ontology node.
static int OWL_ONTOLOGYPROPERTY
          Type constant indicating an owl:OntologyProperty node.
static int OWL_PRIORVERSION
          Type constant indicating an owl:priorVersion node.
static int OWL_RESTRICTION
          Type constant indicating an owl:Restriction node.
static int OWL_SAMEAS
          Type constant indicating an owl:sameAs node.
static int OWL_SOMEVALUESFROM
          Type constant indicating an owl:someValuesFrom node.
static int OWL_SYMMETRICPROPERTY
          Type constant indicating an owl:SymmetricProperty node.
static int OWL_THING
          Type constant indicating an owl:Thing node.
static int OWL_TRANSITIVEPROPERTY
          Type constant indicating an owl:TransitiveProperty node.
static int OWL_UNIONOF
          Type constant indicating an owl:unionOf node.
static int OWL_VERSIONINFO
          Type constant indicating an owl:versionInfo node.
static int PROCESSING_INSTRUCTION
          Type constant indicating an XML processing instruction node.
protected static int RDF
          Type constant indicating the start of the RDF node types.
static int RDF_ABOUT
          Type constant indicating an rdf:about node.
static int RDF_ALT
          Type constant indicating an rdf:Alt node.
static int RDF_BAG
          Type constant indicating an rdf:Bag node.
static int RDF_DATATYPE
          Type constant indicating an rdf:datatype node.
static int RDF_DESCRIPTION
          Type constant indicating an rdf:Description node.
static int RDF_FIRST
          Type constant indicating an rdf:first node.
static int RDF_ID
          Type constant indicating an rdf:ID node.
static int RDF_LIST
          Type constant indicating an rdf:List node.
static int RDF_NODEID
          Type constant indicating an rdf:nodeID node.
static int RDF_OBJECT
          Type constant indicating an rdf:object node.
static int RDF_PARSETYPE
          Type constant indicating an rdf:parseType node.
static int RDF_PREDICATE
          Type constant indicating an rdf:predicate node.
static int RDF_PROPERTY
          Type constant indicating an rdf:Property node.
static int RDF_RDF
          Type constant indicating an rdf:RDF node.
static int RDF_RESOURCE
          Type constant indicating an rdf:resource node.
static int RDF_REST
          Type constant indicating an rdf:rest node.
static int RDF_SEQ
          Type constant indicating an rdf:Seq node.
static int RDF_STATEMENT
          Type constant indicating an rdf:Statement node.
static int RDF_SUBJECT
          Type constant indicating an rdf:subject node.
static int RDF_TYPE
          Type constant indicating an rdf:type node.
static int RDF_VALUE
          Type constant indicating an rdf:value node.
static int RDF_XMLLITERAL
          Type constant indicating an rdf:XMLLiteral node.
static int RDFS
          Type constant indicating the start of the RDFS node types.
static int RDFS_CLASS
          Type constant indicating an rdfs:Class node.
static int RDFS_COMMENT
          Type constant indicating an rdfs:comment node.
static int RDFS_CONTAINER
          Type constant indicating an rdfs:Container node.
static int RDFS_CONTAINERMEMBERSHIPPROPERTY
          Type constant indicating an rdfs:ContainerMembershipProperty node.
static int RDFS_DATATYPE
          Type constant indicating an rdfs:Datatype node.
static int RDFS_DOMAIN
          Type constant indicating an rdfs:domain node.
static int RDFS_ISDEFINEDBY
          Type constant indicating an rdfs:isDefinedBy node.
static int RDFS_LABEL
          Type constant indicating an rdfs:label node.
static int RDFS_LITERAL
          Type constant indicating an rdfs:Literal node.
static int RDFS_MEMBER
          Type constant indicating an rdfs:member node.
static int RDFS_RANGE
          Type constant indicating an rdfs:domain node.
static int RDFS_RESOURCE
          Type constant indicating an rdfs:Resource node.
static int RDFS_SEEALSO
          Type constant indicating an rdfs:seeAlso node.
static int RDFS_SUBCLASSOF
          Type constant indicating an rdfs:subClassOf node.
static int RDFS_SUBPROPERTYOF
          Type constant indicating an rdfs:subPropertyOf node.
static String S_OWL_URI
          The URI of the OWL language specification.
static String S_RDF_URI
          The URI of the RDF language specification.
static String S_RDFS_URI
          The URI of the RDFS language specification.
static String S_XSD_URI
          The URI of the XML schema.
static int UNPARSEABLE
          Type constant indicating an unparseable node.
static int XML_VERSION
          Type constant indicating an XML version node.
 
Constructor Summary
OASTNode()
          Constructs a new node with no parent and no children.
 
Method Summary
 void accept(IOASTNodeVisitor visitor)
          Performs a preorder traversal starting with this node.
protected abstract  int[] allowedChildren()
          Returns an array of node types indicating what is allowed as a child of the node.
protected  void appendChild(OASTNode node)
          Adds a node to the end of this node's child list.
 void attach(IOWLAbstractSyntaxTree tree, boolean bDisplace)
          Attaches the node to an OWL abstract syntax tree at its stored offset and length.
protected  void cleanup()
          Cleanup method called when a node is detached from an IOWLAbstractSyntaxTree.
 Object clone()
          Creates a deep copy of a node and all nodes below it in the tree.
(package private)  OASTNode createChild(String sQName)
          Creates a node for a specific qualified name and appends it as a child of this node.
(package private)  AttributeNode createChildAttribute(String sQName, String sValue)
          Creates a node for a specified qualified attribute name and attribute value and appends it as a child of this node.
 void detach(boolean bDisplace)
          Detaches the node from its associated OWL abstract syntax tree.
 boolean displace(int offset, int length)
          Adjust the node's offset or length to reflect the addition or removal of characters in the file.
protected static boolean displace(OASTNode node, int offset, int length)
          Static helper method for node displacement.
protected abstract  OASTNode duplicateType()
          Creates a new OAST node of the same type as this one.
 boolean endsBefore(int offset)
          Checks if the node ends before specific offset.
 OASTNode findCommonAncestor(OASTNode other)
          Finds a common ancestor for this node and another one at the lowest possible level in the tree.
protected  Base findXmlBase()
          Recursive helper method for getXmlBase().
abstract  String generateNodeText()
          Subclasses must implement this method to provide text representing the contents of the node and its children.
 OASTNode[] getChildren()
          Returns a list of this node's children.
 OASTNode getContainingChild(int offset)
          Finds the most specific node that contains a given offset.
 String getDefaultNamespace()
          Locates the default namespace in the scope of this node.
 OASTNode getFirstChild()
          Retrieves the first non-attribute child of the node.
 AttributeNode getLastAttribute()
          Retrieves the last attribute child of the node.
 int getLength()
          Retrieves the length of the node, in characters.
 int getLevel()
          Calculates the node's depth in the tree.
protected  Object getLockObject()
          Returns an object that can be used to synchronize editing operations on the node.
 String getName()
          Returns the node's local name.
 String getNamespace()
          Returns the namespace abbreviation for the node.
 Map getNamespaces()
          Compiles a list of namespaces in the scope of this node.
 OASTNode getNextChild(OASTNode child)
          Locates the node after a specified entry in this node's child list.
 OASTNode[] getNodesOfType(int iNodeType)
          Compiles a list of all nodes of a particular type in the subtree rooted at this node.
 OASTNode[] getNodesOfType(int iNodeType, int iDepth)
          Compiles a list of all nodes of a particular type in the subtree rooted at this node, up to a specified maximum depth.
abstract  int getNodeType()
          Returns an integer indicating a node's type.
 int getOffset()
          Retrieves the character offset that marks the beginning of the node.
 IOWLAbstractSyntaxTree getOWLAbstractSyntaxTree()
          Returns the tree the node is attached to.
 IOWLDocument getOWLDocument()
          Finds the OWL document that this node is from.
 OASTNode getParent()
          Returns the node's parent.
 OASTNode getPreviousChild(OASTNode child)
          Locates the node before a specified entry in this node's child list.
 String getQName()
          Returns the node's qualified name.
static String getQName(int iNodeType)
          Returns the qualified name associated with a particular node type.
protected  OASTNode getRoot()
          Retrieves the root node of the tree containing this node.
 String getUri()
          Returns the full URI of the node.
 String getXmlBase()
          Locates the XML base in the scope of this node.
protected  void init()
          Initialization method called when a node is attached to an IOWLAbstractSyntaxTree.
 void insert(OASTNode child, boolean bDisplace)
          Inserts a child node into this node.
static boolean match(String qName, int iNodeType)
          Checks if a qualified name is correct for a specific node type.
 void remove(OASTNode child, boolean bDisplace)
          Removes a child node from this node.
 void replace(OASTNode oldChild, OASTNode newChild)
          Replaces an existing child node with a new one.
protected  void setLength(int iLength)
          Sets the length of the node, in characters.
protected  void setOffset(int iOffset)
          Sets the character offset that marks the beginning of the node.
abstract  IRegion[] simplePartitioning()
          Returns a rough partitioning of the node based on the node's tag structure; child nodes are not taken into account.
 boolean startsAfter(int offset)
          Checks if the node starts on or after a specific offset.
 String toString()
          Returns a string representation of the node.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOCUMENT

public static final int DOCUMENT
Type constant indicating a document root node.

See Also:
Constant Field Values

NAMESPACE

public static final int NAMESPACE
Type constant indicating an XML namespace node. This is an attribute node type.

See Also:
Constant Field Values

BASE

public static final int BASE
Type constant indicating an XML base node. This is an attribute node type.

See Also:
Constant Field Values

LITERAL

public static final int LITERAL
Type constant indicating a literal node. This is a text node type.

See Also:
Constant Field Values

GENERICTHING

public static final int GENERICTHING

Type constant indicating a generic thing node. This is a class node type.

A tag will be created as a generic given the following conditions:

  1. The tag's qname is not recognized as a language element
  2. The tag's parent is an rdf:RDF tag or a property node

See Also:
Constant Field Values

GENERICPREDICATE

public static final int GENERICPREDICATE

Type constant indicating a generic predicate node. This is a property node type.

A tag will be created as a generic given the following conditions:

  1. The tag's qname is not recognized as a language element
  2. The tag's parent is a class node

See Also:
Constant Field Values

GENERICATTRIBUTE

public static final int GENERICATTRIBUTE

Type constant indicating a generic attribute node. This is an attribute node type.

An attribute will be created as a generic if its qname is unrecognized or is ordinarily considered a class or property element from one of the language namespaces.

See Also:
Constant Field Values

UNPARSEABLE

public static final int UNPARSEABLE

Type constant indicating an unparseable node. This is a text node type.

Unparseable nodes represent XML errors in the document. They are kept isolated so the rest of the document remains usable and are indicated by an error marker.

See Also:
Constant Field Values

COMMENT

public static final int COMMENT
Type constant indicating an XML comment node. This is a text node type.

See Also:
Constant Field Values

PROCESSING_INSTRUCTION

public static final int PROCESSING_INSTRUCTION

Type constant indicating an XML processing instruction node. This is a text node type.

Processing instructions, along with other XML prolog nodes, are prepended on all partial parses to ensure that the parser uses the proper encoding and entity substitutions.

See Also:
Constant Field Values

DOCTYPE

public static final int DOCTYPE

Type constant indicating a DOCTYPE node. This is a text node type.

DOCTYPEs, along with other XML prolog nodes, are prepended on all partial parses to ensure that the parser uses the proper encoding and entity substitutions.

See Also:
Constant Field Values

XML_VERSION

public static final int XML_VERSION

Type constant indicating an XML version node. This is a text node type.

The XML version tag, along with other XML prolog nodes, is prepended on all partial parses to ensure that the parser uses the proper encoding and entity substitutions.

See Also:
Constant Field Values

RDF

protected static final int RDF
Type constant indicating the start of the RDF node types. Indices into the RDF element name array can be obtained by subtracting this value from any of the RDF_* type constants.

See Also:
AS_RDF, Constant Field Values

RDF_RDF

public static final int RDF_RDF
Type constant indicating an rdf:RDF node. This is a tag node type.

See Also:
Constant Field Values

RDF_DESCRIPTION

public static final int RDF_DESCRIPTION
Type constant indicating an rdf:Description node. This is a class node type.

See Also:
Constant Field Values

RDF_XMLLITERAL

public static final int RDF_XMLLITERAL
Type constant indicating an rdf:XMLLiteral node.

See Also:
Constant Field Values

RDF_PROPERTY

public static final int RDF_PROPERTY
Type constant indicating an rdf:Property node. This is a class node type.

See Also:
Constant Field Values

RDF_STATEMENT

public static final int RDF_STATEMENT
Type constant indicating an rdf:Statement node.

See Also:
Constant Field Values

RDF_BAG

public static final int RDF_BAG
Type constant indicating an rdf:Bag node.

See Also:
Constant Field Values

RDF_SEQ

public static final int RDF_SEQ
Type constant indicating an rdf:Seq node.

See Also:
Constant Field Values

RDF_ALT

public static final int RDF_ALT
Type constant indicating an rdf:Alt node.

See Also:
Constant Field Values

RDF_LIST

public static final int RDF_LIST
Type constant indicating an rdf:List node. This is a class node type.

See Also:
Constant Field Values

RDF_TYPE

public static final int RDF_TYPE
Type constant indicating an rdf:type node. This is a property node type.

See Also:
Constant Field Values

RDF_FIRST

public static final int RDF_FIRST
Type constant indicating an rdf:first node. This is a property node type.

See Also:
Constant Field Values

RDF_REST

public static final int RDF_REST
Type constant indicating an rdf:rest node. This is a property node type.

See Also:
Constant Field Values

RDF_VALUE

public static final int RDF_VALUE
Type constant indicating an rdf:value node.

See Also:
Constant Field Values

RDF_SUBJECT

public static final int RDF_SUBJECT
Type constant indicating an rdf:subject node.

See Also:
Constant Field Values

RDF_PREDICATE

public static final int RDF_PREDICATE
Type constant indicating an rdf:predicate node.

See Also:
Constant Field Values

RDF_OBJECT

public static final int RDF_OBJECT
Type constant indicating an rdf:object node.

See Also:
Constant Field Values

RDF_ID

public static final int RDF_ID
Type constant indicating an rdf:ID node. This is an attribute node type.

See Also:
Constant Field Values

RDF_ABOUT

public static final int RDF_ABOUT
Type constant indicating an rdf:about node. This is an attribute node type.

See Also:
Constant Field Values

RDF_RESOURCE

public static final int RDF_RESOURCE
Type constant indicating an rdf:resource node. This is an attribute node type.

See Also:
Constant Field Values

RDF_DATATYPE

public static final int RDF_DATATYPE
Type constant indicating an rdf:datatype node. This is an attribute node type.

See Also:
Constant Field Values

RDF_NODEID

public static final int RDF_NODEID
Type constant indicating an rdf:nodeID node. This is an attribute node type.

See Also:
Constant Field Values

RDF_PARSETYPE

public static final int RDF_PARSETYPE
Type constant indicating an rdf:parseType node. This is an attribute node type.

See Also:
Constant Field Values

AS_RDF

public static final String[] AS_RDF
Array of element names for items in the RDF namespace.


RDFS

public static final int RDFS
Type constant indicating the start of the RDFS node types. Indices into the RDFS element name array can be obtained by subtracting this value from any of the RDFS_* type constants.

See Also:
AS_RDFS, Constant Field Values

RDFS_COMMENT

public static final int RDFS_COMMENT
Type constant indicating an rdfs:comment node. This is a property node type.

See Also:
Constant Field Values

RDFS_LABEL

public static final int RDFS_LABEL
Type constant indicating an rdfs:label node. This is a property node type.

See Also:
Constant Field Values

RDFS_SUBCLASSOF

public static final int RDFS_SUBCLASSOF
Type constant indicating an rdfs:subClassOf node. This is a property node type.

See Also:
Constant Field Values

RDFS_RESOURCE

public static final int RDFS_RESOURCE
Type constant indicating an rdfs:Resource node.

See Also:
Constant Field Values

RDFS_LITERAL

public static final int RDFS_LITERAL
Type constant indicating an rdfs:Literal node.

See Also:
Constant Field Values

RDFS_CLASS

public static final int RDFS_CLASS
Type constant indicating an rdfs:Class node. This is a class node type.

See Also:
Constant Field Values

RDFS_DATATYPE

public static final int RDFS_DATATYPE
Type constant indicating an rdfs:Datatype node.

See Also:
Constant Field Values

RDFS_CONTAINER

public static final int RDFS_CONTAINER
Type constant indicating an rdfs:Container node.

See Also:
Constant Field Values

RDFS_CONTAINERMEMBERSHIPPROPERTY

public static final int RDFS_CONTAINERMEMBERSHIPPROPERTY
Type constant indicating an rdfs:ContainerMembershipProperty node.

See Also:
Constant Field Values

RDFS_SUBPROPERTYOF

public static final int RDFS_SUBPROPERTYOF
Type constant indicating an rdfs:subPropertyOf node. This is a property node type.

See Also:
Constant Field Values

RDFS_DOMAIN

public static final int RDFS_DOMAIN
Type constant indicating an rdfs:domain node. This is a property node type.

See Also:
Constant Field Values

RDFS_RANGE

public static final int RDFS_RANGE
Type constant indicating an rdfs:domain node. This is a property node type.

See Also:
Constant Field Values

RDFS_MEMBER

public static final int RDFS_MEMBER
Type constant indicating an rdfs:member node.

See Also:
Constant Field Values

RDFS_SEEALSO

public static final int RDFS_SEEALSO
Type constant indicating an rdfs:seeAlso node. This is a property node type.

See Also:
Constant Field Values

RDFS_ISDEFINEDBY

public static final int RDFS_ISDEFINEDBY
Type constant indicating an rdfs:isDefinedBy node.

See Also:
Constant Field Values

AS_RDFS

public static final String[] AS_RDFS
Array of element names for items in the RDFS namespace.


OWL

public static final int OWL
Type constant indicating the start of the OWL node types. Indices into the RDFS element name array can be obtained by subtracting this value from any of the OWL_* type constants.

See Also:
AS_OWL, Constant Field Values

OWL_CLASS

public static final int OWL_CLASS
Type constant indicating an owl:Class node. This is a class node type.

See Also:
Constant Field Values

OWL_DATATYPEPROPERTY

public static final int OWL_DATATYPEPROPERTY
Type constant indicating an owl:DatatypeProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_OBJECTPROPERTY

public static final int OWL_OBJECTPROPERTY
Type constant indicating an owl:ObjectProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_RESTRICTION

public static final int OWL_RESTRICTION
Type constant indicating an owl:Restriction node. This is a class node type.

See Also:
Constant Field Values

OWL_ONPROPERTY

public static final int OWL_ONPROPERTY
Type constant indicating an owl:onProperty node. This is a property node type.

See Also:
Constant Field Values

OWL_ONTOLOGY

public static final int OWL_ONTOLOGY
Type constant indicating an owl:Ontology node. This is a class node type.

See Also:
Constant Field Values

OWL_VERSIONINFO

public static final int OWL_VERSIONINFO
Type constant indicating an owl:versionInfo node. This is a property node type.

See Also:
Constant Field Values

OWL_IMPORTS

public static final int OWL_IMPORTS
Type constant indicating an owl:imports node. This is a property node type.

See Also:
Constant Field Values

OWL_ALLDIFFERENT

public static final int OWL_ALLDIFFERENT
Type constant indicating an owl:AllDifferent node. This is a class node type.

See Also:
Constant Field Values

OWL_ANNOTATIONPROPERTY

public static final int OWL_ANNOTATIONPROPERTY
Type constant indicating an owl:AnnotationProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_DATARANGE

public static final int OWL_DATARANGE
Type constant indicating an owl:DataRange node. This is a class node type.

See Also:
Constant Field Values

OWL_DEPRECATEDCLASS

public static final int OWL_DEPRECATEDCLASS
Type constant indicating an owl:DeprecatedClass node. This is a class node type.

See Also:
Constant Field Values

OWL_DEPRECATEDPROPERTY

public static final int OWL_DEPRECATEDPROPERTY
Type constant indicating an owl:DeprecatedProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_FUNCTIONALPROPERTY

public static final int OWL_FUNCTIONALPROPERTY
Type constant indicating an owl:FunctionalProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_INVERSEFUNCTIONALPROPERTY

public static final int OWL_INVERSEFUNCTIONALPROPERTY
Type constant indicating an owl:InverseFunctionalProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_NOTHING

public static final int OWL_NOTHING
Type constant indicating an owl:Nothing node.

See Also:
Constant Field Values

OWL_ONTOLOGYPROPERTY

public static final int OWL_ONTOLOGYPROPERTY
Type constant indicating an owl:OntologyProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_SYMMETRICPROPERTY

public static final int OWL_SYMMETRICPROPERTY
Type constant indicating an owl:SymmetricProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_THING

public static final int OWL_THING
Type constant indicating an owl:Thing node. This is a class node type.

See Also:
Constant Field Values

OWL_TRANSITIVEPROPERTY

public static final int OWL_TRANSITIVEPROPERTY
Type constant indicating an owl:TransitiveProperty node. This is a class node type.

See Also:
Constant Field Values

OWL_ALLVALUESFROM

public static final int OWL_ALLVALUESFROM
Type constant indicating an owl:allValuesFrom node. This is a property node type.

See Also:
Constant Field Values

OWL_BACKWARDCOMPATIBLEWITH

public static final int OWL_BACKWARDCOMPATIBLEWITH
Type constant indicating an owl:backwardCompatibleWith node. This is a property node type.

See Also:
Constant Field Values

OWL_CARDINALITY

public static final int OWL_CARDINALITY
Type constant indicating an owl:cardinality node. This is a property node type.

See Also:
Constant Field Values

OWL_COMPLEMENTOF

public static final int OWL_COMPLEMENTOF
Type constant indicating an owl:complimentOf node. This is a property node type.

See Also:
Constant Field Values

OWL_DIFFERENTFROM

public static final int OWL_DIFFERENTFROM
Type constant indicating an owl:differentFrom node. This is a property node type.

See Also:
Constant Field Values

OWL_DISTINCTMEMBERS

public static final int OWL_DISTINCTMEMBERS
Type constant indicating an owl:distinctMembers node. This is a property node type.

See Also:
Constant Field Values

OWL_EQUIVALENTCLASS

public static final int OWL_EQUIVALENTCLASS
Type constant indicating an owl:equivalentClass node. This is a property node type.

See Also:
Constant Field Values

OWL_EQUIVALENTPROPERTY

public static final int OWL_EQUIVALENTPROPERTY
Type constant indicating an owl:equivalentProperty node. This is a property node type.

See Also:
Constant Field Values

OWL_HASVALUE

public static final int OWL_HASVALUE
Type constant indicating an owl:hasValue node. This is a property node type.

See Also:
Constant Field Values

OWL_INCOMPATIBLEWITH

public static final int OWL_INCOMPATIBLEWITH
Type constant indicating an owl:incompatibleWith node. This is a property node type.

See Also:
Constant Field Values

OWL_INTERSECTIONOF

public static final int OWL_INTERSECTIONOF
Type constant indicating an owl:intersectionOf node. This is a property node type.

See Also:
Constant Field Values

OWL_INVERSEOF

public static final int OWL_INVERSEOF
Type constant indicating an owl:inverseOf node. This is a property node type.

See Also:
Constant Field Values

OWL_MAXCARDINALITY

public static final int OWL_MAXCARDINALITY
Type constant indicating an owl:maxCardinality node. This is a property node type.

See Also:
Constant Field Values

OWL_MINCARDINALITY

public static final int OWL_MINCARDINALITY
Type constant indicating an owl:minCardinality node. This is a property node type.

See Also:
Constant Field Values

OWL_ONEOF

public static final int OWL_ONEOF
Type constant indicating an owl:oneOf node. This is a property node type.

See Also:
Constant Field Values

OWL_PRIORVERSION

public static final int OWL_PRIORVERSION
Type constant indicating an owl:priorVersion node. This is a property node type.

See Also:
Constant Field Values

OWL_SAMEAS

public static final int OWL_SAMEAS
Type constant indicating an owl:sameAs node. This is a property node type.

See Also:
Constant Field Values

OWL_SOMEVALUESFROM

public static final int OWL_SOMEVALUESFROM
Type constant indicating an owl:someValuesFrom node. This is a property node type.

See Also:
Constant Field Values

OWL_UNIONOF

public static final int OWL_UNIONOF
Type constant indicating an owl:unionOf node. This is a property node type.

See Also:
Constant Field Values

OWL_DISJOINTWITH

public static final int OWL_DISJOINTWITH
Type constant indicating an owl:disjointWith node. This is a property node type.

See Also:
Constant Field Values

AS_OWL

public static final String[] AS_OWL
Array of element names for items in the OWL namespace.


S_XSD_URI

public static final String S_XSD_URI
The URI of the XML schema. This document contains definitions for the XSD datatypes.

See Also:
Constant Field Values

S_OWL_URI

public static final String S_OWL_URI
The URI of the OWL language specification.

See Also:
Constant Field Values

S_RDFS_URI

public static final String S_RDFS_URI
The URI of the RDFS language specification.

See Also:
Constant Field Values

S_RDF_URI

public static final String S_RDF_URI
The URI of the RDF language specification.

See Also:
Constant Field Values

_iOffset

protected int _iOffset
The character offset of this node within the document.


_iLength

protected int _iLength
The length in charactrs of this node within the document.


_nodeParent

protected OASTNode _nodeParent
The parent of this node. Apart from the document root, all nodes attached to an OAST must have a parent. Any node may act as the root of a detached node tree, indicated by a null parent.


_tree

protected IOWLAbstractSyntaxTree _tree
The tree to which this node is attached.

Constructor Detail

OASTNode

public OASTNode()
Constructs a new node with no parent and no children.

Method Detail

getNamespace

public String getNamespace()
Returns the namespace abbreviation for the node. This implementation returns one of "owl", "rdfs", or "rdf" for language nodes or null for anything else. Subclasses that represent non-language tags or attributes should override this method to return a non-null namespace.

Returns:
The namespace abbreviation for the node, or null if it is not a language node

getName

public String getName()
Returns the node's local name. This implementation returns local names for language nodes, and null for everything else. Subclasses that represent non-language tags and attributes should override this method to return a non-null local name.

Returns:
The local name of the node, or null if it is not a language node

getQName

public String getQName()
Returns the node's qualified name. This implementation returns qnames for language nodes, and null for everything else. Subclasses that represent non-language tags and attributes should override this method to return a non-null qname.

Returns:
The qualified name of the node, or null if it is not a lanuage node

getUri

public String getUri()
Returns the full URI of the node. This implementation returns URIs only for language nodes, and null for everything else. Subclasses that represent non-language tags and attributes should override this method to return a non-null URI.

Returns:
The node's URI, or null if it is not a language node.

getQName

public static String getQName(int iNodeType)
Returns the qualified name associated with a particular node type. Node types are defined as public static fields in OASTNode.

Parameters:
iNodeType - Node type whose qname will be returned
Returns:
A qname for node types of the form RDF_*, RDFS_*, and OWL_*, otherwise null.

match

public static boolean match(String qName,
                            int iNodeType)
Checks if a qualified name is correct for a specific node type. Node types are defined as public static fields in OASTNode.

Parameters:
qName - The qualified name to check
iNodeType - The node type to check against
Returns:
true if the node type matches the qname, false if not

setOffset

protected void setOffset(int iOffset)
Sets the character offset that marks the beginning of the node. This method is only intended for setting node positions before attaching them to a tree. No node displacement will be performed as a result of this change.

Parameters:
iOffset - The new begin offset

setLength

protected void setLength(int iLength)
Sets the length of the node, in characters. This method is only intended for setting node sizes before attaching them to a tree. No node displacement will be performed as a result of this change.

Parameters:
iLength - The new character length

getOffset

public int getOffset()
Retrieves the character offset that marks the beginning of the node.

Returns:
The current begin offset

getLength

public int getLength()
Retrieves the length of the node, in characters.

Returns:
The current character length

allowedChildren

protected abstract int[] allowedChildren()
Returns an array of node types indicating what is allowed as a child of the node. Node types are defined as public static fields in OASTNode. This method is not currently used, but will eventually become important for real-time syntax checking.

Returns:
An array of allowed node types.

getNodeType

public abstract int getNodeType()
Returns an integer indicating a node's type. Subclasses must override this method to return one of the node types defined as public static fields in OASTNode. There is a distinct node type for each langauge element as well as several additional types for generics and XML constructs.

Returns:
The type of this node

getParent

public OASTNode getParent()
Returns the node's parent. Every node in an OAST must have a parent, except for the document root node.

Returns:
The parent node, or null if this node is the document root.

appendChild

protected void appendChild(OASTNode node)
Adds a node to the end of this node's child list. No attention is paid to the new child's offset or the offsets of the existing children. This node will also be set as the parent of the appended child node. This method is only intended for use when building a node structure in memory while parsing a document.

Parameters:
node - The new child node to append

getLockObject

protected Object getLockObject()
Returns an object that can be used to synchronize editing operations on the node. If the node is attached to an OWL abstract syntax tree, the tree is returned. Otherwise, the root node of this node's detached subtree is used.

Returns:
An object that can be used to synchronize editing operations

getContainingChild

public OASTNode getContainingChild(int offset)
Finds the most specific node that contains a given offset.

Parameters:
offset - The offset to locate in the subtree rooted at this node
Returns:
The lowest-level node in the tree that contains the specified offset

createChild

OASTNode createChild(String sQName)
Creates a node for a specific qualified name and appends it as a child of this node. This method is able to create language nodes and generic nodes for XML tags

Parameters:
sQName - Qaulified name indicating the type of the new child
Returns:
The new node

createChildAttribute

AttributeNode createChildAttribute(String sQName,
                                   String sValue)
Creates a node for a specified qualified attribute name and attribute value and appends it as a child of this node. This method is able to create attribute nodes for language elements, XML namespaces, XML base, and generics.

Parameters:
sQName - Qualified name of the attribute
sValue - Value of the attribute
Returns:
The new node

getNodesOfType

public OASTNode[] getNodesOfType(int iNodeType)
Compiles a list of all nodes of a particular type in the subtree rooted at this node. This node will be included in the results, if it matches.

Parameters:
iNodeType - The node type to search for
Returns:
A list of all nodes in this subtree matching the specified type, or an empty list if there are no matches.

getNodesOfType

public OASTNode[] getNodesOfType(int iNodeType,
                                 int iDepth)
Compiles a list of all nodes of a particular type in the subtree rooted at this node, up to a specified maximum depth. This node will be included in the results, if it matches.

Parameters:
iNodeType - The node type to search for
iDepth - The number of levels to search. 0 indicates just this node, 1 indicates this node and its children, etc...
Returns:
A list of all nodes in the specified levels of this subtree matching the specified type, or an empty list if there are no matches.

getChildren

public OASTNode[] getChildren()
Returns a list of this node's children.

Returns:
The node's list of children

getPreviousChild

public OASTNode getPreviousChild(OASTNode child)
Locates the node before a specified entry in this node's child list.

Parameters:
child - The child whose previous sibling will be located
Returns:
The node before the specified one in the child list, or null if either the specified node is the first child of this node or is not a child of it at all.

getNextChild

public OASTNode getNextChild(OASTNode child)
Locates the node after a specified entry in this node's child list.

Parameters:
child - The child whose next sibling will be located
Returns:
The node after the specified one in the child list, or null if either the specified node is the last child of this node or is not a child at all.

getNamespaces

public Map getNamespaces()
Compiles a list of namespaces in the scope of this node. In the unlikely event of redefined namespace abbreviations, the definition closer to this node in the tree will be used.

Returns:
A java.util.Map containing namespace abbreviations and the associated full URI

getDefaultNamespace

public String getDefaultNamespace()
Locates the default namespace in the scope of this node.

Returns:
The URI of the default namespace or null if no default namespace is found

getXmlBase

public String getXmlBase()
Locates the XML base in the scope of this node.

Returns:
The URI of the XML base, or null if no XML base is found.

findXmlBase

protected Base findXmlBase()
Recursive helper method for getXmlBase(). This method uses getParent() to move up the tree until it either locates a Base node or runs out of tree.

Returns:
A Base node representing the XML base for this node, or null if no XML base is found.

toString

public String toString()
Returns a string representation of the node. The default implementation just returns the node's qname, but subclasses may override it to supply something more appropriate.

Returns:
A string representation of the node.

getLevel

public int getLevel()
Calculates the node's depth in the tree. Note that the document root is considered to be at depth 0.

Returns:
The depth of the node.

findCommonAncestor

public OASTNode findCommonAncestor(OASTNode other)
Finds a common ancestor for this node and another one at the lowest possible level in the tree. In the best case, this node contains the other node (or vice versa) and is simply returned. In the worst case, the common ancestor might be the document root.

Parameters:
other - The node to find a common ancestor with
Returns:
The lowest-level node that includes both this node and other.

accept

public final void accept(IOASTNodeVisitor visitor)
Performs a preorder traversal starting with this node. Traversals are synchronized against the containing OAST to ensure that visitors do not run concurrently.

Parameters:
visitor - The visitor to call at each step of the recursion

startsAfter

public boolean startsAfter(int offset)
Checks if the node starts on or after a specific offset.

Parameters:
offset - The offset to compare against
Returns:
true if this node begins on or after the offset, false otherwise

endsBefore

public boolean endsBefore(int offset)
Checks if the node ends before specific offset.

Parameters:
offset - The offset to compare against
Returns:
true if this node ends before on or at the offset, false otherwise

generateNodeText

public abstract String generateNodeText()
Subclasses must implement this method to provide text representing the contents of the node and its children. This method is only used by the editor for inserting an extrnally-constructed node (i.e., as a result of a New... wizard) into the text. The formatting of the generated text is thus unimportant, as it will likely be modified by the Auto-Indent Strategy and Content Formatter anyway.

Returns:
A text approximation of the node and its children

init

protected void init()
Initialization method called when a node is attached to an IOWLAbstractSyntaxTree. Subclasses may override this method to perform additional custom setup, but must call super.init() to execute standard initialization code.


cleanup

protected void cleanup()
Cleanup method called when a node is detached from an IOWLAbstractSyntaxTree. Subclasses may override this method to perform additional custom cleanup operations, but must call super.cleanup() to execute standard destruction code.


getOWLDocument

public IOWLDocument getOWLDocument()
Finds the OWL document that this node is from.

Returns:
The OWL document that contains this node

getLastAttribute

public AttributeNode getLastAttribute()
Retrieves the last attribute child of the node.

Returns:
The last attribute child, or null if there are no attributes

getFirstChild

public OASTNode getFirstChild()
Retrieves the first non-attribute child of the node.

Returns:
The first non-attribute child, or null if there are no child nodes or all children are attributes

simplePartitioning

public abstract IRegion[] simplePartitioning()

Returns a rough partitioning of the node based on the node's tag structure; child nodes are not taken into account. Partitioning should be as follows:

Returns:
A rough partitioning of the node.

displace

public boolean displace(int offset,
                        int length)
Adjust the node's offset or length to reflect the addition or removal of characters in the file.

Parameters:
offset - Position in the document where the change occurred. This node's position will only be changed if some or all of it occurs after this offset.
length - Magnitude of the position adjustment. May be negative.
Returns:
true if the node was displaced, false if not

displace

protected static boolean displace(OASTNode node,
                                  int offset,
                                  int length)
Static helper method for node displacement.

Parameters:
node - The node to displace
offset - Position in the document where the change occurred. This node's position will only be changed if some or all of it occurs after this offset.
length - Magnitude of the position adjustment. May be negative.
Returns:
true if the node was displaced, false if not

insert

public void insert(OASTNode child,
                   boolean bDisplace)
            throws OASTException

Inserts a child node into this node. The tree containing this node can optionally be displaced first to make room for it the new child. The child will be inserted at its stored offset, which must fall inside of this node.

If this node is attached to an OWL abstract syntax tree, the new child node will be attached to it and an event will be dispatched to all OAST event listeners to alert them to the insertion.

Parameters:
child - the new child node to insert
bDisplace - true if the tree needs to be displaced to make room for child, false if there is already space for it.
Throws:
OASTException - if this node is attached to a read-only OAST or the starting offset of the new child does not fall within this node

attach

public void attach(IOWLAbstractSyntaxTree tree,
                   boolean bDisplace)

Attaches the node to an OWL abstract syntax tree at its stored offset and length. As an optional first step, nodes already in the tree will be displaced to make room for this node. Next, the appropriate parent/child relationships will be created to tie the node to the tree. Finally, init() will be called on this node and all of its descendants once the node is fully attached to the OAST.

Any further edit operation against this node or any of its descendants will be synchronized against the specified OAST until it is removed from the tree by calling detach(boolean). If this node is already attached to an OAST, it will be detached from it first, with displacement.

This method is for internal use by API functions and the parser and is not intended for use by clients.

Parameters:
tree - The tree to attach the node to
bDisplace - true to have the tree displace existing nodes to make room before attaching this one, false if there is already space for it.

replace

public void replace(OASTNode oldChild,
                    OASTNode newChild)
             throws OASTException

Replaces an existing child node with a new one. The tree will be displaced to compensate for the removal and insertion.

If this node is attached to an OWL abstract syntax tree, the removed child will be detached from it, the replacement child will be attached to it, and an event will be dispatched to all OAST event listeners to alert them to the change.

Parameters:
oldChild - The child to remove
newChild - The child to insert in oldChild's place.
Throws:
OASTException - if this node is attached to a read-only OAST, oldChild is not a child of this node, or newChild is null.

remove

public void remove(OASTNode child,
                   boolean bDisplace)
            throws OASTException

Removes a child node from this node. The tree containing this node can optionally be displaced afterwards to compensate for the removed child.

If this node is attached to an OWL abstract syntax tree, the removed child node will be detached from it and an event will be dispatched to all OAST event listeners to alert them to the removal.

Parameters:
child - the child node to remove
bDisplace - true if the tree needs to be displaced to make room for child, false if there is already space for it.
Throws:
OASTException - if this node is attached to a read-only OAST or child is not a child of this node.

detach

public void detach(boolean bDisplace)

Detaches the node from its associated OWL abstract syntax tree. First, cleanup() will be called on this node and all of its descendants, while this node is still attached to the tree. Next, the parent/child relationships tying the node to the tree will be removed. As an optional final step, the remaining nodes in the tree will be displaced to compensate for the removal.

This method is for internal use by API functions and the parser and is not intended for use by clients.

Parameters:
bDisplace - true to have the tree displace existing nodes to make room before attaching this one, false if there is already space for it.

getRoot

protected OASTNode getRoot()
Retrieves the root node of the tree containing this node. This will be a DocumentRoot if the node is attached to an OAST. If this node is not attached to an OAST, the root node may be of any type.

Returns:
The root node of this node's tree

getOWLAbstractSyntaxTree

public IOWLAbstractSyntaxTree getOWLAbstractSyntaxTree()
Returns the tree the node is attached to.

Returns:
The tree the node is attached to, or null if it is not currently attached to any tree.

duplicateType

protected abstract OASTNode duplicateType()
Creates a new OAST node of the same type as this one.

Returns:
A new node of the same node type

clone

public Object clone()
Creates a deep copy of a node and all nodes below it in the tree. The resulting copy is not attached to any OWL abstract syntax tree.

Returns:
A deep copy of this node, including copies of any node structure below it in the tree.


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