You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/11/25 14:13:39 UTC
svn commit: r348940 -
/incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java
Author: jkaputin
Date: Fri Nov 25 05:13:34 2005
New Revision: 348940
URL: http://svn.apache.org/viewcvs?rev=348940&view=rev
Log:
Added more support to MessageLabel for handling
invalid values, including a boolean isValid() and
overriding equals() to compare contents rather than
object refs for invalid MessageStrings
Modified:
incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java
Modified: incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java?rev=348940&r1=348939&r2=348940&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java Fri Nov 25 05:13:34 2005
@@ -15,6 +15,7 @@
*/
package org.apache.woden.wsdl20.enum;
+
/**
* This class defines the values of the {message label} property of
* InterfaceMessageReference and InterfaceFaultReference. This property
@@ -38,29 +39,68 @@
* msgRef.setMessageLabel(MessageLabel.IN);
* if(msgRef.getMessageLabel() == MessageLabel.IN) ...
* if(msgRef.getMessageLabel().equals(MessageLabel.IN)) ...
- *
- * Note that == and .equals() are equivalent.
* </pre>
- * If a messageLabel attribute in the WSDL specifies an invalid value
- * (i.e. not "In" or "Out"), it may still be useful to capture this value
- * for reporting purposes. Implementations can capture this value in a
- * MessagaLabel object by using the public static method <tt>invalidValue(String)</tt>
- * and can retrieve it using the <tt>toString()</tt> method.
+ * Valid MessageLabels are Singletons, so <tt>==</tt> and <tt>.equals</tt> are gauranteed
+ * to return the same result.
+ * <p>
+ * If a <tt>messageLabel</tt> attribute in the WSDL specifies an invalid value
+ * (i.e. not represented by a constant), it may still be useful to capture this
+ * value for reporting purposes. Use the public static method <tt>invalidValue(String)</tt>
+ * for this purpose.
+ * Invalid MessageLabels are not Singletons, so <tt>.equals</tt> is overridden to compare
+ * string contents for invalid MessageLabels and <tt>==</tt> is not gauranteed to return the same
+ * result as <tt>.equals</tt>.
* <p>
+ * TODO consider using a singleton map of invalid MessageLabels keyed by intern() strings
+ * so that '==' and '.equals' will return the same result, as they do for valid MessageLabels
+ * (i.e. remove the .equals() override and use object refs instead).
+ * <p>
* TODO if extensibility is required, chg ctor to protected
+ * <p>
+ * TODO confirm that 'isValid()' is needed as a public method on the API
*
* @author jkaputin@apache.org
*/
public class MessageLabel
{
+ public static final MessageLabel IN = new MessageLabel("In");
+ public static final MessageLabel OUT = new MessageLabel("Out");
+
+ public static final MessageLabel invalidValue(String value) {
+ return new MessageLabel(value.intern(), false);
+ }
+
private final String fValue;
- private MessageLabel(String value) { fValue = value; }
+ private boolean fValid = true;
+
+ private MessageLabel(String value) {
+ this(value, true);
+ }
+
+ private MessageLabel(String value, boolean valid) {
+ fValue = value;
+ fValid = valid;
+ }
+
public String toString() {return fValue;}
+ public boolean isValid() {return fValid;}
- public static final MessageLabel invalidValue(String value) {
- return new MessageLabel(value);
+ public boolean equals(MessageLabel other)
+ {
+ if(fValid)
+ {
+ //valid MessageLabel is Singleton, so compare object refs
+ return this == other;
+ }
+ else
+ {
+ //invalid MessageLabel is not Singleton, so compare contents
+ if(other != null) {
+ return this.fValue == other.toString();
+ } else {
+ return false;
+ }
+ }
}
- public static final MessageLabel IN = new MessageLabel("In");
- public static final MessageLabel OUT = new MessageLabel("Out");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org