FileDocCategorySizeDatePackage
MessageElement.javaAPI DocApache Axis 1.472601Sat Apr 22 18:57:26 BST 2006org.apache.axis.message

MessageElement

public class MessageElement extends NodeImpl implements Serializable, NodeList, SOAPElement, Cloneable
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.
todo
implement the NodeList methods properly, with tests.

Fields Summary
protected static Log
log
private static final org.apache.axis.utils.Mapping
enc11Mapping
private static final org.apache.axis.utils.Mapping
enc12Mapping
protected String
id
protected String
href
protected boolean
_isRoot
protected SOAPEnvelope
message
protected transient org.apache.axis.encoding.DeserializationContext
context
protected transient QName
typeQName
protected Vector
qNameAttrs
protected transient SAX2EventRecorder
recorder
protected int
startEventIndex
protected int
startContentsIndex
protected int
endEventIndex
public ArrayList
namespaces
protected String
encodingStyle
Our encoding style, if any
private Object
objectValue
Object value, possibly supplied by subclass
protected org.apache.axis.encoding.Deserializer
fixupDeserializer
!!! TODO : Make sure this handles multiple targets
Constructors Summary
public MessageElement()
No-arg constructor for building messages?


              
     
    
    
public MessageElement(String namespace, String localPart, String prefix, Attributes attributes, org.apache.axis.encoding.DeserializationContext context)
Advanced constructor used for deserialization.
  1. The context provides the mappings and Sax event recorder
  2. The soap messaging style is determined from the current message context, defaulting to SOAP1.1 if there is no current context.
  3. if there is an id attribute (any namespace), then the ID is registered with {@link DeserializationContext#registerElementByID(String, MessageElement)} ;a new recorder is created if needed.
  4. If there is an attribute "root" in the default SOAP namespace, then it is examined to see if it marks the element as root (value=="1" or not)
  5. If there is an arrayType attribute then we assume we are an array and set our {@link #typeQName} field appropriately.
  6. The {@link #href} field is set if there is a relevant href value

param
namespace namespace namespace of element
param
localPart local name local name of element
param
prefix prefix prefix of element
param
attributes attributes to save as our attributes
param
context deserialization context for this message element
throws
AxisFault if the encoding style is not recognized/supported

        if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage("newElem00", super.toString(),
                                            "{" + prefix + "}" + localPart));
            for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
                log.debug("  " + attributes.getQName(i) + " = '" + attributes.getValue(i) + "'");
            }
        }
        this.namespaceURI = namespace;
        this.name = localPart;
        this.prefix = prefix;

        this.context = context;
        this.startEventIndex = context.getStartOfMappingsPos();

        setNSMappings(context.getCurrentNSMappings());

        this.recorder = context.getRecorder();

        if (attributes != null && attributes.getLength() > 0) {
            this.attributes = attributes;

            this.typeQName = context.getTypeFromAttributes(namespace,
                                                      localPart,
                                                      attributes);

            String rootVal = attributes.getValue(Constants.URI_DEFAULT_SOAP_ENC, Constants.ATTR_ROOT);

            if (rootVal != null) {
                _isRoot = "1".equals(rootVal);
            }

            id = attributes.getValue(Constants.ATTR_ID);
            // Register this ID with the context.....
            if (id != null) {
                context.registerElementByID(id, this);
                if (recorder == null) {
                    recorder = new SAX2EventRecorder();
                    context.setRecorder(recorder);
                }
            }

            // Set the encoding style to the attribute value.  If null,
            // we just automatically use our parent's (see getEncodingStyle)
            MessageContext mc = context.getMessageContext();
            SOAPConstants sc = (mc != null) ?
                                            mc.getSOAPConstants() :
                                            SOAPConstants.SOAP11_CONSTANTS;

            href = attributes.getValue(sc.getAttrHref());

            // If there's an arrayType attribute, we can pretty well guess that we're an Array???
            if (attributes.getValue(Constants.URI_DEFAULT_SOAP_ENC, Constants.ATTR_ARRAY_TYPE) != null) {
                typeQName = Constants.SOAP_ARRAY;
            }


            encodingStyle =
                    attributes.getValue(sc.getEncodingURI(),
                                        Constants.ATTR_ENCODING_STYLE);

            // if no-encoding style was defined, we don't define as well
            if (Constants.URI_SOAP12_NOENC.equals(encodingStyle))
                encodingStyle = null;

            // If we have an encoding style, and are not a MESSAGE style
            // operation (in other words - we're going to do some data
            // binding), AND we're SOAP 1.2, check the encoding style against
            // the ones we've got type mappings registered for.  If it isn't
            // registered, throw a DataEncodingUnknown fault as per the
            // SOAP 1.2 spec.
            if (encodingStyle != null &&
                    sc.equals(SOAPConstants.SOAP12_CONSTANTS) &&
                    (mc.getOperationStyle() != Style.MESSAGE)) {
                TypeMapping tm = mc.getTypeMappingRegistry().
                        getTypeMapping(encodingStyle);
                if (tm == null ||
                        (tm.equals(mc.getTypeMappingRegistry().
                                                getDefaultTypeMapping()))) {
                    AxisFault badEncodingFault = new AxisFault(
                            Constants.FAULT_SOAP12_DATAENCODINGUNKNOWN,
                            "bad encoding style", null, null);
                    throw badEncodingFault;
                }
            }

        }
    
public MessageElement(String namespace, String localPart)
constructor

param
namespace namespace of element
param
localPart local name

        namespaceURI = namespace;
        name = localPart;
    
public MessageElement(String localPart, String prefix, String namespace)
constructor. Automatically adds a namespace-prefix mapping to the mapping table

param
localPart local name
param
prefix prefix
param
namespace namespace

        this.namespaceURI = namespace;
        this.name = localPart;
        this.prefix = prefix;
        addMapping(new Mapping(namespace, prefix));
    
public MessageElement(Name eltName)
construct using a {@link javax.xml.soap.Name} implementation,

see
#MessageElement(String, String, String)
param
eltName

        this(eltName.getLocalName(),eltName.getPrefix(), eltName.getURI());
    
public MessageElement(String namespace, String localPart, Object value)
constructor binding the internal object value field to the value parameter

param
namespace namespace of the element
param
localPart local name
param
value value of the node

        this(namespace, localPart);
        objectValue = value;
    
