org.apache.axis.message
Class MessageElement

java.lang.Object
  |
  +--org.apache.axis.message.MessageElement
All Implemented Interfaces:
Node, java.io.Serializable, SOAPElement
Direct Known Subclasses:
DetailEntry, SOAPBody, SOAPBodyElement, SOAPEnvelope, SOAPFaultElement, SOAPHeader, SOAPHeaderElement, Text

public class MessageElement
extends java.lang.Object
implements SOAPElement, java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
protected static class MessageElement.QNameAttr
           
 
Field Summary
protected  boolean _isDirty
           
protected  boolean _isRoot
           
protected  org.xml.sax.Attributes attributes
           
protected  DeserializationContext context
           
protected  org.w3c.dom.Element elementRep
           
protected  java.lang.String encodingStyle
          Our encoding style, if any
protected  int endEventIndex
           
protected  java.lang.String href
           
protected  java.lang.String id
           
protected static org.apache.commons.logging.Log log
           
protected  SOAPEnvelope message
           
protected  java.lang.String name
           
 java.util.ArrayList namespaces
           
protected  java.lang.String namespaceURI
           
protected  MessageElement parent
           
protected  java.lang.String prefix
           
protected  java.util.Vector qNameAttrs
           
protected  SAX2EventRecorder recorder
           
protected  int startContentsIndex
           
protected  int startEventIndex
           
protected  org.w3c.dom.Text textRep
           
protected  QName typeQName
           
 
Constructor Summary
MessageElement()
          No-arg constructor for building messages?
MessageElement(org.w3c.dom.Element elem)
           
MessageElement(Name eltName)
           
MessageElement(QName name, java.lang.Object value)
           
MessageElement(java.lang.String namespace, java.lang.String localPart)
           
MessageElement(java.lang.String namespace, java.lang.String localPart, java.lang.Object value)
           
MessageElement(java.lang.String localPart, java.lang.String prefix, java.lang.String namespace)
           
MessageElement(java.lang.String namespace, java.lang.String localPart, java.lang.String prefix, org.xml.sax.Attributes attributes, DeserializationContext context)
           
MessageElement(org.w3c.dom.Text text)
           
 
Method Summary
 SOAPElement addAttribute(Name name, java.lang.String value)
          Adds an attribute with the specified name and value to this SOAPElement object.
 void addAttribute(java.lang.String namespace, java.lang.String localName, QName value)
           
 void addAttribute(java.lang.String namespace, java.lang.String localName, java.lang.String value)
           
 void addAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String localName, java.lang.String value)
           
 void addChild(MessageElement el)
          Note that this method will log a error and no-op if there is a value (set using setObjectValue) in the MessageElement.
 SOAPElement addChildElement(Name name)
          Creates a new SOAPElement object initialized with the given Name object and adds the new element to this SOAPElement object.
 SOAPElement addChildElement(SOAPElement element)
          The added child must be an instance of MessageElement rather than an abitrary SOAPElement otherwise a (wrapped) ClassCastException will be thrown.
 SOAPElement addChildElement(java.lang.String localName)
          Creates a new SOAPElement object initialized with the given String object and adds the new element to this SOAPElement object.
 SOAPElement addChildElement(java.lang.String localName, java.lang.String prefix)
          Creates a new SOAPElement object initialized with the specified local name and prefix and adds the new element to this SOAPElement object.
 SOAPElement addChildElement(java.lang.String localName, java.lang.String prefix, java.lang.String uri)
          Creates a new SOAPElement object initialized with the specified local name, prefix, and URI and adds the new element to this SOAPElement object.
 void addMapping(Mapping map)
           
 SOAPElement addNamespaceDeclaration(java.lang.String prefix, java.lang.String uri)
          Adds a namespace declaration with the specified prefix and URI to this SOAPElement object.
 SOAPElement addTextNode(java.lang.String s)
          Text nodes are not supported.
 void detachNode()
          Break the relationship between this element and its parent, if any.
 java.util.Iterator getAllAttributes()
          Returns an iterator over all of the attribute names in this SOAPElement object.
 org.w3c.dom.Document getAsDocument()
           
 org.w3c.dom.Element getAsDOM()
           
 org.xml.sax.Attributes getAttributes()
           
 java.lang.String getAttributeValue(Name name)
          Returns the value of the attribute with the specified name.
 java.lang.String getAttributeValue(java.lang.String localName)
           
 java.util.Iterator getChildElements()
          Returns an iterator over all the immediate content of this element.
 java.util.Iterator getChildElements(Name name)
          Returns an iterator over all the child elements with the specified name.
 java.util.ArrayList getChildren()
           
 org.xml.sax.Attributes getCompleteAttributes()
          Obtain an Attributes collection consisting of all attributes for this MessageElement, including namespace declarations.
 Name getElementName()
          Returns the name of this SOAPElement object.
 java.lang.String getEncodingStyle()
          Get the encoding style.
 SOAPEnvelope getEnvelope()
           
 Deserializer getFixupDeserializer()
           
 java.lang.String getHref()
           
 java.lang.String getID()
           
 java.lang.String getName()
           
 java.util.Iterator getNamespacePrefixes()
          Returns an iterator of namespace prefixes.
 java.lang.String getNamespaceURI()
           
 java.lang.String getNamespaceURI(java.lang.String prefix)
          Returns the URI of the namespace that has the given prefix.
 java.lang.Object getObjectValue()
          Returns value of the node as an object of registered type.
 SOAPElement getParentElement()
          Returns the parent element of this Node object.
 java.lang.String getPrefix()
           
 java.lang.String getPrefix(java.lang.String namespaceURI)
           
 QName getQName()
           
 MessageElement getRealElement()
           
 SAX2EventRecorder getRecorder()
           
 QName getType()
           
 java.lang.String getValue()
          Returns the the value of the immediate child of this Node object if a child exists and its value is text.
 java.lang.Object getValueAsType(QName type)
           
 boolean isDirty()
           
 boolean isRoot()
           
