Java Doc for AttrImpl.java in  » Web-Server » Rimfaxe-Web-Server » org » apache » xerces » dom » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Rimfaxe Web Server » org.apache.xerces.dom 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.xerces.dom.NodeImpl
      org.apache.xerces.dom.AttrImpl

All known Subclasses:   org.apache.xerces.dom.DeferredAttrImpl,  org.apache.xerces.dom.AttrNSImpl,
AttrImpl
public class AttrImpl extends NodeImpl implements Attr(Code)
Attribute represents an XML-style attribute of an Element. Typically, the allowable values are controlled by its declaration in the Document Type Definition (DTD) governing this kind of document.

If the attribute has not been explicitly assigned a value, but has been declared in the DTD, it will exist and have that default. Only if neither the document nor the DTD specifies a value will the Attribute really be considered absent and have no value; in that case, querying the attribute will return null.

Attributes may have multiple children that contain their data. (XML allows attributes to contain entity references, and tokenized attribute types such as NMTOKENS may have a child for each token.) For convenience, the Attribute object's getValue() method returns the string version of the attribute's value.

Attributes are not children of the Elements they belong to, in the usual sense, and have no valid Parent reference. However, the spec says they _do_ belong to a specific Element, and an INUSE exception is to be thrown if the user attempts to explicitly share them between elements.

Note that Elements do not permit attributes to appear to be shared (see the INUSE exception), so this object's mutability is officially not an issue.

Note: The ownerNode attribute is used to store the Element the Attr node is associated with. Attr nodes do not have parent nodes. Besides, the getOwnerElement() method can be used to get the element node this attribute is associated with.

AttrImpl does not support Namespaces. AttrNSImpl, which inherits from it, does.

AttrImpl used to inherit from ParentNode. It now directly inherits from NodeImpl and provide its own implementation of the ParentNode's behavior. The reason is that we now try and avoid to always create a Text node to hold the value of an attribute. The DOM spec requires it, so we still have to do it in case getFirstChild() is called for instance. The reason attribute values are stored as a list of nodes is so that they can carry more than a simple string. They can also contain EntityReference nodes. However, most of the times people only have a single string that they only set and get through Element.set/getAttribute or Attr.set/getValue. In this new version, the Attr node has a value pointer which can either be the String directly or a pointer to the first ChildNode. A flag tells which one it currently is. Note that while we try to stick with the direct String as much as possible once we've switched to a node there is no going back. This is because we have no way to know whether the application keeps referring to the node we once returned.

The gain in memory varies on the density of attributes in the document. But in the tests I've run I've seen up to 12% of memory gain. And the good thing is that it also leads to a slight gain in speed because we allocate fewer objects! I mean, that's until we have to actually create the node...

To avoid too much duplicated code, I got rid of ParentNode and renamed ChildAndParentNode, which I never really liked, to ParentNode for simplicity, this doesn't make much of a difference in memory usage because there are only very few objects that are only a Parent. This is only true now because AttrImpl now inherits directly from NodeImpl and has its own implementation of the ParentNode's node behavior. So there is still some duplicated code there.

This class doesn't directly support mutation events, however, it notifies the document when mutations are performed so that the document class do so.

WARNING: Some of the code here is partially duplicated in ParentNode, be careful to keep these two classes in sync!
See Also:   AttrNSImpl
author:
   Arnaud Le Hors, IBM
author:
   Joe Kesselman, IBM
author:
   Andy Clark, IBM
since:
   PR-DOM-Level-1-19980818.



Field Summary
protected  Stringname
     Attribute name.
final static  longserialVersionUID
     Serialization version.
protected static  TextImpltextNode
    
protected  Objectvalue
     This can either be a String or the first child node.

Constructor Summary
protected  AttrImpl(CoreDocumentImpl ownerDocument, String name)
     Attribute has no public constructor.
protected  AttrImpl()
    

Method Summary
 voidcheckNormalizationAfterInsert(ChildNode insertedChild)
     Checks the normalized state of this node after inserting a child.
 voidcheckNormalizationAfterRemove(ChildNode previousSibling)
     Checks the normalized of this node after removing a child.
public  NodecloneNode(boolean deep)
    
public  NodeListgetChildNodes()
     Obtain a NodeList enumerating all children of this node.
public  ElementgetElement()
     Returns the element node that this attribute is associated with, or null if the attribute has not been added to an element.
public  NodegetFirstChild()
     The first child of this Node, or null if none.
public  NodegetLastChild()
     The last child of this Node, or null if none.
public  intgetLength()
    
public  StringgetName()
    
public  StringgetNodeName()
    
public  shortgetNodeType()
     A short integer indicating what type of node this is.
public  StringgetNodeValue()
     In Attribute objects, NodeValue is considered a synonym for Value.