public MessageElement(QName name)
constructor declaring the qualified name of the node

param
name naming information

        this(name.getNamespaceURI(), name.getLocalPart());
    
public MessageElement(QName name, Object value)
constructor declaring the qualified name of the node and its value

param
name naming information
param
value value of the node

        this(name.getNamespaceURI(), name.getLocalPart());
        objectValue = value;
    
public MessageElement(Element elem)
create a node through a deep copy of the passed in element.

param
elem name to copy from

        namespaceURI = elem.getNamespaceURI();
        name = elem.getLocalName();
        copyNode(elem);
    
public MessageElement(CharacterData text)
construct a text element.

param
text text data. This is not copied; it is referred to in the MessageElement.

        textRep = text;
        namespaceURI = text.getNamespaceURI();
        name = text.getLocalName();
    
Methods Summary
public voidaddAttribute(java.lang.String namespace, java.lang.String localName, javax.xml.namespace.QName value)
add an attribute to the qname vector. This is a separate vector from the main attribute list.

param
namespace
param
localName
param
value

        if (qNameAttrs == null) {
            qNameAttrs = new Vector();
        }

        QNameAttr attr = new QNameAttr();
        attr.name = new QName(namespace, localName);
        attr.value = value;

        qNameAttrs.addElement(attr);
        // !!! Add attribute to attributes!
    
public voidaddAttribute(java.lang.String namespace, java.lang.String localName, java.lang.String value)
add a normal CDATA/text attribute. There is no check whether or not the attribute already exists.

param
namespace namespace URI
param
localName local anme
param
value value

        AttributesImpl attributes = makeAttributesEditable();
        attributes.addAttribute(namespace, localName, "", "CDATA",
                                value);
    
