com.bbn.swede.core.dom
Class AttributeNode

java.lang.Object
  extended bycom.bbn.swede.core.dom.OASTNode
      extended bycom.bbn.swede.core.dom.AttributeNode
Direct Known Subclasses:
About, Base, GenericAttribute, ID, Namespace, NodeID, ParseType, Resource

public abstract class AttributeNode
extends OASTNode

Common implementation for nodes representing XML attributes.

Author:
jlerner

Nested Class Summary
 
Nested classes inherited from class com.bbn.swede.core.dom.OASTNode
OASTNode.NodeCleanupVisitor, OASTNode.NodeInitVisitor
 
Field Summary
protected  String _sValue
          The value of this attribute.
 
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
AttributeNode(String sValue)
          Creates an attribute node.
 
Method Summary
protected  int[] allowedChildren()
          Returns an array of node types indicating what is allowed as a child of the node.
 Object clone()
          Creates a deep copy of a node and all nodes below it in the tree.
static AttributeNode create(String sQName, String sValue)
          Factory method for creating attribute nodes.
 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  OASTNode duplicateType()
          Creates a new OAST node of the same type as this one.
 String generateNodeText()
          Subclasses must implement this method to provide text representing the contents of the node and its children.
 String getValue()
          Retrieves the attribute value.
protected  void initRegions()
          Initializes the simple partitioning of the attribute node.
 void setValue(String sValue)
          Sets the attribute's value.
(package private)  void setValueRegion(int offset)
          Sets the portion of the attribute node region that contains the value.
 IRegion[] simplePartitioning()
          Returns a rough partitioning of the node based on the node's tag structure; child nodes are not taken into account.
 String toString()
          Returns a string representation of the node.
 
Methods inherited from class com.bbn.swede.core.dom.OASTNode
accept, 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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_sValue

protected String _sValue
The value of this attribute.

Constructor Detail

AttributeNode

public AttributeNode(String sValue)
Creates an attribute node.

Parameters:
sValue - The value of the attribute.
Method Detail

initRegions

protected void initRegions()
Initializes the simple partitioning of the attribute node.


allowedChildren

protected final int[] allowedChildren()
Description copied from class: OASTNode
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.

Specified by:
allowedChildren in class OASTNode
Returns:
An array of allowed node types.

getValue

public String getValue()
Retrieves the attribute value.

Returns:
The attribute value.

setValue

public void setValue(String sValue)
              throws OASTException
Sets the attribute's value.

Parameters:
sValue - The new attribute value.
Throws:
OASTException - if this node is attached to a read-only OAST

toString

public String toString()
Description copied from class: OASTNode
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.

Overrides:
toString in class OASTNode
Returns:
A string representation of the node.

generateNodeText

public String generateNodeText()
Description copied from class: OASTNode
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.

Specified by:
generateNodeText in class OASTNode
Returns:
A text approximation of the node and its children

simplePartitioning

public IRegion[] simplePartitioning()
Description copied from class: OASTNode

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:

Specified by:
simplePartitioning in class OASTNode
Returns:
A rough partitioning of the node.

setValueRegion

void setValueRegion(int offset)

Sets the portion of the attribute node region that contains the value. Only an offset for the beginning of the value region needs to be provided, as it is assumed to end at the same offset as the attribute node itself.

This method also implicitly sets the attribute name region to start at the attribute node's starting offset and end right before the value region.

Parameters:
offset - The starting offset of the value region.

displace

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

Overrides:
displace in class OASTNode
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

duplicateType

protected OASTNode duplicateType()
Description copied from class: OASTNode
Creates a new OAST node of the same type as this one.

Specified by:
duplicateType in class OASTNode
Returns:
A new node of the same node type

clone

public Object clone()
Description copied from class: OASTNode
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.

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

create

public static AttributeNode create(String sQName,
                                   String sValue)
Factory method for creating attribute nodes. If the specified QName is recognized as an attribute from the RDF, RDFS, or OWL language, a custom node of the appropriate type will be created and returned. Otherwise, a generic attribute is created. The new attribute node will have no parent and no children.

Parameters:
sQName - The qualified name for the attribute node
sValue - The value of the attribute
Returns:
An attribute node of the specified type, or a generic attribute if an unknown or non-attribute node type is specified.


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