public  ElementgetOwnerElement()
     Returns the element node that this attribute is associated with, or null if the attribute has not been added to an element.
public  booleangetSpecified()
     The "specified" flag is true if and only if this attribute's value was explicitly specified in the original document.
public  StringgetValue()
     The "string value" of an Attribute is its text representation, which in turn is a concatenation of the string values of its children.
public  booleanhasChildNodes()
     Test whether this node has any children.
public  NodeinsertBefore(Node newChild, Node refChild)
     Move one or more node(s) to our list of children.
 NodeinternalInsertBefore(Node newChild, Node refChild, boolean replace)
     NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able to control which mutation events are spawned.
 NodeinternalRemoveChild(Node oldChild, boolean replace)
     NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able to control which mutation events are spawned.
public  Nodeitem(int index)
     NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds.
final  ChildNodelastChild()
    
final  voidlastChild(ChildNode node)
    
protected  voidmakeChildNode()
    
public  voidnormalize()
    
public  NoderemoveChild(Node oldChild)
     Remove a child from this Node.
public  NodereplaceChild(Node newChild, Node oldChild)
     Make newChild occupy the location that oldChild used to have.
public  voidsetNodeValue(String value)
     Implicit in the rerouting of getNodeValue to getValue is the need to redefine setNodeValue, for symmetry's sake.
 voidsetOwnerDocument(CoreDocumentImpl doc)
    
public  voidsetReadOnly(boolean readOnly, boolean deep)
     Override default behavior so that if deep is true, children are also toggled.
public  voidsetSpecified(boolean arg)
    
public  voidsetValue(String newvalue)
     The DOM doesn't clearly define what setValue(null) means.
protected  voidsynchronizeChildren()
     Override this method in subclass to hook in efficient internal data structure.
public  StringtoString()
    

Field Detail
name
protected String name(Code)
Attribute name.



serialVersionUID
final static long serialVersionUID(Code)
Serialization version.



textNode
protected static TextImpl textNode(Code)



value
protected Object value(Code)
This can either be a String or the first child node.




Constructor Detail
AttrImpl
protected AttrImpl(CoreDocumentImpl ownerDocument, String name)(Code)
Attribute has no public constructor. Please use the factory method in the Document class.



AttrImpl
protected AttrImpl()(Code)




Method Detail
checkNormalizationAfterInsert
void checkNormalizationAfterInsert(ChildNode insertedChild)(Code)
Checks the normalized state of this node after inserting a child. If the inserted child causes this node to be unnormalized, then this node is flagged accordingly. The conditions for changing the normalized state are:
  • The inserted child is a text node and one of its adjacent siblings is also a text node.
  • The inserted child is is itself unnormalized.

Parameters:
  insertedChild - the child node that was inserted into this node
throws:
  NullPointerException - if the inserted child is null



checkNormalizationAfterRemove
void checkNormalizationAfterRemove(ChildNode previousSibling)(Code)
Checks the normalized of this node after removing a child. If the removed child causes this node to be unnormalized, then this node is flagged accordingly. The conditions for changing the normalized state are:
  • The removed child had two adjacent siblings that were text nodes.

Parameters:
  previousSibling - the previous sibling of the removed child, ornull



cloneNode
public Node cloneNode(boolean deep)(Code)



getChildNodes
public NodeList getChildNodes()(Code)
Obtain a NodeList enumerating all children of this node. If there are none, an (initially) empty NodeList is returned.

NodeLists are "live"; as children are added/removed the NodeList will immediately reflect those changes. Also, the NodeList refers to the actual nodes, so changes to those nodes made via the DOM tree will be reflected in the NodeList and vice versa.

In this implementation, Nodes implement the NodeList interface and provide their own getChildNodes() support. Other DOMs may solve this differently.




getElement
public Element getElement()(Code)
Returns the element node that this attribute is associated with, or null if the attribute has not been added to an element.
See Also:   AttrImpl.getOwnerElement



getFirstChild
public Node getFirstChild()(Code)
The first child of this Node, or null if none.



getLastChild
public Node getLastChild()(Code)
The last child of this Node, or null if none.



getLength
public int getLength()(Code)
NodeList method: Count the immediate children of this node int



getName
public String getName()(Code)
In Attributes, NodeName is considered a synonym for the attribute's Name



getNodeName
public String getNodeName()(Code)
Returns the attribute name



getNodeType
public short getNodeType()(Code)
A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.



getNodeValue
public String getNodeValue()(Code)
In Attribute objects, NodeValue is considered a synonym for Value.
See Also:   AttrImpl.getValue()



getOwnerElement
public Element getOwnerElement()(Code)
Returns the element node that this attribute is associated with, or null if the attribute has not been added to an element.
since:
   WD-DOM-Level-2-19990719



