Methods Summary |
---|
public void | addAttribute(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.
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 void | addAttribute(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.
AttributesImpl attributes = makeAttributesEditable();
attributes.addAttribute(namespace, localName, "", "CDATA",
value);
|
public void | addAttribute(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.
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.SOAPElement | addAttribute(javax.xml.soap.Name attrName, java.lang.String value)add a new attribute
try {
addAttribute(attrName.getPrefix(), attrName.getURI(), attrName.getLocalName(), value);
} catch (RuntimeException t) {
throw new SOAPException(t);
}
return this;
|
public void | addChild(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.SOAPElement | addChildElement(javax.xml.soap.Name childName)add the child element
MessageElement child = new MessageElement(childName.getLocalName(),
childName.getPrefix(),
childName.getURI());
addChild(child);
return child;
|
public javax.xml.soap.SOAPElement | addChildElement(java.lang.String localName)add a child element in the message element's own namespace
// Inherit parent's namespace
MessageElement child = new MessageElement(getNamespaceURI(),
localName);
addChild(child);
return child;
|
public javax.xml.soap.SOAPElement | addChildElement(java.lang.String localName, java.lang.String prefixName)add a child element
MessageElement child = new MessageElement(getNamespaceURI(prefixName),
localName);
child.setPrefix(prefixName);
addChild(child);
return child;
|
public javax.xml.soap.SOAPElement | addChildElement(java.lang.String localName, java.lang.String childPrefix, java.lang.String uri)add a child element
MessageElement child = new MessageElement(uri, localName);
child.setPrefix(childPrefix);
child.addNamespaceDeclaration(childPrefix, uri);
addChild(child);
return child;
|
public javax.xml.soap.SOAPElement | addChildElement(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.
try {
addChild((MessageElement)element);
setDirty();
return element;
} catch (ClassCastException e) {
throw new SOAPException(e);
}
|
public void | addMapping(org.apache.axis.utils.Mapping map)add a new namespace/prefix mapping
if (namespaces == null) {
namespaces = new ArrayList();
}
namespaces.add(map);
|
public javax.xml.soap.SOAPElement | addNamespaceDeclaration(java.lang.String prefix, java.lang.String uri)create a {@link Mapping} mapping and add to our namespace list.
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.SOAPElement | addTextNode(java.lang.String s)add a text node to the document.
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 void | childDeepCloned(NodeImpl oldNode, NodeImpl newNode)
|
public org.w3c.dom.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.
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.Object | cloning()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?
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 void | copyNode(org.w3c.dom.Node element)recursively copy.
Note that this does not reset many of our fields, and must be used with caution.
copyNode(this, element);
|
private void | copyNode(org.apache.axis.message.MessageElement dest, org.w3c.dom.Node source)recursive copy
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 void | detachAllChildren()remove all children.
removeContents();
|
public boolean | equals(java.lang.Object obj)equality test. Does a string match of the two message elements,
so is fairly brute force.
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.MessageElement | findElement(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.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.
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.Element | getAsDOM()create a DOM from the message element, by
serializing and deserializing the element
return getAsDocument().getDocumentElement();
|
public org.w3c.dom.Document | getAsDocument()get the message element as a document.
This serializes the element to a string and then parses it.
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.String | getAsString()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.
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.String | getAttribute(java.lang.String attrName)get an attribute by name
return attributes.getValue(attrName);
|
public java.lang.String | getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)get the attribute with namespace/local name match.
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.Attr | getAttributeNode(java.lang.String attrName)This unimplemented operation is meand to return an attribute as a node
return null;
|
public org.w3c.dom.Attr | getAttributeNodeNS(java.lang.String namespace, java.lang.String localName)
return null; //TODO: Fix this for SAAJ 1.2 Implementation
|
public java.lang.String | getAttributeValue(java.lang.String localName)get the value of an attribute
if (attributes == null) {
return null;
}
return attributes.getValue(localName);
|
public java.lang.String | getAttributeValue(javax.xml.soap.Name attrName)Get the value of an attribute whose namespace and local name are described.
return attributes.getValue(attrName.getURI(), attrName.getLocalName());
|
public org.xml.sax.Attributes | getAttributesEx()get the attributes return attributes;
|
public org.apache.axis.message.MessageElement | getChildElement(javax.xml.namespace.QName qname)Convenience method to get the first matching child for a given QName.
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.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.
initializeChildren();
return children.iterator();
|
public java.util.Iterator | getChildElements(javax.xml.namespace.QName qname)get an iterator over child elements
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.Iterator | getChildElements(javax.xml.soap.Name childName)get an iterator over child elements
return getChildElements(new QName(childName.getURI(), childName.getLocalName()));
|
public java.util.List | getChildren()get a list of children
return children;
|
public org.xml.sax.Attributes | getCompleteAttributes()Obtain an Attributes collection consisting of all attributes
for this MessageElement, including namespace declarations.
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.DeserializationContext | getDeserializationContext()Retrieve the DeserializationContext associated with this MessageElement
return context;
|
public javax.xml.soap.Name | getElementName()get the full name of the element
return new PrefixedQName(getNamespaceURI(), getName(), getPrefix());
|
public org.w3c.dom.NodeList | getElementsByTagName(java.lang.String tagName)
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.NodeList | getElementsByTagNameNS(java.lang.String namespace, java.lang.String localName)
return getElementsNS(this,namespace,localName);
|
protected org.w3c.dom.NodeList | getElementsNS(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
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.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 "".
if (encodingStyle == null) {
if (parent == null) {
return "";
}
return ((MessageElement) parent).getEncodingStyle();
}
return encodingStyle;
|
public SOAPEnvelope | getEnvelope()get our current envelope
return message;
|
public org.apache.axis.encoding.Deserializer | getFixupDeserializer()
return fixupDeserializer;
|
public java.lang.String | getHref()get a saved href return href;
|
public java.lang.String | getID()get a saved ID return id;
|
public int | getLength()The number of nodes in the list. The range of valid child node indices
is 0 to length-1 inclusive.
return (children == null) ? 0 : children.size();
|
public java.lang.String | getName()get the local name of this element
return name;
|
public java.util.Iterator | getNamespacePrefixes()get an iterator of the prefixes. The iterator
does not get updated in response to changes in the namespace list.
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.String | getNamespaceURI(java.lang.String searchPrefix)map from a prefix to a namespace.
Will recurse upward the element tree until we get a 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.Object | getObjectValue()Returns value of the node as an object of registered type.
Object obj = null;
try {
obj = getObjectValue(null);
} catch (Exception e) {
log.debug("getValue()", e);
}
return obj;
|
public java.lang.Object | getObjectValue(java.lang.Class cls)Returns value of the node as an object of registered type.
if (objectValue == null) {
objectValue = getValueAsType(getType(), cls);
}
return objectValue;
|
public org.w3c.dom.Document | getOwnerDocument()
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.String | getPrefix(java.lang.String searchNamespaceURI)get the prefix for a given namespace URI
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.QName | getQName()get the fully qualified name of this element
return new QName(namespaceURI, name);
|
public org.apache.axis.message.MessageElement | getRealElement()get the 'real' element -will follow hrefs.
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 SAX2EventRecorder | getRecorder()get the event recorder
return recorder;
|
public java.lang.String | getTagName()
return prefix == null ? name : prefix + ":" + name;
|
public javax.xml.namespace.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.
// 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.String | getValue()Get the value of the doc as a string.
This uses {@link #getAsDOM()} so is a heavyweight operation.
/*--- 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.Object | getValueAsType(javax.xml.namespace.QName type)
return getValueAsType(type, null);
|
public java.lang.Object | getValueAsType(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)}
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.String | getValueDOM()
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.Iterator | getVisibleNamespacePrefixes()get an iterator over visible prefixes. This includes all declared in
parent elements
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 boolean | hasAttribute(java.lang.String attrName)test for an attribute existing
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 boolean | hasAttributeNS(java.lang.String namespace, java.lang.String localName)Test for an attribute
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 boolean | isRoot()get the is-root flag return _isRoot;
|
public org.w3c.dom.Node | item(int index)get a child node
if (children != null && children.size() > index) {
return (Node) children.get(index);
} else {
return null;
}
|
public final void | output(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.
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 void | outputImpl(org.apache.axis.encoding.SerializationContext outputContext)override point -output to a serialization context.
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 void | publishContents(org.xml.sax.ContentHandler handler)replay the sax events to a SAX content handles
if (recorder == null) {
throw new SAXException(Messages.getMessage("noRecorder00"));
}
recorder.replay(startContentsIndex, endEventIndex-1, handler);
|
public void | publishToHandler(org.xml.sax.ContentHandler handler)replay the sax events to a handler
if (recorder == null) {
throw new SAXException(Messages.getMessage("noRecorder00"));
}
recorder.replay(startEventIndex, endEventIndex, handler);
|
public boolean | removeAttribute(javax.xml.soap.Name attrName)remove an element
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 void | removeAttribute(java.lang.String attrName)remove a named attribute.
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 void | removeAttributeNS(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.
makeAttributesEditable();
Name name = new PrefixedQName(namespace, localName, null);
removeAttribute(name);
|
public org.w3c.dom.Attr | removeAttributeNode(org.w3c.dom.Attr oldAttr)remove a an attribue
makeAttributesEditable();
Name name = new PrefixedQName(oldAttr.getNamespaceURI(), oldAttr.getLocalName(), oldAttr.getPrefix());
removeAttribute(name);
return oldAttr;
|
public void | removeContents()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 boolean | removeNamespaceDeclaration(java.lang.String namespacePrefix)remove a namespace declaration.
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 void | setAllAttributes(org.xml.sax.Attributes attrs)set all the attributes of this instance
attributes = attrs;
|
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.
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 void | setAttribute(java.lang.String name, java.lang.String value)set or update an attribute.
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 void | setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)set an attribute or alter an existing one
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.Attr | setAttributeNode(org.w3c.dom.Attr newAttr)set the attribute node.
return newAttr;
|
public org.w3c.dom.Attr | setAttributeNodeNS(org.w3c.dom.Attr newAttr)set an attribute as a node
//attributes.
AttributesImpl attributes = makeAttributesEditable();
// how to convert to DOM ATTR
attributes.addAttribute(newAttr.getNamespaceURI(),
newAttr.getLocalName(),
newAttr.getLocalName(),
"CDATA",
newAttr.getValue());
return null;
|
public void | setContentsIndex(int index)set the index point of our content's starting in the
event recording
startContentsIndex = index;
|
public void | setEncodingStyle(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 "".
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 void | setEndIndex(int endIndex)record the end index of the SAX recording.
endEventIndex = endIndex;
//context.setRecorder(null);
|
public void | setEnvelope(SOAPEnvelope env)bind a a new soap envelope. sets the dirty bit.
env.setDirty();
message = env;
|
public void | setFixupDeserializer(org.apache.axis.encoding.Deserializer dser)
// !!! Merge targets here if already set?
fixupDeserializer = dser;
|
public void | setNSMappings(java.util.ArrayList namespaces)set a new namespace mapping list
this.namespaces = namespaces;
|
public void | setName(java.lang.String name)set the local part of this element's name
this.name = name;
|
public void | setNamespaceURI(java.lang.String nsURI)set the namespace URI of the element
namespaceURI = nsURI;
|
public void | setObjectValue(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.
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 void | setQName(javax.xml.namespace.QName qName)set the name and namespace of this element
this.name = qName.getLocalPart();
this.namespaceURI = qName.getNamespaceURI();
|
public void | setRecorder(SAX2EventRecorder rec)set the event recorder
recorder = rec;
|
public void | setType(javax.xml.namespace.QName qname)set the element's type
typeQName = qname;
|
public void | setValue(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.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
{@link Object#toString()} operation invoked instead.
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();
}
|