public voidaddAttribute(java.lang.String attrPrefix, java.lang.String namespace, java.lang.String localName, java.lang.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.

param
attrPrefix prefix.
param
namespace namespace URI
param
localName
param
value

        AttributesImpl attributes = makeAttributesEditable();
        String attrName = localName;
        if (attrPrefix != null && attrPrefix.length() > 0) {
            attrName = attrPrefix + ":" + localName;
        }
        attributes.addAttribute(namespace, localName, attrName, "CDATA",
                                value);
    
public javax.xml.soap.SOAPElementaddAttribute(javax.xml.soap.Name attrName, java.lang.String value)
add a new attribute

param
attrName name of the attribute
param
value a string value
return
ourselves
throws
SOAPException
see
javax.xml.soap.SOAPElement#addAttribute(javax.xml.soap.Name, String)

        try {
            addAttribute(attrName.getPrefix(), attrName.getURI(), attrName.getLocalName(), value);
        } catch (RuntimeException t) {
            throw new SOAPException(t);
        }
        return this;
    
public voidaddChild(org.apache.axis.message.MessageElement el)
Note that this method will log a error and no-op if there is a value (set using setObjectValue) in the MessageElement.

        if (objectValue != null) {
            IllegalStateException exc =
                new IllegalStateException(Messages.getMessage("valuePresent"));
            log.error(Messages.getMessage("valuePresent"), exc);
            throw exc;
        }
        initializeChildren();
        children.add(el);
        el.parent = this;
    
public javax.xml.soap.SOAPElementaddChildElement(javax.xml.soap.Name childName)
add the child element

param
childName uri, prefix and local name of the element to add
return
the child element
throws
SOAPException
see
javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)

        MessageElement child = new MessageElement(childName.getLocalName(),
                                                  childName.getPrefix(),
                                                  childName.getURI());
        addChild(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(java.lang.String localName)
add a child element in the message element's own namespace

param
localName
return
the child element
throws
SOAPException
see
javax.xml.soap.SOAPElement#addChildElement(String)

        // Inherit parent's namespace
        MessageElement child = new MessageElement(getNamespaceURI(),
                                                  localName);
        addChild(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(java.lang.String localName, java.lang.String prefixName)
add a child element

param
localName
param
prefixName
return
the child element
throws
SOAPException
see
javax.xml.soap.SOAPElement#addChildElement(String, String)

        MessageElement child = new MessageElement(getNamespaceURI(prefixName),
                                                  localName);
        child.setPrefix(prefixName);
        addChild(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(java.lang.String localName, java.lang.String childPrefix, java.lang.String uri)
add a child element

param
localName
param
childPrefix
param
uri
return
the child element
throws
SOAPException
see
javax.xml.soap.SOAPElement#addChildElement(String, String, String)

        MessageElement child = new MessageElement(uri, localName);
        child.setPrefix(childPrefix);
        child.addNamespaceDeclaration(childPrefix, uri);
        addChild(child);
        return child;
    
public javax.xml.soap.SOAPElementaddChildElement(javax.xml.soap.SOAPElement element)
The added child must be an instance of MessageElement rather than an abitrary SOAPElement otherwise a (wrapped) ClassCastException will be thrown.

see
javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)

        try {
            addChild((MessageElement)element);
            setDirty();
            return element;
        } catch (ClassCastException e) {
            throw new SOAPException(e);
        }
    
public voidaddMapping(org.apache.axis.utils.Mapping map)
add a new namespace/prefix mapping

param
map new mapping to add
todo:
this code does not verify that the mapping does not exist already; it is possible to create duplicate mappings.

        if (namespaces == null) {
            namespaces = new ArrayList();
        }
        namespaces.add(map);
    
public javax.xml.soap.SOAPElementaddNamespaceDeclaration(java.lang.String prefix, java.lang.String uri)
create a {@link Mapping} mapping and add to our namespace list.

param
prefix
param
uri
return
throws
SOAPException for any {@link RuntimeException} caught
todo
for some reason this logic catches all rutime exceptions and rethrows them as SOAPExceptions. This is unusual behavio, and should be looked at closely.
see
javax.xml.soap.SOAPElement#addNamespaceDeclaration(String, String)

        try {
            Mapping map = new Mapping(uri, prefix);
            addMapping(map);
        } catch (RuntimeException t) {
            //TODO: why is this here? Nowhere else do we turn runtimes into SOAPExceptions.
            throw new SOAPException(t);
        }
        return this;
    
public javax.xml.soap.SOAPElementaddTextNode(java.lang.String s)
add a text node to the document.

return
ourselves
see
javax.xml.soap.SOAPElement#addTextNode(String)

        try {
            Text text = getOwnerDocument().createTextNode(s);
            ((org.apache.axis.message.Text)text).setParentElement(this);
            return this;
        } catch (java.lang.IncompatibleClassChangeError e) {
            Text text = new org.apache.axis.message.Text(s);
            this.appendChild(text);
            return this;
        } catch (ClassCastException e) {
            throw new SOAPException(e);
        }
    
protected voidchildDeepCloned(NodeImpl oldNode, NodeImpl newNode)

    
public org.w3c.dom.NodecloneNode(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.

param
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).
return
The duplicate node.

        try{
            MessageElement clonedSelf = (MessageElement) cloning();

            if(deep){
                if(children != null){
                    for(int i =0; i < children.size(); i++){
                        NodeImpl child = (NodeImpl)children.get(i);
                        if(child != null) {  // why child can be null?
                            NodeImpl clonedChild = (NodeImpl)child.cloneNode(deep); // deep == true
                            clonedChild.setParent(clonedSelf);
                            clonedChild.setOwnerDocument(getOwnerDocument());
                            
                            clonedSelf.childDeepCloned( child, clonedChild );
                        }
                    }
                }
            }
            return clonedSelf;
        }
        catch(Exception e){
            return null;
        }
    
protected java.lang.Objectcloning()
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?

return
throws
CloneNotSupportedException

        try{
            MessageElement clonedME = null;
            clonedME = (MessageElement)this.clone();

            clonedME.setName(name);
            clonedME.setNamespaceURI(namespaceURI);
            clonedME.setPrefix(prefix);

            // new AttributesImpl will copy all data not set referencing only
            clonedME.setAllAttributes(new AttributesImpl(attributes));
            //       clonedME.addNamespaceDeclaration((namespaces.clone()); // cannot do this. since we cannot access the namepace arraylist

            clonedME.namespaces = new ArrayList();
            if(namespaces != null){
                for(int i = 0; i < namespaces.size(); i++){
                    //     jeus.util.Logger.directLog( " Debug :  namspace.size() = " + namespaces.size());
                    Mapping namespace = (Mapping)namespaces.get(i);
                    clonedME.addNamespaceDeclaration(namespace.getPrefix(), namespace.getNamespaceURI()); // why exception here!!
                }
            }
            clonedME.children = new ArrayList();

            // clear parents relationship to old parent
            clonedME.parent = null;
            // clonedME.setObjectValue(objectValue); // how to copy this???
            clonedME.setDirty(this._isDirty);
            if(encodingStyle != null){
                clonedME.setEncodingStyle(encodingStyle);
            }
            return clonedME;
        }catch(Exception ex){
            return null;
        }
    
private voidcopyNode(org.w3c.dom.Node element)
recursively copy. Note that this does not reset many of our fields, and must be used with caution.

param
element

        copyNode(this, element);
    
private voidcopyNode(org.apache.axis.message.MessageElement dest, org.w3c.dom.Node source)
recursive copy

param
dest element to copy into
param
source child element

        dest.setPrefix(source.getPrefix());
        if(source.getLocalName() != null) {
            dest.setQName(new QName(source.getNamespaceURI(), source.getLocalName()));
        }
        else
        {
            dest.setQName(new QName(source.getNamespaceURI(), source.getNodeName()));
        }

        NamedNodeMap attrs = source.getAttributes();
        for(int i = 0; i < attrs.getLength(); i++){
            Node att = attrs.item(i);
        if (att.getNamespaceURI() != null &&
                att.getPrefix() != null &&
                att.getNamespaceURI().equals(Constants.NS_URI_XMLNS) &&
                "xmlns".equals(att.getPrefix())) {
                Mapping map = new Mapping(att.getNodeValue(), att.getLocalName());
                dest.addMapping(map);
            }
            if(att.getLocalName() != null) {
                dest.addAttribute(att.getPrefix(),
                        (att.getNamespaceURI() != null ? att.getNamespaceURI() : ""),
                        att.getLocalName(),
                        att.getNodeValue());
            } else if (att.getNodeName() != null) {
                dest.addAttribute(att.getPrefix(),
                        (att.getNamespaceURI() != null ? att.getNamespaceURI() : ""),
                        att.getNodeName(),
                        att.getNodeValue());
            }
        }

        NodeList children = source.getChildNodes();
        for(int i = 0; i < children.getLength(); i++){
            Node child = children.item(i);
            if(child.getNodeType()==TEXT_NODE ||
               child.getNodeType()==CDATA_SECTION_NODE ||
               child.getNodeType()==COMMENT_NODE ) {
                org.apache.axis.message.Text childElement = 
                    new org.apache.axis.message.Text((CharacterData)child);
                dest.appendChild(childElement);
            } else {
                MessageElement childElement = new MessageElement();
                dest.appendChild(childElement);
                copyNode(childElement, child);
            }
        }
    
public voiddetachAllChildren()
remove all children.

        removeContents();
    
public booleanequals(java.lang.Object obj)
equality test. Does a string match of the two message elements, so is fairly brute force.

see
#toString()
param
obj
return

        if (obj == null || !(obj instanceof MessageElement)) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        if (!this.getLocalName().equals(((MessageElement) obj).getLocalName())) {
            return false;
        }
        return toString().equals(obj.toString());
    
protected org.apache.axis.message.MessageElementfindElement(java.util.Vector vec, java.lang.String namespace, java.lang.String localPart)

        if (vec.isEmpty()) {
            return null;
        }

        QName qname = new QName(namespace, localPart);
        Enumeration e = vec.elements();
        MessageElement element;
        while (e.hasMoreElements()) {
            element = (MessageElement) e.nextElement();
            if (element.getQName().equals(qname)) {
                return element;
            }
        }

        return null;
    
public java.util.IteratorgetAllAttributes()
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.

return
an iterator of the attributes.
see
javax.xml.soap.SOAPElement#getAllAttributes()

        int num = attributes.getLength();
        Vector attrs = new Vector(num);
        for (int i = 0; i < num; i++) {
            String q = attributes.getQName(i);
            String prefix = "";
            if (q != null) {
                int idx = q.indexOf(":");
                if (idx > 0) {
                    prefix = q.substring(0, idx);
                } else {
                    prefix= "";
                }
            }

            attrs.add(new PrefixedQName(attributes.getURI(i),
                                        attributes.getLocalName(i),
                                        prefix));
        }
        return attrs.iterator();
    
public org.w3c.dom.ElementgetAsDOM()
create a DOM from the message element, by serializing and deserializing the element

see
#getAsString()
see
#getAsDocument()
return
the root document element of the element
throws
Exception

        return getAsDocument().getDocumentElement();
    
public org.w3c.dom.DocumentgetAsDocument()
get the message element as a document. This serializes the element to a string and then parses it.

see
#getAsString()
return
throws
Exception

        String elementString = getAsString();

        Reader reader = new StringReader(elementString);
        Document doc = XMLUtils.newDocument(new InputSource(reader));
        if (doc == null) {
            throw new Exception(
                    Messages.getMessage("noDoc00", elementString));
        }
        return doc;
    
public java.lang.StringgetAsString()
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.

return
an XML fragment in a string.
throws
Exception if anything went wrong

        SerializationContext serializeContext = null;
        StringWriter writer = new StringWriter();
        MessageContext msgContext;
        if (context != null) {
            msgContext = context.getMessageContext();
        } else {
            msgContext = MessageContext.getCurrentContext();
        }
        serializeContext = new SerializationContext(writer, msgContext);
        serializeContext.setSendDecl(false);
        setDirty(false);
        output(serializeContext);
        writer.close();

        return writer.getBuffer().toString();
    
public java.lang.StringgetAttribute(java.lang.String attrName)
get an attribute by name

param
attrName of attribute
return
the attribute value or null
see
org.w3c.dom.Element#getAttribute(String)

        return attributes.getValue(attrName);
    
public java.lang.StringgetAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
get the attribute with namespace/local name match.

see
org.w3c.dom.Element#getAttributeNS(String, String)
param
namespaceURI namespace
param
localName name
return
string value or null if not found
todo:
this could be refactored to use getAttributeValue()

    	if(namespaceURI == null) {
    		namespaceURI = "";
    	}
        for (int i = 0; i < attributes.getLength(); i++) {
            if (attributes.getURI(i).equals(namespaceURI) &&
                    attributes.getLocalName(i).equals(localName)) {
                return  attributes.getValue(i);
            }
        }
        return null;
    
public org.w3c.dom.AttrgetAttributeNode(java.lang.String attrName)
This unimplemented operation is meand to return an attribute as a node

see
org.w3c.dom.Element#getAttributeNode(String)
param
attrName
return
null, always.
todo
Fix this for SAAJ 1.2 Implementation. marked as deprecated to warn people it is broken
deprecated
this is not implemented

        return null;
    
public org.w3c.dom.AttrgetAttributeNodeNS(java.lang.String namespace, java.lang.String localName)

see
org.w3c.dom.Element#getAttributeNS(String, String)
deprecated
not implemented!
param
namespace namespace
param
localName local name
return
null

        return null;  //TODO: Fix this for SAAJ 1.2 Implementation
    
public java.lang.StringgetAttributeValue(java.lang.String localName)
get the value of an attribute

param
localName
return
the value or null

        if (attributes == null) {
           return null;
        }
        return attributes.getValue(localName);
    
public java.lang.StringgetAttributeValue(javax.xml.soap.Name attrName)
Get the value of an attribute whose namespace and local name are described.

param
attrName qualified name of the attribute
return
the attribute or null if there was no match
see
SOAPElement#getAttributeValue(javax.xml.soap.Name)

        return attributes.getValue(attrName.getURI(), attrName.getLocalName());
    
public org.xml.sax.AttributesgetAttributesEx()
get the attributes

return
attributes. If this equals {@link NullAttributes.singleton} it is null

 return attributes; 
public org.apache.axis.message.MessageElementgetChildElement(javax.xml.namespace.QName qname)
Convenience method to get the first matching child for a given QName.

param
qname
return
child element or null
see
javax.xml.soap.SOAPElement#getChildElements()

        if (children != null) {
            for (Iterator i = children.iterator(); i.hasNext();) {
                MessageElement child = (MessageElement) i.next();
                if (child.getQName().equals(qname))
                    return child;
            }
        }
        return null;
    
public java.util.IteratorgetChildElements()
get an iterator over the children This iterator may get confused if changes are made to the children while the iteration is in progress.

return
an iterator over child elements.
see
javax.xml.soap.SOAPElement#getChildElements()

        initializeChildren();
        return children.iterator();
    
public java.util.IteratorgetChildElements(javax.xml.namespace.QName qname)
get an iterator over child elements

param
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.
return
an iterator.

        initializeChildren();
        int num = children.size();
        Vector c = new Vector(num);
        for (int i = 0; i < num; i++) {
            MessageElement child = (MessageElement)children.get(i);
            Name cname = child.getElementName();
            if (cname.getURI().equals(qname.getNamespaceURI()) &&
                cname.getLocalName().equals(qname.getLocalPart())) {
                c.add(child);
            }
        }
        return c.iterator();
    
public java.util.IteratorgetChildElements(javax.xml.soap.Name childName)
get an iterator over child elements

param
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.
return
an iterator.
see
javax.xml.soap.SOAPElement#getChildElements(javax.xml.soap.Name)

        return getChildElements(new QName(childName.getURI(), childName.getLocalName()));
    
public java.util.ListgetChildren()
get a list of children

return
a list, or null if there are no children

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

return
Attributes collection

        if (namespaces == null) {
            return attributes;
        }

        AttributesImpl attrs = null;
        if (attributes == NullAttributes.singleton) {
            attrs = new AttributesImpl();
        } else {
            attrs = new AttributesImpl(attributes);
        }

        for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) {
            Mapping mapping = (Mapping) iterator.next();
            String prefix = mapping.getPrefix();
            String nsURI = mapping.getNamespaceURI();
            attrs.addAttribute(Constants.NS_URI_XMLNS, prefix,
                               "xmlns:" + prefix, nsURI, "CDATA");
        }
        return attrs;
    
public org.apache.axis.encoding.DeserializationContextgetDeserializationContext()
Retrieve the DeserializationContext associated with this MessageElement

return
The DeserializationContext associated with this MessageElement

        return context;
    
public javax.xml.soap.NamegetElementName()
get the full name of the element

return
see
javax.xml.soap.SOAPElement#getElementName()

        return new PrefixedQName(getNamespaceURI(), getName(), getPrefix());
    
public org.w3c.dom.NodeListgetElementsByTagName(java.lang.String tagName)

see
org.w3c.dom.Element#getElementsByTagName(String)
param
tagName tag to look for.
return
a list of elements

        NodeListImpl nodelist = new NodeListImpl();
        for (int i = 0; children != null && i < children.size(); i++) {
            if (children.get(i) instanceof Node) {
                Node el = (Node)children.get(i);
                if (el.getLocalName() != null && el.getLocalName()
                                .equals(tagName))
                    nodelist.addNode(el);
                if (el instanceof Element) {
                    NodeList grandchildren =
                            ((Element)el).getElementsByTagName(tagName);
                    for (int j = 0; j < grandchildren.getLength(); j++) {
                        nodelist.addNode(grandchildren.item(j));
                    }
                }
            }
        }
        return nodelist;
    
public org.w3c.dom.NodeListgetElementsByTagNameNS(java.lang.String namespace, java.lang.String localName)

see
org.w3c.dom.Element#getElementsByTagNameNS(String, String)
param
namespace namespace
param
localName local name of element
return
(potentially empty) list of elements that match the (namespace,localname) tuple

        return getElementsNS(this,namespace,localName);
    
protected org.w3c.dom.NodeListgetElementsNS(org.w3c.dom.Element parentElement, java.lang.String namespace, java.lang.String localName)
helper method for recusively getting the element that has namespace URI and localname

param
parentElement parent element
param
namespace namespace
param
localName local name of element
return
(potentially empty) list of elements that match the (namespace,localname) tuple

        NodeList children = parentElement.getChildNodes();
        NodeListImpl matches = new NodeListImpl();

        for (int i = 0; i < children.getLength(); i++) {
            if (children.item(i) instanceof Text) {
                continue;
            }
            Element child = (Element) children.item(i);
            if (namespace.equals(child.getNamespaceURI()) &&
                    localName.equals(child.getLocalName())) {
                matches.addNode(child);
            }
            // search the grand-children.
            matches.addNodeList(child.getElementsByTagNameNS(namespace,
                    localName));
        }
        return matches;
    
public java.lang.StringgetEncodingStyle()
Get the encoding style. If ours is null, walk up the hierarchy and use our parent's. Default if we're the root is "".

return
the currently in-scope encoding style

        if (encodingStyle == null) {
            if (parent == null) {
                return "";
            }
            return ((MessageElement) parent).getEncodingStyle();
        }
        return encodingStyle;
    
public SOAPEnvelopegetEnvelope()
get our current envelope

return
envelope or null.

        return message;
    
public org.apache.axis.encoding.DeserializergetFixupDeserializer()

        return fixupDeserializer;
    
public java.lang.StringgetHref()
get a saved href

return
href or null

 return href; 
public java.lang.StringgetID()
get a saved ID

return
ID or null for no ID

 return id; 
public intgetLength()
The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.

return
number of children
since
SAAJ 1.2 : Nodelist Interface
see
org.w3c.dom.NodeList#getLength()

        return (children == null) ? 0 : children.size();
    
public java.lang.StringgetName()
get the local name of this element

return
name

        return name;
    
public java.util.IteratorgetNamespacePrefixes()
get an iterator of the prefixes. The iterator does not get updated in response to changes in the namespace list.

return
an iterator over a vector of prefixes
see
javax.xml.soap.SOAPElement#getNamespacePrefixes()

        Vector prefixes = new Vector();
        for (int i = 0; namespaces != null && i < namespaces.size(); i++) {
            prefixes.add(((Mapping)namespaces.get(i)).getPrefix());
        }
        return prefixes.iterator();
    
public java.lang.StringgetNamespaceURI(java.lang.String searchPrefix)
map from a prefix to a namespace. Will recurse upward the element tree until we get a match

param
searchPrefix
return
the prefix, or null for no match

        if (searchPrefix == null) {
            searchPrefix = "";
        }

        if (href != null && getRealElement() != null) {
            return getRealElement().getNamespaceURI(searchPrefix);
        }

        for (int i = 0; namespaces != null && i < namespaces.size(); i++) {
            Mapping map = (Mapping) namespaces.get(i);
            if (map.getPrefix().equals(searchPrefix)) {
                return map.getNamespaceURI();
            }
        }

        if (parent != null) {
            return ((MessageElement) parent).getNamespaceURI(searchPrefix);
        }

        if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage("noPrefix00", "" + this, searchPrefix));
        }

        return null;
    