protected  org.xml.sax.helpers.AttributesImpl makeAttributesEditable()
           
 void output(SerializationContext context)
          This is the public output() method, which will always simply use the recorded SAX stream for this element if it is available.
protected  void outputImpl(SerializationContext context)
          Subclasses can override
 void publishContents(org.xml.sax.ContentHandler handler)
           
 void publishToHandler(org.xml.sax.ContentHandler handler)
           
 void recycleNode()
          No-opped - Axis does not recycle nodes.
 boolean removeAttribute(Name name)
          Removes the attribute with the specified name.
 void removeChild(MessageElement child)
          Remove a child element.
 boolean removeNamespaceDeclaration(java.lang.String prefix)
          Removes the namespace declaration corresponding to the given prefix.
 void setAttribute(java.lang.String namespace, java.lang.String localName, java.lang.String value)
          Set an attribute, adding the attribute if it isn't already present in this element, and changing the value if it is.
 void setContentsIndex(int index)
           
 void setDirty(boolean dirty)
           
 void setEncodingStyle(java.lang.String encodingStyle)
          Sets the encoding style for this SOAPElement object to one specified.
 void setEndIndex(int endIndex)
           
 void setEnvelope(SOAPEnvelope env)
           
 void setFixupDeserializer(Deserializer dser)
           
 void setName(java.lang.String name)
           
 void setNamespaceURI(java.lang.String nsURI)
           
 void setNSMappings(java.util.ArrayList namespaces)
           
 void setObjectValue(java.lang.Object newValue)
          Sets value of this node to an Object.
 void setParentElement(SOAPElement parent)
          Sets the parent of this Node object to the given SOAPElement object.
 void setPrefix(java.lang.String prefix)
           
 void setQName(QName qName)
           
 void setRecorder(SAX2EventRecorder rec)
           
 void setType(QName qname)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

name

protected java.lang.String name

prefix

protected java.lang.String prefix

namespaceURI

protected java.lang.String namespaceURI

attributes

protected transient org.xml.sax.Attributes attributes

id

protected java.lang.String id

href

protected java.lang.String href

_isRoot

protected boolean _isRoot

message

protected SOAPEnvelope message

_isDirty

protected boolean _isDirty

context

protected transient DeserializationContext context

typeQName

protected transient QName typeQName

qNameAttrs

protected java.util.Vector qNameAttrs

recorder

protected transient SAX2EventRecorder recorder

startEventIndex

protected int startEventIndex

startContentsIndex

protected int startContentsIndex

endEventIndex

protected int endEventIndex

elementRep

protected org.w3c.dom.Element elementRep

textRep

protected org.w3c.dom.Text textRep

parent

protected MessageElement parent

namespaces

public java.util.ArrayList namespaces

encodingStyle

protected java.lang.String encodingStyle
Our encoding style, if any

Constructor Detail

MessageElement

public MessageElement()
No-arg constructor for building messages?


MessageElement