getSpecified
public boolean getSpecified()(Code)
The "specified" flag is true if and only if this attribute's value was explicitly specified in the original document. Note that the implementation, not the user, is in charge of this property. If the user asserts an Attribute value (even if it ends up having the same value as the default), it is considered a specified attribute. If you really want to revert to the default, delete the attribute from the Element, and the Implementation will re-assert the default (if any) in its place, with the appropriate specified=false setting.



getValue
public String getValue()(Code)
The "string value" of an Attribute is its text representation, which in turn is a concatenation of the string values of its children.



hasChildNodes
public boolean hasChildNodes()(Code)
Test whether this node has any children. Convenience shorthand for (Node.getFirstChild()!=null)



insertBefore
public Node insertBefore(Node newChild, Node refChild) throws DOMException(Code)
Move one or more node(s) to our list of children. Note that this implicitly removes them from their previous parent.
Parameters:
  newChild - The Node to be moved to our subtree. As aconvenience feature, inserting a DocumentNode will instead insertall its children.
Parameters:
  refChild - Current child which newChild should be placedimmediately before. If refChild is null, the insertion occursafter all existing Nodes, like appendChild().
throws:
  DOMException - (HIERARCHY_REQUEST_ERR) if newChild is of atype that shouldn't be a child of this node, or if newChild is anancestor of this node.
throws:
  DOMException - (WRONG_DOCUMENT_ERR) if newChild has adifferent owner document than we do.
throws:
  DOMException - (NOT_FOUND_ERR) if refChild is not a child ofthis node.
throws:
  DOMException - (NO_MODIFICATION_ALLOWED_ERR) if this node isread-only.



internalInsertBefore
Node internalInsertBefore(Node newChild, Node refChild, boolean replace) throws DOMException(Code)
NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able to control which mutation events are spawned. This version of the insertBefore operation allows us to do so. It is not intended for use by application programs.



internalRemoveChild
Node internalRemoveChild(Node oldChild, boolean replace) throws DOMException(Code)
NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able to control which mutation events are spawned. This version of the removeChild operation allows us to do so. It is not intended for use by application programs.



item
public Node item(int index)(Code)
NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds. org.w3c.dom.Node
Parameters:
  Index - int



lastChild
final ChildNode lastChild()(Code)



lastChild
final void lastChild(ChildNode node)(Code)



makeChildNode
protected void makeChildNode()(Code)



normalize
public void normalize()(Code)



removeChild
public Node removeChild(Node oldChild) throws DOMException(Code)
Remove a child from this Node. The removed child's subtree remains intact so it may be re-inserted elsewhere. oldChild, in its new state (removed).
throws:
  DOMException - (NOT_FOUND_ERR) if oldChild is not a child ofthis node.
throws:
  DOMException - (NO_MODIFICATION_ALLOWED_ERR) if this node isread-only.



replaceChild
public Node replaceChild(Node newChild, Node oldChild) throws DOMException(Code)
Make newChild occupy the location that oldChild used to have. Note that newChild will first be removed from its previous parent, if any. Equivalent to inserting newChild before oldChild, then removing oldChild.
throws:
  DOMException - (HIERARCHY_REQUEST_ERR) if newChild is of atype that shouldn't be a child of this node, or if newChild isone of our ancestors.
throws:
  DOMException - (WRONG_DOCUMENT_ERR) if newChild has adifferent owner document than we do.
throws:
  DOMException - (NOT_FOUND_ERR) if oldChild is not a child ofthis node.
throws:
  DOMException - (NO_MODIFICATION_ALLOWED_ERR) if this node isread-only.



setNodeValue
public void setNodeValue(String value) throws DOMException(Code)
Implicit in the rerouting of getNodeValue to getValue is the need to redefine setNodeValue, for symmetry's sake. Note that since we're explicitly providing a value, Specified should be set true.... even if that value equals the default.



setOwnerDocument
void setOwnerDocument(CoreDocumentImpl doc)(Code)
NON-DOM set the ownerDocument of this node and its children



setReadOnly
public void setReadOnly(boolean readOnly, boolean deep)(Code)
Override default behavior so that if deep is true, children are also toggled.
See Also:   Node
See Also:   


See Also:   Note: this will not change the state of an EntityReference or its
See Also:   children, which are always read-only.




setSpecified
public void setSpecified(boolean arg)(Code)
NON-DOM, for use by parser



setValue
public void setValue(String newvalue)(Code)
The DOM doesn't clearly define what setValue(null) means. I've taken it as "remove all children", which from outside should appear similar to setting it to the empty string.



synchronizeChildren
protected void synchronizeChildren()(Code)
Override this method in subclass to hook in efficient internal data structure.



