You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2002/01/16 17:25:42 UTC
cvs commit: xml-axis/java/src/org/apache/axis/message SOAPEnvelope.java SOAPHeader.java MessageElement.java
gdaniels 02/01/16 08:25:42
Modified: java/src/org/apache/axis/message SOAPEnvelope.java
SOAPHeader.java MessageElement.java
Log:
Factor setAttribute() up into a utility method of MessageElement, and use it
several places.
Revision Changes Path
1.51 +3 -8 xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
Index: SOAPEnvelope.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- SOAPEnvelope.java 15 Jan 2002 01:33:24 -0000 1.50
+++ SOAPEnvelope.java 16 Jan 2002 16:25:42 -0000 1.51
@@ -144,6 +144,9 @@
public void setEncodingStyleURI(String uri)
{
encodingStyleURI = uri;
+ setAttribute(Constants.URI_SOAP_ENV,
+ Constants.ATTR_ENCODING_STYLE,
+ encodingStyleURI);
}
public Vector getBodyElements() throws AxisFault
@@ -397,14 +400,6 @@
}
Enumeration enum;
- if (encodingStyleURI != null) {
- if(attributes == null)
- attributes = new AttributesImpl();
- attributes.addAttribute(Constants.URI_SOAP_ENV,
- Constants.ATTR_ENCODING_STYLE,
- "SOAP-ENV:" + Constants.ATTR_ENCODING_STYLE,
- "CDATA", encodingStyleURI);
- }
context.startElement(new QName(Constants.URI_SOAP_ENV,
Constants.ELEM_ENVELOPE), attributes);
1.31 +4 -33 xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
Index: SOAPHeader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- SOAPHeader.java 14 Jan 2002 19:45:06 -0000 1.30
+++ SOAPHeader.java 16 Jan 2002 16:25:42 -0000 1.31
@@ -121,45 +121,16 @@
public boolean isMustUnderstand() { return( mustUnderstand ); }
public void setMustUnderstand(boolean b) {
mustUnderstand = b ;
- if (attributes != null) {
- int idx = attributes.getIndex(Constants.URI_SOAP_ENV,
- Constants.ATTR_MUST_UNDERSTAND);
- if (idx > -1) {
- // Got it, so replace it's value.
- attributes.setValue(idx, b ? "1" : "0");
- return;
- }
- } else {
- attributes = new AttributesImpl();
- }
-
- addAttribute(Constants.URI_SOAP_ENV,
+ String val = b ? "1" : "0";
+ setAttribute(Constants.URI_SOAP_ENV,
Constants.ATTR_MUST_UNDERSTAND,
- b ? "1" : "0");
+ val);
}
public String getActor() { return( actor ); }
public void setActor(String a) {
actor = a ;
- if (attributes != null) {
- int idx = attributes.getIndex(Constants.URI_SOAP_ENV,
- Constants.ATTR_ACTOR);
- if (idx > -1) {
- // Got it, so replace it's value.
- if (a != null) {
- attributes.setValue(idx, a);
- } else {
- attributes.removeAttribute(idx);
- }
- return;
- }
- } else if (a != null) {
- attributes = new AttributesImpl();
- }
-
- addAttribute(Constants.URI_SOAP_ENV,
- Constants.ATTR_ACTOR,
- a);
+ setAttribute(Constants.URI_SOAP_ENV, Constants.ATTR_ACTOR, a);
}
public void setProcessed(boolean value) {
1.71 +26 -0 xml-axis/java/src/org/apache/axis/message/MessageElement.java
Index: MessageElement.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- MessageElement.java 10 Jan 2002 14:24:15 -0000 1.70
+++ MessageElement.java 16 Jan 2002 16:25:42 -0000 1.71
@@ -353,6 +353,32 @@
attributes.addAttribute(namespace, localName, "", "CDATA",
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.
+ */
+ public void setAttribute(String namespace, String localName,
+ String value)
+ {
+ if (attributes != null) {
+ 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;
+ }
+ } else if (value != null) {
+ attributes = new AttributesImpl();
+ }
+
+ addAttribute(namespace, localName, value);
+ }
public String getAttributeValue(String localName)
{