public MessageElement(java.lang.String namespace,
                      java.lang.String localPart)

MessageElement

public MessageElement(java.lang.String localPart,
                      java.lang.String prefix,
                      java.lang.String namespace)

MessageElement

public MessageElement(Name eltName)

MessageElement

public MessageElement(java.lang.String namespace,
                      java.lang.String localPart,
                      java.lang.Object value)

MessageElement

public MessageElement(QName name,
                      java.lang.Object value)

MessageElement

public MessageElement(org.w3c.dom.Element elem)

MessageElement

public MessageElement(org.w3c.dom.Text text)

MessageElement

public MessageElement(java.lang.String namespace,
                      java.lang.String localPart,
                      java.lang.String prefix,
                      org.xml.sax.Attributes attributes,
                      DeserializationContext context)
               throws AxisFault
Method Detail

setFixupDeserializer

public void setFixupDeserializer(Deserializer dser)

getFixupDeserializer

public Deserializer getFixupDeserializer()

setEndIndex

public void setEndIndex(int endIndex)

isDirty

public boolean isDirty()

setDirty

public void setDirty(boolean dirty)

isRoot

public boolean isRoot()

getID

public java.lang.String getID()

getHref

public java.lang.String getHref()

getAttributes

public org.xml.sax.Attributes getAttributes()

getCompleteAttributes

public org.xml.sax.Attributes getCompleteAttributes()
Obtain an Attributes collection consisting of all attributes for this MessageElement, including namespace declarations.

Returns:
Attributes collection

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getQName

public QName getQName()

setQName

public void setQName(QName qName)

getPrefix

public java.lang.String getPrefix()

setPrefix

public void setPrefix(java.lang.String prefix)

getNamespaceURI

public java.lang.String getNamespaceURI()

setNamespaceURI

public void setNamespaceURI(java.lang.String nsURI)

getType

public QName getType()

setType

public void setType(QName qname)

getRecorder

public SAX2EventRecorder getRecorder()

setRecorder

public void setRecorder(SAX2EventRecorder rec)

getEncodingStyle

public java.lang.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 "".

Specified by:
getEncodingStyle in interface SOAPElement
Returns:
the currently in-scope encoding style
See Also:
setEncodingStyle(java.lang.String)

setEncodingStyle