toString
public String toString()(Code)
NON-DOM method for debugging convenience



Fields inherited from org.apache.xerces.dom.NodeImpl
final public static short ELEMENT_DEFINITION_NODE(Code)(Java Doc)
final protected static short FIRSTCHILD(Code)(Java Doc)
final protected static short HASSTRING(Code)(Java Doc)
final protected static short IGNORABLEWS(Code)(Java Doc)
final protected static short OWNED(Code)(Java Doc)
final protected static short READONLY(Code)(Java Doc)
final protected static short SPECIFIED(Code)(Java Doc)
final protected static short SYNCCHILDREN(Code)(Java Doc)
final protected static short SYNCDATA(Code)(Java Doc)
final protected static short UNNORMALIZED(Code)(Java Doc)
protected short flags(Code)(Java Doc)
protected NodeImpl ownerNode(Code)(Java Doc)
final static long serialVersionUID(Code)(Java Doc)

Methods inherited from org.apache.xerces.dom.NodeImpl
public void addEventListener(String type, EventListener listener, boolean useCapture)(Code)(Java Doc)
public Node appendChild(Node newChild) throws DOMException(Code)(Java Doc)
protected void changed()(Code)(Java Doc)
protected int changes()(Code)(Java Doc)
public Node cloneNode(boolean deep)(Code)(Java Doc)
public boolean dispatchEvent(Event event)(Code)(Java Doc)
public NamedNodeMap getAttributes()(Code)(Java Doc)
public NodeList getChildNodes()(Code)(Java Doc)
public Node getFirstChild()(Code)(Java Doc)
public Node getLastChild()(Code)(Java Doc)
public int getLength()(Code)(Java Doc)
public String getLocalName()(Code)(Java Doc)
public String getNamespaceURI()(Code)(Java Doc)
public Node getNextSibling()(Code)(Java Doc)
abstract public String getNodeName()(Code)(Java Doc)
abstract public short getNodeType()(Code)(Java Doc)
public String getNodeValue()(Code)(Java Doc)
public Document getOwnerDocument()(Code)(Java Doc)
public Node getParentNode()(Code)(Java Doc)
public String getPrefix()(Code)(Java Doc)
public Node getPreviousSibling()(Code)(Java Doc)
public boolean getReadOnly()(Code)(Java Doc)
public Object getUserData()(Code)(Java Doc)
public boolean hasAttributes()(Code)(Java Doc)
public boolean hasChildNodes()(Code)(Java Doc)
final boolean hasStringValue()(Code)(Java Doc)
final void hasStringValue(boolean value)(Code)(Java Doc)
public Node insertBefore(Node newChild, Node refChild) throws DOMException(Code)(Java Doc)
final boolean internalIsIgnorableWhitespace()(Code)(Java Doc)
final boolean isFirstChild()(Code)(Java Doc)
final void isFirstChild(boolean value)(Code)(Java Doc)
final void isIgnorableWhitespace(boolean value)(Code)(Java Doc)
final boolean isNormalized()(Code)(Java Doc)
final void isNormalized(boolean value)(Code)(Java Doc)
final boolean isOwned()(Code)(Java Doc)
final void isOwned(boolean value)(Code)(Java Doc)
final boolean isReadOnly()(Code)(Java Doc)
final void isReadOnly(boolean value)(Code)(Java Doc)
final boolean isSpecified()(Code)(Java Doc)
final void isSpecified(boolean value)(Code)(Java Doc)
public boolean isSupported(String feature, String version)(Code)(Java Doc)
public Node item(int index)(Code)(Java Doc)
final boolean needsSyncChildren()(Code)(Java Doc)
final void needsSyncChildren(boolean value)(Code)(Java Doc)
final boolean needsSyncData()(Code)(Java Doc)
final void needsSyncData(boolean value)(Code)(Java Doc)
public void normalize()(Code)(Java Doc)
CoreDocumentImpl ownerDocument()(Code)(Java Doc)
NodeImpl parentNode()(Code)(Java Doc)
ChildNode previousSibling()(Code)(Java Doc)
public Node removeChild(Node oldChild) throws DOMException(Code)(Java Doc)
public void removeEventListener(String type, EventListener listener, boolean useCapture)(Code)(Java Doc)
public Node replaceChild(Node newChild, Node oldChild) throws DOMException(Code)(Java Doc)
public void setNodeValue(String x) throws DOMException(Code)(Java Doc)
void setOwnerDocument(CoreDocumentImpl doc)(Code)(Java Doc)
public void setPrefix(String prefix) throws DOMException(Code)(Java Doc)
public void setReadOnly(boolean readOnly, boolean deep)(Code)(Java Doc)
public void setUserData(Object data)(Code)(Java Doc)
protected void synchronizeData()(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.