public java.lang.ObjectgetObjectValue()
Returns value of the node as an object of registered type.

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

        Object obj = null;
        try {
            obj = getObjectValue(null);
        } catch (Exception e) {
            log.debug("getValue()", e);
        }
        return obj;
    
public java.lang.ObjectgetObjectValue(java.lang.Class cls)
Returns value of the node as an object of registered type.

param
cls Class that contains top level deserializer metadata
return
Object of proper type, or null if no mapping could be found.

        if (objectValue == null) {
            objectValue = getValueAsType(getType(), cls);
        }
        return objectValue;
    
public org.w3c.dom.DocumentgetOwnerDocument()

        Document doc = null;
        if (context != null && context.getEnvelope() != null &&
                context.getEnvelope().getOwnerDocument() != null) {
            doc = context.getEnvelope().getOwnerDocument();
        }
        if(doc == null) {
            doc = super.getOwnerDocument();
        }
        if (doc == null) {
            doc = new SOAPDocumentImpl(null);
        }
        return doc;
    
public java.lang.StringgetPrefix(java.lang.String searchNamespaceURI)
get the prefix for a given namespace URI

param
searchNamespaceURI namespace
return
null for null or emtpy uri, null for no match, and the prefix iff there is a match

        if ((searchNamespaceURI == null) || ("".equals(searchNamespaceURI)))
            return null;

        if (href != null && getRealElement() != null) {
            return getRealElement().getPrefix(searchNamespaceURI);
        }

        for (int i = 0; namespaces != null && i < namespaces.size(); i++) {
            Mapping map = (Mapping) namespaces.get(i);
            if (map.getNamespaceURI().equals(searchNamespaceURI)) {
                return map.getPrefix();
            }
        }

        if (parent != null) {
            return ((MessageElement) parent).getPrefix(searchNamespaceURI);
        }

        return null;
    