public void setEncodingStyle(java.lang.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 "".

Specified by:
setEncodingStyle in interface SOAPElement
Parameters:
encodingStyle - a String giving the encoding style
Throws:
java.lang.IllegalArgumentException - if there was a problem in the encoding style being set.
SOAPException
See Also:
getEncodingStyle()

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.

SOAPException

removeChild

public void removeChild(MessageElement child)
Remove a child element.


getChildren

public java.util.ArrayList getChildren()

setContentsIndex

public void setContentsIndex(int index)

setNSMappings

public void setNSMappings(java.util.ArrayList namespaces)

getPrefix

public java.lang.String getPrefix(java.lang.String namespaceURI)

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Description copied from interface: SOAPElement
Returns the URI of the namespace that has the given prefix.

Specified by:
getNamespaceURI in interface SOAPElement
Parameters:
prefix - a String giving the prefix of the namespace for which to search
Returns:
a String with the uri of the namespace that has the given prefix

getObjectValue

public java.lang.Object getObjectValue()
Returns value of the node as an object of registered type.

Returns:
Object of proper type, or null if no mapping could be found.

setObjectValue

public void setObjectValue(java.lang.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.

Parameters:
newValue - node's value or null.
SOAPException

getValueAsType

public java.lang.Object getValueAsType(QName type)
                                throws java.lang.Exception
java.lang.Exception

addAttribute

public void addAttribute(java.lang.String namespace,
                         java.lang.String localName,
                         QName value)

makeAttributesEditable

protected org.xml.sax.helpers.AttributesImpl makeAttributesEditable()

addAttribute

public void addAttribute(java.lang.String namespace,
                         java.lang.String localName,
                         java.lang.String value)

addAttribute

public void addAttribute(java.lang.String prefix,
                         java.lang.String namespace,
                         java.lang.String localName,
                         java.lang.String value)

setAttribute

public void setAttribute(java.lang.String namespace,
                         java.lang.String localName,
                         java.lang.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.


getAttributeValue

public java.lang.String getAttributeValue(java.lang.String localName)

setEnvelope

public void setEnvelope(SOAPEnvelope env)

getEnvelope

public SOAPEnvelope getEnvelope()

getRealElement

public MessageElement getRealElement()

getAsDocument

public org.w3c.dom.Document getAsDocument()
                                   throws java.lang.Exception
java.lang.Exception

getAsDOM

public org.w3c.dom.Element getAsDOM()
                             throws java.lang.Exception
java.lang.Exception

publishToHandler

public void publishToHandler(org.xml.sax.ContentHandler handler)
                      throws org.xml.sax.SAXException
org.xml.sax.SAXException

publishContents

public void publishContents(org.xml.sax.ContentHandler handler)
                     throws org.xml.sax.SAXException
org.xml.sax.SAXException

output

public final void output(SerializationContext context)
                  throws java.lang.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.

Parameters:
context - the SerializationContext we will write to.
java.lang.Exception

outputImpl

protected void outputImpl(SerializationContext context)
                   throws java.lang.Exception
Subclasses can override

java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addMapping

public void addMapping(Mapping map)

getValue

public java.lang.String getValue()
Returns the the value of the immediate child of this Node object if a child exists and its value is text.

Specified by:
getValue in interface Node
Returns:
a String with the text of the immediate child of this Node object if (1) there is a child and (2) the child is a Text object; null otherwise

setParentElement

public void setParentElement(SOAPElement parent)
                      throws SOAPException
Description copied from interface: Node
Sets the parent of this Node object to the given SOAPElement object.

Specified by:
setParentElement in interface Node
Parameters:
parent - the SOAPElement object to be set as the parent of this Node object
Throws:
SOAPException - if there is a problem in setting the parent to the given element
See Also:
getParentElement()

getParentElement

public SOAPElement getParentElement()
Description copied from interface: Node
Returns the parent element of this Node object. This method can throw an UnsupportedOperationException if the tree is not kept in memory.

Specified by:
getParentElement in interface Node
Returns:
the SOAPElement object that is the parent of this Node object or null if this Node object is root
See Also:
setParentElement(javax.xml.soap.SOAPElement)

detachNode

public void detachNode()
Break the relationship between this element and its parent, if any.

Specified by:
detachNode in interface Node

recycleNode

public void recycleNode()
No-opped - Axis does not recycle nodes.

Specified by:
recycleNode in interface Node

addChildElement

public SOAPElement addChildElement(Name name)
                            throws SOAPException
Description copied from interface: SOAPElement
Creates a new SOAPElement object initialized with the given Name object and adds the new element to this SOAPElement object.

Specified by:
addChildElement in interface SOAPElement
Parameters:
name - a Name object with the XML name for the new element
Returns:
the new SOAPElement object that was created
Throws:
SOAPException - if there is an error in creating the SOAPElement object

addChildElement

public SOAPElement addChildElement(java.lang.String localName)
                            throws SOAPException
Description copied from interface: SOAPElement
Creates a new SOAPElement object initialized with the given String object and adds the new element to this SOAPElement object.

Specified by:
addChildElement in interface SOAPElement
Parameters:
localName - a String giving the local name for the element
Returns:
the new SOAPElement object that was created
Throws:
SOAPException - if there is an error in creating the SOAPElement object

addChildElement

public SOAPElement addChildElement(java.lang.String localName,
                                   java.lang.String prefix)
                            throws SOAPException
Description copied from interface: SOAPElement
Creates a new SOAPElement object initialized with the specified local name and prefix and adds the new element to this SOAPElement object.

Specified by:
addChildElement in interface SOAPElement
Parameters:
localName - a String giving the local name for the new element
prefix - a String giving the namespace prefix for the new element
Returns:
the new SOAPElement object that was created
Throws:
SOAPException - if there is an error in creating the SOAPElement object

addChildElement

public SOAPElement addChildElement(java.lang.String localName,
                                   java.lang.String prefix,
                                   java.lang.String uri)
                            throws SOAPException
Description copied from interface: SOAPElement
Creates a new SOAPElement object initialized with the specified local name, prefix, and URI and adds the new element to this SOAPElement object.

Specified by:
addChildElement in interface SOAPElement
Parameters:
localName - a String giving the local name for the new element
prefix - a String giving the namespace prefix for the new element
uri - a String giving the URI of the namespace to which the new element belongs
Returns:
the new SOAPElement object that was created
Throws:
SOAPException - if there is an error in creating the SOAPElement object

addChildElement

public SOAPElement addChildElement(SOAPElement element)
                            throws SOAPException
The added child must be an instance of MessageElement rather than an abitrary SOAPElement otherwise a (wrapped) ClassCastException will be thrown.

Specified by:
addChildElement in interface SOAPElement
Parameters:
element - the SOAPElement to be added as a new child
Returns:
an instance representing the new SOAP element that was actually added to the tree.
Throws:
SOAPException - if there was an error in adding this element as a child

addTextNode

public SOAPElement addTextNode(java.lang.String s)
                        throws SOAPException
Text nodes are not supported.

Specified by:
addTextNode in interface SOAPElement
Parameters:
s - a String object with the textual content to be added
Returns:
the SOAPElement object into which the new Text object was inserted
Throws:
SOAPException - if there is an error in creating the new Text object

addAttribute

public SOAPElement addAttribute(Name name,
                                java.lang.String value)
                         throws SOAPException
Description copied from interface: SOAPElement
Adds an attribute with the specified name and value to this SOAPElement object.

Specified by:
addAttribute in interface SOAPElement
Parameters:
name - a Name object with the name of the attribute
value - a String giving the value of the attribute
Returns:
the SOAPElement object into which the attribute was inserted
Throws:
SOAPException - if there is an error in creating the Attribute

addNamespaceDeclaration

public SOAPElement addNamespaceDeclaration(java.lang.String prefix,
                                           java.lang.String uri)
                                    throws SOAPException
Description copied from interface: SOAPElement
Adds a namespace declaration with the specified prefix and URI to this SOAPElement object.

Specified by:
addNamespaceDeclaration in interface SOAPElement
Parameters:
prefix - a String giving the prefix of the namespace
uri - a String giving the prefix of the namespace
Returns:
the SOAPElement object into which this namespace declaration was inserted.
Throws:
SOAPException - if there is an error in creating the namespace

getAttributeValue

public java.lang.String getAttributeValue(Name name)
Description copied from interface: SOAPElement
Returns the value of the attribute with the specified name.

Specified by:
getAttributeValue in interface SOAPElement
Parameters:
name - a Name object with the name of the attribute
Returns:
a String giving the value of the specified attribute

getAllAttributes

public java.util.Iterator getAllAttributes()
Description copied from interface: SOAPElement
Returns an iterator over all of the attribute names in this SOAPElement object. The iterator can be used to get the attribute names, which can then be passed to the method getAttributeValue to retrieve the value of each attribute.

Specified by:
getAllAttributes in interface SOAPElement
Returns:
an iterator over the names of the attributes

getNamespacePrefixes

public java.util.Iterator getNamespacePrefixes()
Description copied from interface: SOAPElement
Returns an iterator of namespace prefixes. The iterator can be used to get the namespace prefixes, which can then be passed to the method getNamespaceURI to retrieve the URI of each namespace.

Specified by:
getNamespacePrefixes in interface SOAPElement
Returns:
an iterator over the namespace prefixes in this SOAPElement object

getElementName

public Name getElementName()
Description copied from interface: SOAPElement
Returns the name of this SOAPElement object.

Specified by:
getElementName in interface SOAPElement
Returns:
a Name object with the name of this SOAPElement object

removeAttribute

public boolean removeAttribute(Name name)
Description copied from interface: SOAPElement
Removes the attribute with the specified name.

Specified by:
removeAttribute in interface SOAPElement
Parameters:
name - the Name object with the name of the attribute to be removed
Returns:
true if the attribute was removed successfully; false if it was not

removeNamespaceDeclaration

public boolean removeNamespaceDeclaration(java.lang.String prefix)
Description copied from interface: SOAPElement
Removes the namespace declaration corresponding to the given prefix.

Specified by:
removeNamespaceDeclaration in interface SOAPElement
Parameters:
prefix - a String giving the prefix for which to search
Returns:
true if the namespace declaration was removed successfully; false if it was not

getChildElements

public java.util.Iterator getChildElements()
Description copied from interface: SOAPElement
Returns an iterator over all the immediate content of this element. This includes Text objects as well as SOAPElement objects.

Specified by:
getChildElements in interface SOAPElement
Returns:
an iterator with the content of this SOAPElement object

getChildElements

public java.util.Iterator getChildElements(Name name)
Description copied from interface: SOAPElement
Returns an iterator over all the child elements with the specified name.

Specified by:
getChildElements in interface SOAPElement
Parameters:
name - a Name object with the name of the child elements to be returned
Returns:
an Iterator object over all the elements in this SOAPElement object with the specified name


Copyright © 2003 Apache Web Services Project. All Rights Reserved.