Author: jkaputin
Date: Wed Jan 4 09:45:37 2006
New Revision: 365956
URL: http://svn.apache.org/viewcvs?rev=365956&view=rev
Log:
Change the implementation of binding faults collection
to a List, same as binding operations collection.
In addXXX() methods, check for a null arg to avoid adding
nulls to the Lists.
Modified:
incubator/woden/java/src/org/apache/woden/internal/wsdl20/BindingImpl.java
Modified:
incubator/woden/java/src/org/apache/woden/internal/wsdl20/BindingImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/BindingImpl.java?rev=365956&r1=365955&r2=365956&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/BindingImpl.java
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/BindingImpl.java
Wed Jan 4 09:45:37 2006
@@ -15,11 +15,8 @@
*/package org.apache.woden.internal.wsdl20;
import java.net.URI;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Vector;
import javax.xml.namespace.QName;
@@ -48,25 +45,15 @@
private URI fType = null;
/*
- * TODO determine type of retrieval required for binding faults and
operations
- * as this may influence the choice of collection type - e.g. Map for
keyed access,
- * or a List for sequential access.
- *
- * Binding faults and operations could be accessed by their 'ref'
attribute qname, which
- * typically suggests a Map implementation keyed by 'ref' qname. However,
with these
- * objects we have a null key problem when their 'ref' qname is missing.
These 'null key'
- * objects could be stored in a List, separately to the 'keyed' objects
stored in the Map -
- * i.e. they cannot be looked up in a Map because they have no key, but
they must be stored
- * so we store them in a list.
- *
- * TODO Final implementation choice will probably depend on what the
resulting code
- * looks like, its readability, etc. It may be that List is a better
implementation choice,
- * even for retrieval based on a 'ref' qname key, because the null key
problem does not arise.
- * For now, I have implemented binding faults as a Map of keyed objects
AND a list of null key
- * objects, and have implemented binding operations as a List to compare
the implementations.
+ * Binding faults and operations may be referred to specifically by the
qname represented by
+ * their 'ref' attribute. This typically suggests a Map implementation
keyed by 'ref' qname.
+ * However if the validation feature is disabled, it is possible that the
'ref' attribute may
+ * be missing, which will cause a null key problem if a Map is used.
+ * To avoid this problem, binding faults and operations will be stored in
Lists instead.
+ * This will avoid any null key issues, however it will make the
implementation of 'ref' based
+ * access more complicated.
*/
- private Map fFaultsWithRef = new HashMap();
- private List fFaultsWithoutRef = new Vector();
+ private List fFaults = new Vector();
private List fOperations = new Vector();
/* ************************************************************
@@ -98,36 +85,12 @@
}
/*
- * TODO see previous comments for fFaults about the null key problem
- * with the use of Map, rather than List.
- *
- * Binding faults are stored as a Map of BindingFaultImpl keyed by 'ref'
qname.
- * If a binding fault 'ref' qname is missing, it gets stored in the
fFaults Map in a
- * List of BindingFaultImpl keyed by null. To return a collection of all
binding faults
- * we need to combine this collection with the collection of binding
faults that do have
- * a 'ref' qname and have been stored in the Map against this key.
- *
- * This need to accomodate null keyed binding faults, makes Map a
complicated choice
- * compared to List, where the null key problem does not arise.
- * Map may be a suitable choice where retrieval by 'ref' qname is
required, but even that
- * can be achieved with a List implementation. See fOperations and
getBindingOperations()
- * to compare the List implementation.
- *
* @see org.apache.woden.wsdl20.Binding#getBindingFaults()
*/
public BindingFault[] getBindingFaults()
{
- Collection coll = null;
- if(fFaultsWithoutRef.isEmpty()) {
- coll = fFaultsWithRef.values();
- } else {
- coll = new Vector();
- coll.addAll(fFaultsWithoutRef);
- coll.addAll(fFaultsWithRef.values());
- }
-
- BindingFault[] array = new BindingFault[coll.size()];
- coll.toArray(array);
+ BindingFault[] array = new BindingFault[fFaults.size()];
+ fFaults.toArray(array);
return array;
}
@@ -188,43 +151,22 @@
}
/*
- * TODO see previous comments for fFaults and getBindingFaults() about the
null key problem
- * with the use of Map, rather than List.
- *
- * Binding faults are stored in a Map keyed by their 'ref' attribute
qname.
- * If they are missing their 'ref' qname, they are stored in a list
instead of the map.
- *
* @see
org.apache.woden.wsdl20.xml.BindingElement#addBindingFaultElement(org.apache.woden.wsdl20.xml.BindingFaultElement)
*/
public void addBindingFaultElement(BindingFaultElement fault)
{
- QName qname = fault.getRef();
- if(qname != null) {
- fFaultsWithRef.put(qname, fault);
- } else {
- fFaultsWithoutRef.add(fault);
+ if(fault != null) {
+ fFaults.add(fault);
}
}
/*
- * TODO see previous comments for fFaults and getBindingFaults() about the
null key problem
- * with the use of Map, rather than List.
- *
* @see
org.apache.woden.wsdl20.xml.BindingElement#getBindingFaultElements()
*/
public BindingFaultElement[] getBindingFaultElements()
{
- Collection coll = null;
- if(fFaultsWithoutRef.isEmpty()) {
- coll = fFaultsWithRef.values();
- } else {
- coll = new Vector();
- coll.addAll(fFaultsWithoutRef);
- coll.addAll(fFaultsWithRef.values());
- }
-
- BindingFaultElement[] array = new BindingFaultElement[coll.size()];
- coll.toArray(array);
+ BindingFaultElement[] array = new BindingFaultElement[fFaults.size()];
+ fFaults.toArray(array);
return array;
}
@@ -233,13 +175,16 @@
*/
public void addBindingOperationElement(BindingOperationElement operation)
{
- fOperations.add(operation);
+ if(operation != null) {
+ fOperations.add(operation);
+ }
}
/* (non-Javadoc)
* @see
org.apache.woden.wsdl20.xml.BindingElement#getBindingOperationElements()
*/
- public BindingOperationElement[] getBindingOperationElements() {
+ public BindingOperationElement[] getBindingOperationElements()
+ {
BindingOperationElement[] array = new
BindingOperationElement[fOperations.size()];
fOperations.toArray(array);
return array;
@@ -254,11 +199,30 @@
/*
* Get the binding fault with the specified 'ref' attribute qname.
*
- * TODO decide if this type of qname-based accessor is needed, either
internally or on API.
+ * TODO decide if this type of qname-based accessor is needed, either
internally or on API.
+ *
+ * Note that for this type of key-based access, the choice of List rather
than Map makes
+ * the implementation more complicated. However, the advantage of List is
that it avoids the
+ * null key problem that arises when the binding fault is missing its
'ref' attribute qname.
*/
public BindingFaultElement getBindingFaultElement(QName qname)
{
- return (BindingFaultElement)fFaultsWithRef.get(qname);
+ BindingFaultElement fault = null;
+ if(qname != null)
+ {
+ BindingFaultElement bindFault = null;
+ Iterator i = fFaults.iterator();
+ while(i.hasNext())
+ {
+ bindFault = (BindingFaultElement)i.next();
+ if(qname.equals(bindFault.getRef()))
+ {
+ fault = bindFault;
+ break;
+ }
+ }
+ }
+ return fault;
}
/*
@@ -266,13 +230,9 @@
*
* TODO decide if this type of qname-based accessor is needed, either
internally or on API.
*
- * Note that for this type of key-based access, the choice of List rather
than Map
- * makes the implementation more complicated - see
getBindingFaultElement(QName) for
- * a comparison. However, List may still be a better choice as it hides
the null key
- * problem that arises when the binding operation is missing its 'ref'
attribute qname.
- *
- * TODO see previous comments for fFaults and getBindingFaults() about the
null key problem
- * with the use of Map, rather than List.
+ * Note that for this type of key-based access, the choice of List rather
than Map makes
+ * the implementation more complicated. However, the advantage of List is
that it avoids the
+ * null key problem that arises when the binding operation is missing its
'ref' attribute qname.
*/
public BindingOperationElement getBindingOperationElement(QName qname)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]