public javax.xml.namespace.QNamegetQName()
get the fully qualified name of this element

return
a QName describing the name of thsi element

        return new QName(namespaceURI, name);
    
public org.apache.axis.message.MessageElementgetRealElement()
get the 'real' element -will follow hrefs.

return
the message element or null if there is a href to something that is not a MessageElemeent.

        if (href == null) {
            return this;
        }

        Object obj = context.getObjectByRef(href);
        if (obj == null) {
            return null;
        }

        if (!(obj instanceof MessageElement)) {
            return null;
        }

        return (MessageElement) obj;
    
public SAX2EventRecordergetRecorder()
get the event recorder

return
recorder or null

        return recorder;
    
public java.lang.StringgetTagName()

see
org.w3c.dom.Element#getTagName()
return
the name of the element

        return prefix == null ? name : prefix + ":" + name;
    
public javax.xml.namespace.QNamegetType()
get the element's type. If we are a reference, we look up our target in the context and return (and cache) its type.

return

        // Try to get the type from our target if we're a reference...
        if (typeQName == null && href != null && context != null) {
            MessageElement referent = context.getElementByID(href);
            if (referent != null) {
                typeQName = referent.getType();
            }
        }
        return typeQName;
    
public java.lang.StringgetValue()
Get the value of the doc as a string. This uses {@link #getAsDOM()} so is a heavyweight operation.

return
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.
see
javax.xml.soap.Node#getValue() ;

        /*--- Fix for AXIS-1817
        if ((recorder != null) && (!_isDirty)) {
            StringWriter writer = new StringWriter();
            TextSerializationContext outputContext = 
                new TextSerializationContext(writer);
            try {
                recorder.replay(startEventIndex,
                                endEventIndex,
                                new SAXOutputter(outputContext));
            } catch (Exception t) {
                log.debug("getValue()", t);
                return null;
            }
            String value = writer.toString();
            return (value.length() == 0) ? null : value;
        } 
        ---*/

        if (textRep != null) {
            // weird case: error?
            return textRep.getNodeValue();
        }

        if (objectValue != null) {
            return getValueDOM();
        }

        for (Iterator i = getChildElements(); i.hasNext(); ) {
            org.apache.axis.message.NodeImpl n = (org.apache.axis.message.NodeImpl) i.next();
            if (n instanceof org.apache.axis.message.Text) {
                org.apache.axis.message.Text textNode = (org.apache.axis.message.Text) n;
                return textNode.getNodeValue();
            }
        }

        return null;
    
public java.lang.ObjectgetValueAsType(javax.xml.namespace.QName type)

        return getValueAsType(type, null);
    
public java.lang.ObjectgetValueAsType(javax.xml.namespace.QName type, java.lang.Class cls)
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 {@link MessageElement#MessageElement(String, String, String, org.xml.sax.Attributes, org.apache.axis.encoding.DeserializationContext)}

param
type type to look up a deserializer for.
param
cls class to use for looking up the deserializer. This takes precedence over the type field.
return
the value of the deserializer
throws
Exception

        if (context == null) {
            throw new Exception(Messages.getMessage("noContext00"));
        }

        Deserializer dser = null;
        if (cls == null) {
            dser = context.getDeserializerForType(type);
        } else {
            dser = context.getDeserializerForClass(cls);
        }
        if (dser == null) {
            throw new Exception(Messages.getMessage("noDeser00", "" + type));
        }

        boolean oldVal = context.isDoneParsing();
        context.deserializing(true);
        context.pushElementHandler(new EnvelopeHandler((SOAPHandler)dser));

        publishToHandler((org.xml.sax.ContentHandler) context);

        context.deserializing(oldVal);

        return dser.getValue();
    
protected java.lang.StringgetValueDOM()

        try {
            Element element = getAsDOM();
            if (element.hasChildNodes()) {
                Node node = element.getFirstChild();
                if (node.getNodeType() == Node.TEXT_NODE) {
                    return node.getNodeValue();
                }
            }
        } catch (Exception t) {
            log.debug("getValue()", t);
        }
        return null;
    
public java.util.IteratorgetVisibleNamespacePrefixes()
get an iterator over visible prefixes. This includes all declared in parent elements

return
an iterator.

        Vector prefixes = new Vector();

        // Add all parents namespace definitions
        if(parent !=null){
            Iterator parentsPrefixes = ((MessageElement)parent).getVisibleNamespacePrefixes();
            if(parentsPrefixes != null){
                while(parentsPrefixes.hasNext()){
                    prefixes.add(parentsPrefixes.next());
                }
            }
        }
        Iterator mine = getNamespacePrefixes();
        if(mine != null){
            while(mine.hasNext()){
                prefixes.add(mine.next());
            }
        }
        return prefixes.iterator();
    
public booleanhasAttribute(java.lang.String attrName)
test for an attribute existing

param
attrName name of attribute (or null)
return
true if it exists Note that the behaviour for a null parameter (returns false) is not guaranteed in future
see
org.w3c.dom.Element#hasAttribute(String)

        if(attrName == null)  // Do I have to send an exception?
            attrName = "";

        for(int i = 0; i < attributes.getLength(); i++){
            if(attrName.equals(attributes.getQName(i)))
                return true;
        }
        return false;
    
public booleanhasAttributeNS(java.lang.String namespace, java.lang.String localName)
Test for an attribute

see
org.w3c.dom.Element#hasAttributeNS(String, String)
param
namespace
param
localName
return

        if (namespace == null) {
            namespace = "";
        }
        if (localName == null)  // Do I have to send an exception? or just return false
        {
            localName = "";
        }

        for(int i = 0; i < attributes.getLength(); i++){
            if( namespace.equals(attributes.getURI(i))
                    && localName.equals(attributes.getLocalName(i)))
                return true;
        }
        return false;
    
public booleanisRoot()
get the is-root flag

return
true if the element is considered a document root.

 return _isRoot; 
public org.w3c.dom.Nodeitem(int index)
get a child node

param
index index value
return
child or null for out of range value
see
org.w3c.dom.NodeList#item(int)

        if (children != null && children.size() > index) {
            return (Node) children.get(index);
        } else {
            return null;
        }
    
public final voidoutput(org.apache.axis.encoding.SerializationContext outputContext)
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.

param
outputContext the SerializationContext we will write to.

        if ((recorder != null) && (!_isDirty)) {
            recorder.replay(startEventIndex,
                            endEventIndex,
                            new SAXOutputter(outputContext));
            return;
        }

        // Turn QName attributes into strings
        if (qNameAttrs != null) {
            for (int i = 0; i < qNameAttrs.size(); i++) {
                QNameAttr attr = (QNameAttr)qNameAttrs.get(i);
                QName attrName = attr.name;
                setAttribute(attrName.getNamespaceURI(),
                             attrName.getLocalPart(),
                             outputContext.qName2String(attr.value));
            }
        }

        /**
         * Write the encoding style attribute IF it's different from
         * whatever encoding style is in scope....
         */
        if (encodingStyle != null) {
            MessageContext mc = outputContext.getMessageContext();
            SOAPConstants soapConstants = (mc != null) ?
                                            mc.getSOAPConstants() :
                                            SOAPConstants.SOAP11_CONSTANTS;
            if (parent == null) {
                // don't emit an encoding style if its "" (literal)
                if (!"".equals(encodingStyle)) {
                    setAttribute(soapConstants.getEnvelopeURI(),
                                 Constants.ATTR_ENCODING_STYLE,
                                 encodingStyle);
                }
            } else if (!encodingStyle.equals(((MessageElement)parent).getEncodingStyle())) {
                setAttribute(soapConstants.getEnvelopeURI(),
                             Constants.ATTR_ENCODING_STYLE,
                             encodingStyle);
            }
        }

        outputImpl(outputContext);
    
protected voidoutputImpl(org.apache.axis.encoding.SerializationContext outputContext)
override point -output to a serialization context.

param
outputContext destination.
throws
Exception if something went wrong.

        if (textRep != null) {
            boolean oldPretty = outputContext.getPretty();
            outputContext.setPretty(false);
            if (textRep instanceof CDATASection) {
                outputContext.writeString("<![CDATA[");
                outputContext.writeString(textRep.getData());
                outputContext.writeString("]]>");
            } else if (textRep instanceof Comment) {
                outputContext.writeString("<!--");
                outputContext.writeString(textRep.getData());
                outputContext.writeString("-->");
            } else if (textRep instanceof Text) {
                outputContext.writeSafeString(textRep.getData());
            }
            outputContext.setPretty(oldPretty);
            return;
        }

        if (prefix != null)
            outputContext.registerPrefixForURI(prefix, namespaceURI);

        if (namespaces != null) {
            for (Iterator i = namespaces.iterator(); i.hasNext();) {
                Mapping mapping = (Mapping) i.next();
                outputContext.registerPrefixForURI(mapping.getPrefix(), mapping.getNamespaceURI());
            }
        }

        if (objectValue != null) {
            outputContext.serialize(new QName(namespaceURI, name),
                              attributes,
                              objectValue);
            return;
        }

        outputContext.startElement(new QName(namespaceURI, name), attributes);
        if (children != null) {
            for (Iterator it = children.iterator(); it.hasNext();) {
                ((NodeImpl)it.next()).output(outputContext);
            }
        }
        outputContext.endElement();
    
public voidpublishContents(org.xml.sax.ContentHandler handler)
replay the sax events to a SAX content handles

param
handler
throws
SAXException

        if (recorder == null) {
            throw new SAXException(Messages.getMessage("noRecorder00"));
        }

        recorder.replay(startContentsIndex, endEventIndex-1, handler);
    
public voidpublishToHandler(org.xml.sax.ContentHandler handler)
replay the sax events to a handler

param
handler
throws
SAXException

        if (recorder == null) {
            throw new SAXException(Messages.getMessage("noRecorder00"));
        }

        recorder.replay(startEventIndex, endEventIndex, handler);
    
public booleanremoveAttribute(javax.xml.soap.Name attrName)
remove an element

param
attrName name of the element
return
true if the attribute was found and removed.
see
javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)

        AttributesImpl attributes = makeAttributesEditable();
        boolean removed = false;

        for (int i = 0; i < attributes.getLength() && !removed; i++) {
            if (attributes.getURI(i).equals(attrName.getURI()) &&
                attributes.getLocalName(i).equals(attrName.getLocalName())) {
                attributes.removeAttribute(i);
                removed = true;
            }
        }
        return removed;
    
public voidremoveAttribute(java.lang.String attrName)
remove a named attribute.

see
org.w3c.dom.Element#removeAttribute(String)
param
attrName name of the attributes
throws
DOMException

        AttributesImpl impl =  (AttributesImpl)attributes;
        int index = impl.getIndex(attrName);
        if(index >= 0){
            AttributesImpl newAttrs = new AttributesImpl();
            // copy except the removed attribute
            for(int i = 0; i < impl.getLength(); i++){ // shift after removal
                if(i != index){
                    String uri = impl.getURI(i);
                    String local = impl.getLocalName(i);
                    String qname = impl.getQName(i);
                    String type = impl.getType(i);
                    String value = impl.getValue(i);
                    newAttrs.addAttribute(uri,local,qname,type,value);
                }
            }
            // replace it
            attributes = newAttrs;
        }
    
public voidremoveAttributeNS(java.lang.String namespace, java.lang.String localName)
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.

see
org.w3c.dom.Element#removeAttributeNS(String, String)
param
namespace namespace of attr
param
localName local name
throws
DOMException

        makeAttributesEditable();
        Name name =  new PrefixedQName(namespace, localName, null);
        removeAttribute(name);
    
public org.w3c.dom.AttrremoveAttributeNode(org.w3c.dom.Attr oldAttr)
remove a an attribue

param
oldAttr
return
oldAttr
throws
DOMException

        makeAttributesEditable();
        Name name =  new PrefixedQName(oldAttr.getNamespaceURI(), oldAttr.getLocalName(), oldAttr.getPrefix());
        removeAttribute(name);
        return oldAttr;
    
public voidremoveContents()
remove all chidlren. All SOAPExceptions which can get thrown in this process are ignored.

        // unlink
        if (children != null) {
            for (int i = 0; i < children.size(); i++) {
                try {
                    ((NodeImpl) children.get(i)).setParent(null);
                } catch (SOAPException e) {
                    log.debug("ignoring", e);
                }
            }
            // empty the collection
            children.clear();
            setDirty();
        }
    
public booleanremoveNamespaceDeclaration(java.lang.String namespacePrefix)
remove a namespace declaration.

param
namespacePrefix
return
true if the prefix was found and removed.
see
javax.xml.soap.SOAPElement#removeNamespaceDeclaration(String)

        makeAttributesEditable();
        boolean removed = false;

        for (int i = 0; namespaces != null && i < namespaces.size() && !removed; i++) {
            if (((Mapping)namespaces.get(i)).getPrefix().equals(namespacePrefix)) {
                namespaces.remove(i);
                removed = true;
            }
        }
        return removed;
    
public voidsetAllAttributes(org.xml.sax.Attributes attrs)
set all the attributes of this instance

param
attrs a new attributes list

        attributes = attrs;
    
public voidsetAttribute(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.

        AttributesImpl attributes = makeAttributesEditable();

        int idx = attributes.getIndex(namespace, localName);
        if (idx > -1) {
            // Got it, so replace it's value.
            if (value != null) {
                attributes.setValue(idx, value);
            } else {
                attributes.removeAttribute(idx);
            }
            return;
        }

        addAttribute(namespace, localName, value);
    
public voidsetAttribute(java.lang.String name, java.lang.String value)
set or update an attribute.

see
org.w3c.dom.Element#setAttribute(String, String)
param
name attribute name
param
value attribute value
throws
DOMException

        AttributesImpl impl =  makeAttributesEditable();
        int index = impl.getIndex(name);
        if (index < 0) { // not found
            String uri = "";
            String localname = name;
            String qname = name;
            String type = "CDDATA";
            impl.addAttribute(uri, localname, qname, type, value);
        } else {         // found
            impl.setLocalName(index, value);
        }
    
public voidsetAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)
set an attribute or alter an existing one

see
org.w3c.dom.Element#setAttributeNS(String, String, String)
param
namespaceURI namepsace
param
qualifiedName qualified name of the attribue
param
value value
throws
DOMException

        AttributesImpl attributes = makeAttributesEditable();
        String localName =  qualifiedName.substring(qualifiedName.indexOf(":")+1, qualifiedName.length());

        if (namespaceURI == null) {
            namespaceURI = "intentionalNullURI";
        }
        attributes.addAttribute(namespaceURI,
                localName,
                qualifiedName,
                "CDATA",
                value);
    
public org.w3c.dom.AttrsetAttributeNode(org.w3c.dom.Attr newAttr)
set the attribute node.

see
org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
param
newAttr
return
newAttr
throws
DOMException
deprecated
this is not implemented
todo
implement

        return newAttr;
    
public org.w3c.dom.AttrsetAttributeNodeNS(org.w3c.dom.Attr newAttr)
set an attribute as a node

see
org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
todo
implement properly.
param
newAttr
return
null
throws
DOMException

        //attributes.
        AttributesImpl attributes = makeAttributesEditable();
        // how to convert to DOM ATTR
        attributes.addAttribute(newAttr.getNamespaceURI(),
                newAttr.getLocalName(),
                newAttr.getLocalName(),
                "CDATA",
                newAttr.getValue());
        return null;
    
public voidsetContentsIndex(int index)
set the index point of our content's starting in the event recording

param
index index value of the first event of our recorder.

        startContentsIndex = index;
    
public voidsetEncodingStyle(java.lang.String encodingStyle)
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 "".

param
encodingStyle a String giving the encoding style
throws
java.lang.IllegalArgumentException if there was a problem in the encoding style being set.
see
#getEncodingStyle() getEncodingStyle()

        if (encodingStyle == null) {
            encodingStyle = "";
        }

        this.encodingStyle = encodingStyle;

        // Wherever we set the encoding style, map the SOAP-ENC prefix
        // just for fun (if it's a known style)
        if (encodingStyle.equals(Constants.URI_SOAP11_ENC)) {
            addMapping(enc11Mapping);
        } else if (encodingStyle.equals(Constants.URI_SOAP12_ENC)) {
            addMapping(enc12Mapping);
        }
    
public voidsetEndIndex(int endIndex)
record the end index of the SAX recording.

param
endIndex end value

        endEventIndex = endIndex;
        //context.setRecorder(null);
    
public voidsetEnvelope(SOAPEnvelope env)
bind a a new soap envelope. sets the dirty bit.

param
env

        env.setDirty();
        message = env;
    
public voidsetFixupDeserializer(org.apache.axis.encoding.Deserializer dser)

        // !!! Merge targets here if already set?
        fixupDeserializer = dser;
    
public voidsetNSMappings(java.util.ArrayList namespaces)
set a new namespace mapping list

param
namespaces

        this.namespaces = namespaces;
    
public voidsetName(java.lang.String name)
set the local part of this element's name

param
name

        this.name = name;
    
public voidsetNamespaceURI(java.lang.String nsURI)
set the namespace URI of the element

param
nsURI new namespace URI

        namespaceURI = nsURI;
    
public voidsetObjectValue(java.lang.Object newValue)
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.

param
newValue node's value or null.

        if (children != null && !children.isEmpty()) {
            SOAPException exc = new SOAPException(Messages.getMessage("childPresent"));
            log.error(Messages.getMessage("childPresent"), exc);
            throw exc;
        }
        if (textRep != null) {
            SOAPException exc = new SOAPException(Messages.getMessage("xmlPresent"));
            log.error(Messages.getMessage("xmlPresent"), exc);
            throw exc;
        }
        this.objectValue = newValue;
    
public voidsetQName(javax.xml.namespace.QName qName)
set the name and namespace of this element

param
qName qualified name

        this.name = qName.getLocalPart();
        this.namespaceURI = qName.getNamespaceURI();
    
public voidsetRecorder(SAX2EventRecorder rec)
set the event recorder

param
rec

        recorder = rec;
    
public voidsetType(javax.xml.namespace.QName qname)
set the element's type

param
qname

        typeQName = qname;
    
public voidsetValue(java.lang.String value)

        // if possible, get objectValue in sync with Node value
        if (children==null) {
            try {
                setObjectValue(value);
            } catch ( SOAPException soape ) {
                log.debug("setValue()", soape);
            }
        }
        super.setValue(value);
    
public java.lang.StringtoString()
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 {@link Object#toString()} operation invoked instead.

return
a string representing the class

        try {
            return getAsString();
        }
        catch( Exception exp ) {
            //couldn't turn to a string.
            //log it
            log.error(Messages.getMessage("exception00"), exp);
            //then hand off to our superclass, which is probably object
            return super.toString();
        }