MessageElement is the base type of nodes of the SOAP message parse tree.
Note: it was made Serializable to help users of Apache SOAP who had
exploited the serializability of the DOM tree to migrate to Axis.
addAttribute
public void addAttribute(String namespace,
String localName,
String value)
add a normal CDATA/text attribute.
There is no check whether or not the attribute already exists.
namespace
- namespace URIlocalName
- local anmevalue
- value
addAttribute
public void addAttribute(String attrPrefix,
String namespace,
String localName,
String value)
add an attribute.
Note that the prefix is not added to our mapping list.
Also, there is no check whether or not the attribute already exists.
attrPrefix
- prefix.namespace
- namespace URIlocalName
- value
-
addAttribute
public void addAttribute(String namespace,
String localName,
QName value)
add an attribute to the qname vector. This is a separate vector from the
main attribute list.
namespace
- localName
- value
-
addChild
public void addChild(MessageElement el)
throws SOAPException
Note that this method will log a error and no-op if there is
a value (set using setObjectValue) in the MessageElement.
addMapping
public void addMapping(Mapping map)
add a new namespace/prefix mapping
map
- new mapping to add
childDeepCloned
protected void childDeepCloned(NodeImpl oldNode,
NodeImpl newNode)
cloneNode
public Node cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy
constructor for nodes. The duplicate node has no parent; (
parentNode
is null
.).
Cloning an Element
copies all attributes and their
values, including those generated by the XML processor to represent
defaulted attributes, but this method does not copy any text it
contains unless it is a deep clone, since the text is contained in a
child Text
node. Cloning an Attribute
directly, as opposed to be cloned as part of an Element
cloning operation, returns a specified attribute (
specified
is true
). Cloning any other type
of node simply returns a copy of this node.
Note that cloning an immutable subtree results in a mutable copy,
but the children of an EntityReference
clone are readonly
. In addition, clones of unspecified Attr
nodes are
specified. And, cloning Document
,
DocumentType
, Entity
, and
Notation
nodes is implementation dependent.
- cloneNode in interface NodeImpl
deep
- If true
, recursively clone the subtree under
the specified node; if false
, clone only the node
itself (and its attributes, if it is an Element
).
- The duplicate node.
cloning
protected Object cloning()
throws CloneNotSupportedException
protected clone method (not public)
copied status
-------------------
protected String name ; Y
protected String prefix ; Y
protected String namespaceURI ; Y
protected transient Attributes attributes Y
protected String id; Y?
protected String href; Y?
protected boolean _isRoot = true; Y?
protected SOAPEnvelope message = null; N?
protected transient DeserializationContext context; Y?
protected transient QName typeQName = null; Y?
protected Vector qNameAttrs = null; Y?
protected transient SAX2EventRecorder recorder = null; N?
protected int startEventIndex = 0; N?
protected int startContentsIndex = 0; N?
protected int endEventIndex = -1; N?
protected CharacterData textRep = null; Y?
protected MessageElement parent = null; N
public ArrayList namespaces = null; Y
protected String encodingStyle = null; N?
private Object objectValue = null; N?
detachAllChildren
public void detachAllChildren()
remove all children.
equals
public boolean equals(Object obj)
equality test. Does a string match of the two message elements,
so is fairly brute force.
obj
-
toString()
findElement
protected MessageElement findElement(Vector vec,
String namespace,
String localPart)
getAllAttributes
public Iterator getAllAttributes()
Get an interator to all the attributes of the node.
The iterator is over a static snapshot of the node names; if attributes
are added or deleted during the iteration, this iterator will be not
be updated to follow the changes.
- getAllAttributes in interface SOAPElement
- an iterator of the attributes.
SOAPElement.getAllAttributes()
getAsDOM
public Element getAsDOM()
throws Exception
create a DOM from the message element, by
serializing and deserializing the element
- the root document element of the element
getAsString()
, getAsDocument()
getAsDocument
public Document getAsDocument()
throws Exception
get the message element as a document.
This serializes the element to a string and then parses it.
getAsString()
getAsString
public String getAsString()
throws Exception
get the message element as a string.
This is not a cheap operation, as we have to serialise the
entire message element to the current context, then
convert it to a string.
Nor is it cached; repeated calls repeat the operation.
- an XML fragment in a string.
getAttribute
public String getAttribute(String attrName)
get an attribute by name
attrName
- of attribute
- the attribute value or null
org.w3c.dom.Element.getAttribute(String)
getAttributeNS
public String getAttributeNS(String namespaceURI,
String localName)
get the attribute with namespace/local name match.
namespaceURI
- namespacelocalName
- name
- string value or null if not found
org.w3c.dom.Element.getAttributeNS(String, String)
getAttributeNode
public Attr getAttributeNode(String attrName)
this is not implemented
This unimplemented operation is meand to return an attribute as a node
attrName
-
- null, always.
org.w3c.dom.Element.getAttributeNode(String)
getAttributeNodeNS
public Attr getAttributeNodeNS(String namespace,
String localName)
not implemented!
namespace
- namespacelocalName
- local name
- null
org.w3c.dom.Element.getAttributeNS(String, String)
getAttributeValue
public String getAttributeValue(String localName)
get the value of an attribute
localName
-
- the value or null
getAttributesEx
public Attributes getAttributesEx()
get the attributes
- attributes. If this equals
NullAttributes.singleton
it is null
getChildElements
public Iterator getChildElements()
get an iterator over the children
This iterator may get confused if changes are made to the
children while the iteration is in progress.
- getChildElements in interface SOAPElement
- an iterator over child elements.
SOAPElement.getChildElements()
getChildElements
public Iterator getChildElements(QName qname)
get an iterator over child elements
qname
- namespace/element name of parts to find.
This iterator is not (currently) susceptible to change in the element
list during its lifetime, though changes in the contents of the elements
are picked up.
- an iterator.
getChildElements
public Iterator getChildElements(Name childName)
get an iterator over child elements
- getChildElements in interface SOAPElement
childName
- namespace/element name of parts to find.
This iterator is not (currently) susceptible to change in the element
list during its lifetime, though changes in the contents of the elements
are picked up.
- an iterator.
SOAPElement.getChildElements(Name)
getChildren
public List getChildren()
get a list of children
- a list, or null if there are no children
getCompleteAttributes
public Attributes getCompleteAttributes()
Obtain an Attributes collection consisting of all attributes
for this MessageElement, including namespace declarations.
- Attributes collection
getDeserializationContext
public DeserializationContext getDeserializationContext()
Retrieve the DeserializationContext associated with this MessageElement
- The DeserializationContext associated with this MessageElement
getElementsByTagName
public NodeList getElementsByTagName(String tagName)
tagName
- tag to look for.
- a list of elements
org.w3c.dom.Element.getElementsByTagName(String)
getElementsByTagNameNS
public NodeList getElementsByTagNameNS(String namespace,
String localName)
namespace
- namespacelocalName
- local name of element
- (potentially empty) list of elements that match the (namespace,localname) tuple
org.w3c.dom.Element.getElementsByTagNameNS(String, String)
getElementsNS
protected NodeList getElementsNS(org.w3c.dom.Element parentElement,
String namespace,
String localName)
helper method for recusively getting the element that has namespace URI and localname
parentElement
- parent elementnamespace
- namespacelocalName
- local name of element
- (potentially empty) list of elements that match the (namespace,localname) tuple
getEncodingStyle
public String getEncodingStyle()
Get the encoding style. If ours is null, walk up the hierarchy
and use our parent's. Default if we're the root is "".
- getEncodingStyle in interface SOAPElement
- the currently in-scope encoding style
getEnvelope
public SOAPEnvelope getEnvelope()
get our current envelope
- envelope or null.
getFixupDeserializer
public Deserializer getFixupDeserializer()
getHref
public String getHref()
get a saved href
- href or null
getID
public String getID()
get a saved ID
- ID or null for no ID
getLength
public int getLength()
The number of nodes in the list. The range of valid child node indices
is 0 to length-1
inclusive.
- number of children
- SAAJ 1.2 : Nodelist Interface
org.w3c.dom.NodeList.getLength()
getName
public String getName()
get the local name of this element
- name
getNamespaceURI
public String getNamespaceURI(String searchPrefix)
map from a prefix to a namespace.
Will recurse upward the element tree until we get a match
- getNamespaceURI in interface SOAPElement
searchPrefix
-
- the prefix, or null for no match
getObjectValue
public Object getObjectValue()
Returns value of the node as an object of registered type.
- Object of proper type, or null if no mapping could be found.
getObjectValue
public Object getObjectValue(Class cls)
throws Exception
Returns value of the node as an object of registered type.
cls
- Class that contains top level deserializer metadata
- Object of proper type, or null if no mapping could be found.
getOwnerDocument
public Document getOwnerDocument()
- getOwnerDocument in interface NodeImpl
getPrefix
public String getPrefix(String searchNamespaceURI)
get the prefix for a given namespace URI
searchNamespaceURI
- namespace
- null for null or emtpy uri, null for no match, and the prefix iff there is a match
getQName
public QName getQName()
get the fully qualified name of this element
- a QName describing the name of thsi element
getRealElement
public MessageElement getRealElement()
get the 'real' element -will follow hrefs.
- the message element or null if there is a href to something
that is not a MessageElemeent.
getRecorder
public SAX2EventRecorder getRecorder()
get the event recorder
- recorder or null
getTagName
public String getTagName()
- the name of the element
org.w3c.dom.Element.getTagName()
getType
public QName getType()
get the element's type.
If we are a reference, we look up our target in the context and
return (and cache) its type.
getValue
public String getValue()
Get the value of the doc as a string.
This uses
getAsDOM()
so is a heavyweight operation.
- getValue in interface Node
- getValue in interface NodeImpl
- the value of any child node, or null if there is no node/something went
wrong during serialization. If the first child is text, the return value
is the text itself.
javax.xml.soap.Node.getValue() ;
getValueAsType
public Object getValueAsType(QName type)
throws Exception
getValueAsType
public Object getValueAsType(QName type,
Class cls)
throws Exception
This is deserialization logic mixed in to our element class.
It is only valid we have a deserializer, which means that we were created
using MessageElement.MessageElement(String, String, String, org.xml.sax.Attributes, org.apache.axis.encoding.DeserializationContext)
type
- type to look up a deserializer for.cls
- class to use for looking up the deserializer. This takes precedence over the type field.
- the value of the deserializer
getValueDOM
protected String getValueDOM()
getVisibleNamespacePrefixes
public Iterator getVisibleNamespacePrefixes()
get an iterator over visible prefixes. This includes all declared in
parent elements
- getVisibleNamespacePrefixes in interface SOAPElement
- an iterator.
hasAttribute
public boolean hasAttribute(String attrName)
test for an attribute existing
attrName
- name of attribute (or null)
- true if it exists
Note that the behaviour for a null parameter (returns false) is not guaranteed in future
org.w3c.dom.Element.hasAttribute(String)
hasAttributeNS
public boolean hasAttributeNS(String namespace,
String localName)
Test for an attribute
namespace
- localName
-
org.w3c.dom.Element.hasAttributeNS(String, String)
isRoot
public boolean isRoot()
get the is-root flag
- true if the element is considered a document root.
item
public Node item(int index)
get a child node
index
- index value
- child or null for out of range value
org.w3c.dom.NodeList.item(int)
output
public final void output(SerializationContext outputContext)
throws Exception
This is the public output() method, which will always simply use
the recorded SAX stream for this element if it is available. If
not, this method calls outputImpl() to allow subclasses and
programmatically created messages to serialize themselves.
- output in interface NodeImpl
outputContext
- the SerializationContext we will write to.
outputImpl
protected void outputImpl(SerializationContext outputContext)
throws Exception
override point -output to a serialization context.
outputContext
- destination.
publishContents
public void publishContents(ContentHandler handler)
throws SAXException
replay the sax events to a SAX content handles
handler
-
publishToHandler
public void publishToHandler(ContentHandler handler)
throws SAXException
replay the sax events to a handler
handler
-
removeAttribute
public void removeAttribute(String attrName)
throws DOMException
remove a named attribute.
attrName
- name of the attributes
org.w3c.dom.Element.removeAttribute(String)
removeAttributeNS
public void removeAttributeNS(String namespace,
String localName)
throws DOMException
Remove an attribute. If the removed
attribute has a default value it is immediately replaced. The
replacing attribute has the same namespace URI and local name, as
well as the original prefix.
If there is no matching attribute, the operation is a no-op.
namespace
- namespace of attrlocalName
- local name
org.w3c.dom.Element.removeAttributeNS(String, String)
removeAttributeNode
public Attr removeAttributeNode(Attr oldAttr)
throws DOMException
remove a an attribue
oldAttr
-
- oldAttr
removeContents
public void removeContents()
remove all chidlren.
All SOAPExceptions which can get thrown in this process are ignored.
- removeContents in interface SOAPElement
setAllAttributes
public void setAllAttributes(Attributes attrs)
set all the attributes of this instance
attrs
- a new attributes list
setAttribute
public void setAttribute(String name,
String value)
throws DOMException
set or update an attribute.
name
- attribute namevalue
- attribute value
org.w3c.dom.Element.setAttribute(String, String)
setAttribute
public void setAttribute(String namespace,
String localName,
String value)
Set an attribute, adding the attribute if it isn't already present
in this element, and changing the value if it is. Passing null as the
value will cause any pre-existing attribute by this name to go away.
setAttributeNS
public void setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
throws DOMException
set an attribute or alter an existing one
namespaceURI
- namepsacequalifiedName
- qualified name of the attribuevalue
- value
org.w3c.dom.Element.setAttributeNS(String, String, String)
setAttributeNode
public Attr setAttributeNode(Attr newAttr)
throws DOMException
this is not implemented
set the attribute node.
newAttr
-
- newAttr
org.w3c.dom.Element.setAttributeNode(org.w3c.dom.Attr)
setAttributeNodeNS
public Attr setAttributeNodeNS(Attr newAttr)
throws DOMException
set an attribute as a node
newAttr
-
- null
org.w3c.dom.Element.setAttributeNodeNS(org.w3c.dom.Attr)
setContentsIndex
public void setContentsIndex(int index)
set the index point of our content's starting in the
event recording
index
- index value of the first event of our recorder.
setEncodingStyle
public void setEncodingStyle(String encodingStyle)
throws SOAPException
Sets the encoding style for this SOAPElement
object to one specified. The semantics of a null value,
as above in getEncodingStyle() are to just use the parent's value,
but null here means set to "".
- setEncodingStyle in interface SOAPElement
encodingStyle
- a String
giving the encoding style
getEncodingStyle()
setEndIndex
public void setEndIndex(int endIndex)
record the end index of the SAX recording.
endIndex
- end value
setEnvelope
public void setEnvelope(SOAPEnvelope env)
bind a a new soap envelope. sets the dirty bit.
env
-
setFixupDeserializer
public void setFixupDeserializer(Deserializer dser)
setNSMappings
public void setNSMappings(ArrayList namespaces)
set a new namespace mapping list
namespaces
-
setName
public void setName(String name)
set the local part of this element's name
name
-
setNamespaceURI
public void setNamespaceURI(String nsURI)
set the namespace URI of the element
nsURI
- new namespace URI
setObjectValue
public void setObjectValue(Object newValue)
throws SOAPException
Sets value of this node to an Object.
A serializer needs to be registered for this object class for proper
operation.
Note that this method will log an error and no-op if there are
any children in the MessageElement or if the MessageElement was
constructed from XML.
newValue
- node's value or null.
setQName
public void setQName(QName qName)
set the name and namespace of this element
qName
- qualified name
setRecorder
public void setRecorder(SAX2EventRecorder rec)
set the event recorder
rec
-
setType
public void setType(QName qname)
set the element's type
qname
-
setValue
public void setValue(String value)
If this is a Text node then this method will set its value, otherwise it
sets the value of the immediate (Text) child of this node. The value of
the immediate child of this node can be set only if, there is one child
node and that node is a Text node, or if there are no children in which
case a child Text node will be created.
- setValue in interface Node
- setValue in interface NodeImpl
value
- the text to set
toString
public String toString()
Generate a string representation by serializing our contents
This is not a lightweight operation, and is repeated whenever
you call this method.
If the serialization fails, an error is logged and the classic
Object.toString()
operation invoked instead.
- a string representing the class