You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sa...@apache.org on 2006/03/03 09:26:49 UTC

svn commit: r382719 [1/2] - in /webservices/commons/modules/policy/src/org/apache/ws/policy: ./ util/

Author: sanka
Date: Fri Mar  3 00:26:45 2006
New Revision: 382719

URL: http://svn.apache.org/viewcvs?rev=382719&view=rev
Log:
adding more javadoc comments

Modified:
    webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/CompositeAssertion.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/PrimitiveAssertion.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/XorCompositeAssertion.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/DOMPolicyReader.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/Loader.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/OMPolicyReader.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyReader.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyRegistry.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyUtil.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyWriter.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/SchemaRegistry.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/StAXPolicyWriter.java
    webservices/commons/modules/policy/src/org/apache/ws/policy/util/StringUtils.java

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java Fri Mar  3 00:26:45 2006
@@ -21,21 +21,21 @@
 
 /**
  * AbstractAssertion provides the default implementation of some basic functions
- * definded in Assertion interface.  
- *  
+ * definded in Assertion interface.
+ * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public abstract class AbstractAssertion implements Assertion {
-	
+
 	/** Flag to mark whether this assertion is in normalize format */
 	protected boolean flag = false;
-	
+
 	/** To store terms of this assertion */
 	protected ArrayList childTerms = new ArrayList();
-	
+
 	/** To refer to the parent of this assertion */
 	protected Assertion parent = null;
-	
+
 	/**
 	 * 
 	 * Default implementation of normalize() operation.
@@ -45,37 +45,39 @@
 	public Assertion normalize() throws UnsupportedOperationException {
 		return normalize(null);
 	}
-	
+
 	/**
 	 * Default implementation of intersect(Assertion) operation.
 	 * 
-	 * @param assertion the assertion to intersect with this object.
-	 * @return an assertion which is equivalent to the intersect of this 
+	 * @param assertion
+	 *            the assertion to intersect with this object.
+	 * @return an assertion which is equivalent to the intersect of this
 	 *         assertion and the argument.
-	 * 
+	 *  
 	 */
 	public Assertion intersect(Assertion assertion)
 			throws UnsupportedOperationException {
 		return intersect(assertion, null);
 	}
-	
+
 	/**
 	 * Default implementation of merge(Assertion) operation.
 	 * 
-	 * @param assertion the assertion to merge with this object.
-	 * @return an assertion which is equivalent to the merge of this assertion 
+	 * @param assertion
+	 *            the assertion to merge with this object.
+	 * @return an assertion which is equivalent to the merge of this assertion
 	 *         and the argument.
 	 */
 	public Assertion merge(Assertion assertion)
 			throws UnsupportedOperationException {
 		return merge(assertion, null);
 	}
-	
+
 	/**
 	 * Returns true if this assertion is in normalzied format.
 	 * 
-	 * @return true if this assertion is in normalized format. 
-	 */	
+	 * @return true if this assertion is in normalized format.
+	 */
 	public boolean isNormalized() {
 		return flag;
 	}
@@ -83,20 +85,21 @@
 	/**
 	 * Marks this assertion as it is in normalized format.
 	 * 
-	 * @param flag which marks this object as in its normalized format or not. 
+	 * @param flag
+	 *            which marks this object as in its normalized format or not.
 	 */
 	public void setNormalized(boolean flag) {
 		this.flag = flag;
-		
+
 		for (Iterator iterator = getTerms().iterator(); iterator.hasNext();) {
-			((Assertion) iterator.next()).setNormalized(flag);			
+			((Assertion) iterator.next()).setNormalized(flag);
 		}
 	}
-	
+
 	/**
 	 * Returns true if this assertion object has a parent.
 	 * 
-	 * @return returns true if this has a parent. 
+	 * @return returns true if this has a parent.
 	 */
 	public boolean hasParent() {
 		return (parent != null);
@@ -114,7 +117,8 @@
 	/**
 	 * Sets the parent of this assertion.
 	 * 
-	 * @param parent of this assertion.
+	 * @param parent
+	 *            of this assertion.
 	 */
 	public void setParent(Assertion parent) {
 		this.parent = parent;
@@ -123,16 +127,18 @@
 	/**
 	 * Adds an assertion as a term of this assertion.
 	 * 
-	 * @param assertion the term to add
+	 * @param assertion
+	 *            the term to add
 	 */
 	public void addTerm(Assertion assertion) {
 		childTerms.add(assertion);
 	}
-	
+
 	/**
 	 * Adds a list of assertions as terms of this assertion.
 	 * 
-	 * @param assertions list of terms to add
+	 * @param assertions
+	 *            list of terms to add
 	 */
 	public void addTerms(List assertions) {
 		childTerms.addAll(assertions);
@@ -141,7 +147,8 @@
 	/**
 	 * Returns the list of terms of this assertion.
 	 * 
-	 * @param a list of terms of this assertion.
+	 * @param a
+	 *            list of terms of this assertion.
 	 */
 	public List getTerms() {
 		return childTerms;
@@ -151,16 +158,17 @@
 	 * Returns true if this assertion has no terms.
 	 * 
 	 * @return if this assertion has no terms.
-	 * 
+	 *  
 	 */
 	public boolean isEmpty() {
 		return childTerms.isEmpty();
 	}
-	
+
 	/**
 	 * Remove the geven term from the set of terms of this assertion.
 	 * 
-	 * @param returns true if the assertion is removed.
+	 * @param returns
+	 *            true if the assertion is removed.
 	 */
 	public boolean remove(Assertion assertion) {
 		return childTerms.remove(assertion);
@@ -174,4 +182,4 @@
 	public int size() {
 		return childTerms.size();
 	}
-}
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java Fri Mar  3 00:26:45 2006
@@ -27,8 +27,9 @@
 import org.apache.ws.policy.util.PolicyRegistry;
 
 /**
- * AndCompositeAssertion represents either policy or a single policy
- * alternative. It requires that all its terms are satisfied.
+ * AndCompositeAssertion requires that all of its terms are met.
+ * 
+ * Sanka Samaranayake (sanka@apache.org)
  */
 public class AndCompositeAssertion extends AbstractAssertion implements
 		CompositeAssertion {

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java Fri Mar  3 00:26:45 2006
@@ -22,6 +22,8 @@
 /**
  * Assertion is an interface which all constructs of policy must implement. It
  * defines three policy operations that all policy constructs must support.
+ * 
+ * Sanka Samaranayake (sanka@apache.org)
  */
 
 public interface Assertion {
@@ -121,13 +123,14 @@
 
 	/**
 	 * Returns true if the assertion is in normalized form.
-	 *  
+	 * 
 	 * @return true if the assertion is in normalized form.
 	 */
 	public boolean isNormalized();
 
 	/**
 	 * Marks this assertion as in normalized form.
+	 * 
 	 * @param flag
 	 */
 	public void setNormalized(boolean flag);
@@ -157,21 +160,23 @@
 	/**
 	 * Adds an assertion as a term of this assertion.
 	 * 
-	 * @param assertion the assertion to add as a term
+	 * @param assertion
+	 *            the assertion to add as a term
 	 */
 	public void addTerm(Assertion assertion);
 
 	/**
 	 * Adds a list of assertions as terms of this assertion.
 	 * 
-	 * @param assertions the list of assertions to add as terms
+	 * @param assertions
+	 *            the list of assertions to add as terms
 	 */
 	public void addTerms(List assertions);
 
 	/**
 	 * Returns the list of terms of this assertion.
 	 * 
-	 * @return list of terms 
+	 * @return list of terms
 	 */
 	public List getTerms();
 
@@ -185,7 +190,8 @@
 	/**
 	 * Removes the specified assertion from the terms list.
 	 * 
-	 * @param assertion the assertion to remove from the terms list.
+	 * @param assertion
+	 *            the assertion to remove from the terms list.
 	 * @return true if it is removed from the child list.
 	 */
 	public boolean remove(Assertion assertion);
@@ -199,15 +205,15 @@
 
 	/**
 	 * Returns a short type which describes the type of the assertion.
-	 *  
+	 * 
 	 * @return a short value of one of following values:
 	 * 
-	 *			PRIMITIVE_TYPE     : if the assertion is a PrimitiveAssertion
-	 * 			COMPOSITE_AND_TYPE : if the assertion is a AndCompositeAssertion
-	 *          COMPOSITE_XOR_TYPE : if the assertion is a XorCompositeAssertion
-	 * 			COMPOSITE_POLICY_TYPE : if the assertion is a Policy
-	 * 			POLICY_REFERENCE_TYPE : if the assertion is a PolicyReferece 			    
+	 * PRIMITIVE_TYPE : if the assertion is a PrimitiveAssertion
+	 * COMPOSITE_AND_TYPE : if the assertion is a AndCompositeAssertion
+	 * COMPOSITE_XOR_TYPE : if the assertion is a XorCompositeAssertion
+	 * COMPOSITE_POLICY_TYPE : if the assertion is a Policy
+	 * POLICY_REFERENCE_TYPE : if the assertion is a PolicyReferece
 	 */
 	public short getType();
-	
+
 }

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/CompositeAssertion.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/CompositeAssertion.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/CompositeAssertion.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/CompositeAssertion.java Fri Mar  3 00:26:45 2006
@@ -15,12 +15,11 @@
  */
 package org.apache.ws.policy;
 
-
 /**
- * CompositeAssertion interface is a marker interface for indecating which 
- * Assertions are CompositeAssertion type. 
+ * CompositeAssertion interface is a marker interface for indecating which
+ * Assertions are CompositeAssertion type.
  * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
-public interface CompositeAssertion extends Assertion {		
+public interface CompositeAssertion extends Assertion {
 }

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java Fri Mar  3 00:26:45 2006
@@ -26,8 +26,8 @@
 
 /**
  * Policy class is the runtime representation of a policy. It provides a
- * convenient model to store process any policy. Policy object requires that all 
- * its terms are met.   
+ * convenient model to store process any policy. Policy object requires that all
+ * its terms are met.
  */
 public class Policy extends AbstractAssertion implements CompositeAssertion {
 	private Log log = LogFactory.getLog(this.getClass().getName());
@@ -42,12 +42,12 @@
 	 */
 	public Policy() {
 	}
-	
-	
+
 	/**
 	 * Creates a policy object with the specified Id
 	 * 
-	 * @param id a string as the id
+	 * @param id
+	 *            a string as the id
 	 */
 	public Policy(String id) {
 		this(null, id);
@@ -55,10 +55,12 @@
 	}
 
 	/**
-	 * Creates a policy object with the specified xml-base and id. 
+	 * Creates a policy object with the specified xml-base and id.
 	 * 
-	 * @param xmlBase the xml-base
-	 * @param id a string as the id 
+	 * @param xmlBase
+	 *            the xml-base
+	 * @param id
+	 *            a string as the id
 	 */
 	public Policy(String xmlBase, String id) {
 		this.xmlBase = xmlBase;
@@ -69,15 +71,16 @@
 	/**
 	 * Set the xml-base of the policy object
 	 * 
-	 * @param xmlBase the xml base of the policy object
+	 * @param xmlBase
+	 *            the xml base of the policy object
 	 */
 	public void setBase(String xmlBase) {
 		this.xmlBase = xmlBase;
 	}
 
 	/**
-	 * Returns the xml-base of the policy object. Returns null if
-	 * no xml-base is set.
+	 * Returns the xml-base of the policy object. Returns null if no xml-base is
+	 * set.
 	 * 
 	 * @return xml base of the policy object
 	 */
@@ -104,9 +107,9 @@
 	}
 
 	/**
-	 * Returns a String which uniquely identify the policy object. It has the format of
-	 * {$xmlBase}#{$id}. If the xmlBase is null it will return #{$id} as the URI String.
-	 * If the Id is null, this will return.
+	 * Returns a String which uniquely identify the policy object. It has the
+	 * format of {$xmlBase}#{$id}. If the xmlBase is null it will return #{$id}
+	 * as the URI String. If the Id is null, this will return.
 	 * 
 	 * @return a String which uniquely identify the policy object.
 	 */
@@ -350,7 +353,7 @@
 	}
 
 	/**
-	 * Returns a short value which indicates this is a Policy.  
+	 * Returns a short value which indicates this is a Policy.
 	 */
 	public final short getType() {
 		return Assertion.COMPOSITE_POLICY_TYPE;

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java Fri Mar  3 00:26:45 2006
@@ -1,4 +1,5 @@
 package org.apache.ws.policy;
+
 /*
  * Copyright 2001-2004 The Apache Software Foundation.
  * 
@@ -16,36 +17,36 @@
  */
 
 /**
- * PolicyConstants interfaces defines some CONST VALUES that are used in the 
+ * PolicyConstants interfaces defines some CONST VALUES that are used in the
  * entier framework.
  */
 public interface PolicyConstants {
-    
-    /** Tag name of AndComposteAssertion */
-    public static final String AND_COMPOSITE_ASSERTION = "All";
-    
-    /** Tag name of XorCompositeAssertion */
-    public static final String XOR_COMPOSITE_ASSERTION = "ExactlyOne";
-    
-    /** Tag name of Policy */
-    public static final String WS_POLICY = "Policy";
-    
-    /** Prefix of WS-Policy namespace*/
-    public static final String WS_POLICY_PREFIX = "wsp";
-    
-    /** Prefix of WSU namespace*/
-    public static final String WSU_NAMESPACE_PREFIX = "wsu";
-    
-    /** Tag name of PolicyReference*/
-    public static final String WS_POLICY_REFERENCE = "PolicyReference";
-    
-    /** Namespace of WS-Policy */
-    public static final String WS_POLICY_NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/09/policy";
-    
-    /** Namespace of WSU*/
-    public static final String WSU_NAMESPACE_URI = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
- 
-    /** XML namespace */
-    public static final String XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
-    
-}
+
+	/** Tag name of AndComposteAssertion */
+	public static final String AND_COMPOSITE_ASSERTION = "All";
+
+	/** Tag name of XorCompositeAssertion */
+	public static final String XOR_COMPOSITE_ASSERTION = "ExactlyOne";
+
+	/** Tag name of Policy */
+	public static final String WS_POLICY = "Policy";
+
+	/** Prefix of WS-Policy namespace */
+	public static final String WS_POLICY_PREFIX = "wsp";
+
+	/** Prefix of WSU namespace */
+	public static final String WSU_NAMESPACE_PREFIX = "wsu";
+
+	/** Tag name of PolicyReference */
+	public static final String WS_POLICY_REFERENCE = "PolicyReference";
+
+	/** Namespace of WS-Policy */
+	public static final String WS_POLICY_NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+
+	/** Namespace of WSU */
+	public static final String WSU_NAMESPACE_URI = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+
+	/** XML namespace */
+	public static final String XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
+
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/PrimitiveAssertion.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/PrimitiveAssertion.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/PrimitiveAssertion.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/PrimitiveAssertion.java Fri Mar  3 00:26:45 2006
@@ -28,14 +28,16 @@
 import org.apache.ws.policy.util.PolicyUtil;
 
 /**
- * PrimitiveAssertion wraps an assertion which is indivisible. Such assertion
- * require domain specific knowledge for further processing. Hence this class
- * seperates that domain specific knowledge from generic framework.
+ * PrimitiveAssertion wraps an assertion which contain domain specific
+ * knowledge. This type of an assertion should only be evaluated by a component
+ * which contains the required knowledge. For instance a PrimitiveAssertion
+ * which contains a WSSecurity policy assertionshould be processed only by the
+ * security module.
  * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public class PrimitiveAssertion extends AbstractAssertion implements Assertion {
-	
+
 	private Log log = LogFactory.getLog(this.getClass().getName());
 
 	private Assertion owner = null;
@@ -75,13 +77,14 @@
 		log.debug("Enter: PrimitveAssertion:intersect");
 
 		Assertion normalizedMe = (isNormalized()) ? this : normalize(reg);
-		
-		if (! (normalizedMe instanceof PrimitiveAssertion)) {
+
+		if (!(normalizedMe instanceof PrimitiveAssertion)) {
 			return normalizedMe.intersect(assertion, reg);
 		}
-		
-		Assertion target = (assertion.isNormalized()) ? assertion : assertion.normalize(reg);
-		
+
+		Assertion target = (assertion.isNormalized()) ? assertion : assertion
+				.normalize(reg);
+
 		// Am not a primitive assertion anymore ..
 		if (!(assertion instanceof PrimitiveAssertion)) {
 			return normalizedMe.intersect(assertion, reg);
@@ -128,10 +131,10 @@
 
 		///////////////////////////////////////////////////////////////////////
 		///////////////////////////////////////////////////////////////////////
-		
+
 		PrimitiveAssertion PRIMITIVE_A, PRIMITIVE_B = null;
 		List primListA, primListB;
-		
+
 		if (selfChildTerms.size() > argChildTerms.size()) {
 			primListA = selfChildTerms;
 			primListB = argChildTerms;
@@ -139,14 +142,14 @@
 			primListA = argChildTerms;
 			primListB = selfChildTerms;
 		}
-		
+
 		boolean isIntersect = false;
-		
+
 		for (Iterator iterator = primListA.iterator(); iterator.hasNext();) {
 			PRIMITIVE_A = (PrimitiveAssertion) iterator.next();
-			
+
 			boolean found = false;
-			
+
 			for (Iterator iterator2 = primListB.iterator(); iterator2.hasNext();) {
 				PRIMITIVE_B = (PrimitiveAssertion) iterator2.next();
 				if (PRIMITIVE_A.getName().equals(PRIMITIVE_B.getName())) {
@@ -154,34 +157,20 @@
 					break;
 				}
 			}
-			
+
 			if (!found) {
 				return new XorCompositeAssertion();
 			}
-			
+
 			if (PRIMITIVE_A.intersect(PRIMITIVE_B) instanceof XorCompositeAssertion) {
 				return new XorCompositeAssertion();
 			}
 		}
-		
 
 		AndCompositeAssertion andCompositeAssertion = new AndCompositeAssertion();
 		andCompositeAssertion.addTerm(arg);
 		andCompositeAssertion.addTerm(self);
 		return andCompositeAssertion;
-
-		
-		///////////////////////////////////////////////////////////////////////
-		///////////////////////////////////////////////////////////////////////
-//		if (PolicyUtil.matchByQName(argChildTerms, selfChildTerms)) {
-//
-//			AndCompositeAssertion andCompositeAssertion = new AndCompositeAssertion();
-//			andCompositeAssertion.addTerm(arg);
-//			andCompositeAssertion.addTerm(self);
-//			return andCompositeAssertion;
-//		}
-//
-//		return new XorCompositeAssertion();
 	}
 
 	public Assertion intersect(Assertion assertion)
@@ -281,8 +270,8 @@
 		}
 
 		Policy policyTerm = PolicyUtil.getSinglePolicy(policyTerms, reg);
-		Assertion xorTerm = (XorCompositeAssertion) policyTerm
-				.getTerms().get(0);
+		Assertion xorTerm = (XorCompositeAssertion) policyTerm.getTerms()
+				.get(0);
 
 		List ANDs = xorTerm.getTerms();
 
@@ -374,9 +363,9 @@
 	public void addTerm(Assertion term) {
 		terms.add(term);
 	}
-	
+
 	public void addTerms(List terms) {
-		terms.addAll(terms);		
+		terms.addAll(terms);
 	}
 
 	public boolean isNormalized() {
@@ -430,7 +419,7 @@
 	public int size() {
 		return terms.size();
 	}
-	
+
 	private Policy getSinglePolicy(List childTerms) {
 		Policy policy = new Policy();
 		XorCompositeAssertion xor = new XorCompositeAssertion();
@@ -451,7 +440,7 @@
 		return ((AndCompositeAssertion) ((XorCompositeAssertion) policy
 				.getTerms().get(0)).getTerms().get(0)).getTerms();
 	}
-	
+
 	public final short getType() {
 		return Assertion.PRIMITIVE_TYPE;
 	}

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/XorCompositeAssertion.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/XorCompositeAssertion.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/XorCompositeAssertion.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/XorCompositeAssertion.java Fri Mar  3 00:26:45 2006
@@ -24,9 +24,9 @@
 import org.apache.ws.policy.util.PolicyRegistry;
 
 /**
- * XORCompositeAssertion represents a bunch of policy alternatives. It requires
- * that exactly one of its terms (policy alternative) is statisfied.
- *  
+ * XorCompositeAssertion requires that exactly one of its terms are met.
+ * 
+ * Sanka Samaranayake (sanka@apache.org)
  */
 public class XorCompositeAssertion extends AbstractAssertion implements
 		CompositeAssertion {
@@ -114,119 +114,77 @@
 		short type = target.getType();
 
 		switch (type) {
-		
+
 		case Assertion.COMPOSITE_POLICY_TYPE: {
 			Policy nPOLICY = new Policy();
 			nPOLICY.addTerm(((XorCompositeAssertion) normalizedMe.getTerms()
 					.get(0)).intersect(target));
 			return nPOLICY;
 		}
-		
+
 		case Assertion.COMPOSITE_XOR_TYPE: {
 			XorCompositeAssertion nXOR = new XorCompositeAssertion();
 
 			Assertion asser;
 			AndCompositeAssertion AND;
-			
-			for (Iterator iterator = normalizedMe.getTerms().iterator(); iterator.hasNext(); ) {
+
+			for (Iterator iterator = normalizedMe.getTerms().iterator(); iterator
+					.hasNext();) {
 				AND = (AndCompositeAssertion) iterator.next();
-				
-				for (Iterator iterator2 = target.getTerms().iterator(); iterator2.hasNext(); ) {
-					asser = AND.intersect((AndCompositeAssertion) iterator2.next());
-					
+
+				for (Iterator iterator2 = target.getTerms().iterator(); iterator2
+						.hasNext();) {
+					asser = AND.intersect((AndCompositeAssertion) iterator2
+							.next());
+
 					if (asser instanceof AndCompositeAssertion) {
 						nXOR.addTerm(asser);
 					}
 				}
 			}
-			
+
 			return nXOR;
 		}
-		
-		case Assertion.COMPOSITE_AND_TYPE : {
+
+		case Assertion.COMPOSITE_AND_TYPE: {
 			XorCompositeAssertion nXOR = new XorCompositeAssertion();
 			Assertion asser;
-			
-			for (Iterator iterator = normalizedMe.getTerms().iterator(); iterator.hasNext();) {
-				asser = ((AndCompositeAssertion) iterator.next()).intersect(target);
-				
+
+			for (Iterator iterator = normalizedMe.getTerms().iterator(); iterator
+					.hasNext();) {
+				asser = ((AndCompositeAssertion) iterator.next())
+						.intersect(target);
+
 				if (asser instanceof AndCompositeAssertion) {
 					nXOR.addTerm(asser);
 				}
 			}
 			return nXOR;
 		}
-		
+
 		case Assertion.PRIMITIVE_TYPE: {
 			XorCompositeAssertion nXOR = new XorCompositeAssertion();
-			
+
 			Assertion asser;
-			
-			for (Iterator iterator = normalizedMe.getTerms().iterator(); iterator.hasNext(); ) {
-				asser = ((AndCompositeAssertion) iterator.next()).intersect(target);
-				
+
+			for (Iterator iterator = normalizedMe.getTerms().iterator(); iterator
+					.hasNext();) {
+				asser = ((AndCompositeAssertion) iterator.next())
+						.intersect(target);
+
 				if (asser instanceof AndCompositeAssertion) {
 					nXOR.addTerm(asser);
 				}
 			}
 			return nXOR;
 		}
-		
+
 		default: {
-			throw new IllegalArgumentException("intersect for assertion type " + target.getClass().getName() + " not defined");
+			throw new IllegalArgumentException("intersect for assertion type "
+					+ target.getClass().getName() + " not defined");
 		}
-		
+
 		}
-		
-		
-//
-//		XorCompositeAssertion result = new XorCompositeAssertion();
-//
-//		if (assertion instanceof PrimitiveAssertion) {
-//
-//			Iterator iterator = normalizedMe.getTerms().iterator();
-//
-//			while (iterator.hasNext()) {
-//				AndCompositeAssertion andTerm = (AndCompositeAssertion) iterator
-//						.next();
-//				Assertion value = andTerm.intersect(assertion);
-//				if (value instanceof AndCompositeAssertion) {
-//					result.addTerm(value);
-//				}
-//			}
-//
-//		} else {
-//
-//			Iterator iterator = normalizedMe.getTerms().iterator();
-//			while (iterator.hasNext()) {
-//				AndCompositeAssertion andTerm = (AndCompositeAssertion) iterator
-//						.next();
-//
-//				if (target instanceof AndCompositeAssertion) {
-//					Assertion value = andTerm.intersect(target);
-//
-//					if (value instanceof AndCompositeAssertion) {
-//						result.addTerm(value);
-//					}
-//
-//				} else if (target instanceof XorCompositeAssertion) {
-//
-//					Iterator andTerms = target.getTerms().iterator();
-//
-//					while (andTerms.hasNext()) {
-//						AndCompositeAssertion tAndTerm = (AndCompositeAssertion) andTerms
-//								.next();
-//						Assertion value = andTerm.intersect(tAndTerm);
-//
-//						if (value instanceof AndCompositeAssertion) {
-//							result.addTerm(value);
-//						}
-//					}
-//				}
-//			}
-//		}
-//
-//		return result;
 	}
 
 	public Assertion merge(Assertion assertion, PolicyRegistry reg) {
@@ -268,7 +226,7 @@
 				}
 
 				if (target.isEmpty() && AND.isEmpty()) { // FIXME is this a
-														 // hack?
+					// hack?
 					/*
 					 * " <wsp:ExactlyOne> <wsp:All/>
 					 * </wsp:ExactlyOne>".intersect(" <wsp:ExactlyOne/>")

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/DOMPolicyReader.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/DOMPolicyReader.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/DOMPolicyReader.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/DOMPolicyReader.java Fri Mar  3 00:26:45 2006
@@ -16,7 +16,6 @@
 
 package org.apache.ws.policy.util;
 
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -45,175 +44,182 @@
 import org.apache.ws.policy.XorCompositeAssertion;
 
 /**
+ * DOMPolicyReader implements PolicyReader and provides different methods to
+ * create a policy object. It uses DOM as it underlying mechanism to XML.
+ * 
  * @author Werner Dittmann (werner@apache.org)
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public class DOMPolicyReader implements PolicyReader {
-    public static final String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
+	public static final String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
 
-    DOMPolicyReader() {
-    }
+	DOMPolicyReader() {
+	}
 
-    public Policy readPolicy(InputStream in) {
-        try {
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
-            dbf.setNamespaceAware(true);
-            dbf.setValidating(false);
-
-            DocumentBuilder db = dbf.newDocumentBuilder();
-            Document doc = db.parse(in);
-            Element element = doc.getDocumentElement();
-            return readPolicy(element);
-        } catch (ParserConfigurationException e) {
-            e.printStackTrace();
-            throw new RuntimeException("error : " + e.getMessage());
-        } catch (SAXException e) {
-            e.printStackTrace();
-            throw new RuntimeException("error : " + e.getMessage());
-        } catch (IOException e) {
-            e.printStackTrace();
-            throw new RuntimeException("error : " + e.getMessage());
-        }
-    }
-
-    private Assertion readAssertion(Element element) {
-        String namespace = element.getNamespaceURI();
-        String localName = element.getLocalName();
-
-        if (!(namespace.equals(PolicyConstants.WS_POLICY_NAMESPACE_URI))) {
-            return readPrimitiveAssertion(element);
-        }
-
-        if (localName.equals(PolicyConstants.WS_POLICY)) {
-            return readPolicy(element);
-
-        } else if (localName.equals(PolicyConstants.AND_COMPOSITE_ASSERTION)) {
-            return readAndComposite(element);
-
-        } else if (localName.equals(PolicyConstants.XOR_COMPOSITE_ASSERTION)) {
-            return readXorComposite(element);
-
-        } else if (localName.equals(PolicyConstants.WS_POLICY_REFERENCE)) {
-            return readPolicyReference(element);
-
-        } else {
-            throw new RuntimeException("unknown element ..");
-        }
-    }
-
-    public Policy readPolicy(Element element) {
-        Policy policy = new Policy();
-        Attr attri;
-        attri = element.getAttributeNodeNS(PolicyConstants.WSU_NAMESPACE_URI, "Id");
-        if (attri != null) {
-            policy.setId(attri.getValue());
-        }
-
-        attri = element.getAttributeNodeNS(PolicyConstants.XML_NAMESPACE_URI, "base");
-        if (attri != null) {
-            policy.setBase(attri.getValue());
-        }
-
-        policy.addTerms(readTerms(element));
-        return policy;
-    }
-
-    private AndCompositeAssertion readAndComposite(Element element) {
-        AndCompositeAssertion andCompositeAssertion = new AndCompositeAssertion();
-        andCompositeAssertion.addTerms(readTerms(element));
-        return andCompositeAssertion;
-    }
-
-    private XorCompositeAssertion readXorComposite(Element element) {
-        XorCompositeAssertion xorCompositeAssertion = new XorCompositeAssertion();
-        xorCompositeAssertion.addTerms(readTerms(element));
-        return xorCompositeAssertion;
-    }
-
-    public PolicyReference readPolicyReference(Element element) {
-        Attr attribute = element.getAttributeNode("URI");
-        return new PolicyReference(attribute.getValue());
-    }
-
-    private PrimitiveAssertion readPrimitiveAssertion(Element element) {
-        QName qname = new QName(element.getNamespaceURI(), element.getLocalName(), element.getPrefix());
-        PrimitiveAssertion result = new PrimitiveAssertion(qname);
-
-        result.setAttributes(getAttributes(element));
-        String isOptional = result.getAttribute(new QName(
-                PolicyConstants.WS_POLICY_NAMESPACE_URI, "Optional"));
-        result.setOptional(new Boolean(isOptional).booleanValue());
-
-        //CHECK ME
-        NodeList list = element.getChildNodes();
-        int length = list.getLength();
-
-        for (int i = 0; i < length; i++) {
-            Node node = list.item(i);
-            short nodeType = node.getNodeType();
-
-            if (nodeType == Node.ELEMENT_NODE) {
-                Element childElement = (Element) node;
-                if (childElement.getNamespaceURI().equals(
-                        PolicyConstants.WS_POLICY_NAMESPACE_URI)
-                        && childElement.getLocalName().equals(
-                        PolicyConstants.WS_POLICY)) {
-                    Policy policy = readPolicy(childElement);
-                    result.addTerm(policy);
-
-                } else {
-                    PrimitiveAssertion pa = readPrimitiveAssertion(childElement);
-                    result.addTerm(pa);
-                }
-            }
-            else if (nodeType == Node.TEXT_NODE) {
-                String strValue = node.getNodeValue();
-
-                if (strValue != null && strValue.length() != 0) {
-                    result.setStrValue(strValue);
-                }
-            }
-        }
-        return result;
-    }
-
-    private ArrayList readTerms(Element element) {
-        ArrayList terms = new ArrayList();
-        NodeList list = element.getChildNodes();
-        int length = list.getLength();
-
-        for (int i = 0; i < length; i++) {
-            Object obj = list.item(i);
-
-            if (obj instanceof Element) {
-                Element e = (Element) obj;
-                terms.add(readAssertion(e));
-            }
-        }
-        return terms;
-    }
-
-    private Hashtable getAttributes(Element element) {
-        Hashtable attributes = new Hashtable();
-        NamedNodeMap map = element.getAttributes();
-
-        int length = map.getLength();
-
-        for (int i = 0; i < length; i++) {
-            Attr attribute = (Attr) map.item(i);
-            if (!XMLNS_NS_URI.equals(attribute.getNamespaceURI())){
-                String prefix = attribute.getPrefix();
-                QName qn = null;
-                if (prefix != null) {
-                    qn = new QName(attribute.getNamespaceURI(), attribute.getLocalName(), prefix);
-                }else {
-                    qn = new QName(attribute.getNamespaceURI(), attribute.getLocalName());
-                }
-                attributes.put(qn, attribute.getValue());
-            }
-
-        }
-        return attributes;
-    }
+	public Policy readPolicy(InputStream in) {
+		try {
+			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+			dbf.setNamespaceAware(true);
+			dbf.setValidating(false);
+
+			DocumentBuilder db = dbf.newDocumentBuilder();
+			Document doc = db.parse(in);
+			Element element = doc.getDocumentElement();
+			return readPolicy(element);
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+			throw new RuntimeException("error : " + e.getMessage());
+		} catch (SAXException e) {
+			e.printStackTrace();
+			throw new RuntimeException("error : " + e.getMessage());
+		} catch (IOException e) {
+			e.printStackTrace();
+			throw new RuntimeException("error : " + e.getMessage());
+		}
+	}
+
+	private Assertion readAssertion(Element element) {
+		String namespace = element.getNamespaceURI();
+		String localName = element.getLocalName();
+
+		if (!(namespace.equals(PolicyConstants.WS_POLICY_NAMESPACE_URI))) {
+			return readPrimitiveAssertion(element);
+		}
+
+		if (localName.equals(PolicyConstants.WS_POLICY)) {
+			return readPolicy(element);
+
+		} else if (localName.equals(PolicyConstants.AND_COMPOSITE_ASSERTION)) {
+			return readAndComposite(element);
+
+		} else if (localName.equals(PolicyConstants.XOR_COMPOSITE_ASSERTION)) {
+			return readXorComposite(element);
+
+		} else if (localName.equals(PolicyConstants.WS_POLICY_REFERENCE)) {
+			return readPolicyReference(element);
+
+		} else {
+			throw new RuntimeException("unknown element ..");
+		}
+	}
+
+	public Policy readPolicy(Element element) {
+		Policy policy = new Policy();
+		Attr attri;
+		attri = element.getAttributeNodeNS(PolicyConstants.WSU_NAMESPACE_URI,
+				"Id");
+		if (attri != null) {
+			policy.setId(attri.getValue());
+		}
+
+		attri = element.getAttributeNodeNS(PolicyConstants.XML_NAMESPACE_URI,
+				"base");
+		if (attri != null) {
+			policy.setBase(attri.getValue());
+		}
+
+		policy.addTerms(readTerms(element));
+		return policy;
+	}
+
+	private AndCompositeAssertion readAndComposite(Element element) {
+		AndCompositeAssertion andCompositeAssertion = new AndCompositeAssertion();
+		andCompositeAssertion.addTerms(readTerms(element));
+		return andCompositeAssertion;
+	}
+
+	private XorCompositeAssertion readXorComposite(Element element) {
+		XorCompositeAssertion xorCompositeAssertion = new XorCompositeAssertion();
+		xorCompositeAssertion.addTerms(readTerms(element));
+		return xorCompositeAssertion;
+	}
+
+	public PolicyReference readPolicyReference(Element element) {
+		Attr attribute = element.getAttributeNode("URI");
+		return new PolicyReference(attribute.getValue());
+	}
+
+	private PrimitiveAssertion readPrimitiveAssertion(Element element) {
+		QName qname = new QName(element.getNamespaceURI(), element
+				.getLocalName(), element.getPrefix());
+		PrimitiveAssertion result = new PrimitiveAssertion(qname);
+
+		result.setAttributes(getAttributes(element));
+		String isOptional = result.getAttribute(new QName(
+				PolicyConstants.WS_POLICY_NAMESPACE_URI, "Optional"));
+		result.setOptional(new Boolean(isOptional).booleanValue());
+
+		//CHECK ME
+		NodeList list = element.getChildNodes();
+		int length = list.getLength();
+
+		for (int i = 0; i < length; i++) {
+			Node node = list.item(i);
+			short nodeType = node.getNodeType();
+
+			if (nodeType == Node.ELEMENT_NODE) {
+				Element childElement = (Element) node;
+				if (childElement.getNamespaceURI().equals(
+						PolicyConstants.WS_POLICY_NAMESPACE_URI)
+						&& childElement.getLocalName().equals(
+								PolicyConstants.WS_POLICY)) {
+					Policy policy = readPolicy(childElement);
+					result.addTerm(policy);
+
+				} else {
+					PrimitiveAssertion pa = readPrimitiveAssertion(childElement);
+					result.addTerm(pa);
+				}
+			} else if (nodeType == Node.TEXT_NODE) {
+				String strValue = node.getNodeValue();
+
+				if (strValue != null && strValue.length() != 0) {
+					result.setStrValue(strValue);
+				}
+			}
+		}
+		return result;
+	}
+
+	private ArrayList readTerms(Element element) {
+		ArrayList terms = new ArrayList();
+		NodeList list = element.getChildNodes();
+		int length = list.getLength();
+
+		for (int i = 0; i < length; i++) {
+			Object obj = list.item(i);
+
+			if (obj instanceof Element) {
+				Element e = (Element) obj;
+				terms.add(readAssertion(e));
+			}
+		}
+		return terms;
+	}
+
+	private Hashtable getAttributes(Element element) {
+		Hashtable attributes = new Hashtable();
+		NamedNodeMap map = element.getAttributes();
+
+		int length = map.getLength();
+
+		for (int i = 0; i < length; i++) {
+			Attr attribute = (Attr) map.item(i);
+			if (!XMLNS_NS_URI.equals(attribute.getNamespaceURI())) {
+				String prefix = attribute.getPrefix();
+				QName qn = null;
+				if (prefix != null) {
+					qn = new QName(attribute.getNamespaceURI(), attribute
+							.getLocalName(), prefix);
+				} else {
+					qn = new QName(attribute.getNamespaceURI(), attribute
+							.getLocalName());
+				}
+				attributes.put(qn, attribute.getValue());
+			}
+
+		}
+		return attributes;
+	}
 }

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/Loader.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/Loader.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/Loader.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/Loader.java Fri Mar  3 00:26:45 2006
@@ -24,141 +24,150 @@
 import java.net.URL;
 
 /**
- * Load resources (or images) from various sources.
- * <p/>
- *
+ * Load resources (or images) from various sources. <p/>
+ * 
  * @author Davanum Srinivas (dims@yahoo.com).
  */
 public class Loader {
-    private static Log log = LogFactory.getLog(Loader.class.getName());
+	private static Log log = LogFactory.getLog(Loader.class.getName());
 
-    /**
-     * This method will search for <code>resource</code> in different
-     * places. The rearch order is as follows:
-     * <ol>
-     * <p><li>Search for <code>resource</code> using the thread context
-     * class loader under Java2. If that fails, search for
-     * <code>resource</code> using the class loader that loaded this
-     * class (<code>Loader</code>).
-     * <p><li>Try one last time with
-     * <code>ClassLoader.getSystemResource(resource)</code>, that is is
-     * using the system class loader in JDK 1.2 and virtual machine's
-     * built-in class loader in JDK 1.1.
-     * </ol>
-     * <p/>
-     *
-     * @param resource
-     * @return TODO
-     */
-    static public URL getResource(String resource) {
-        ClassLoader classLoader = null;
-        URL url = null;
-        try {
-            // We could not find resource. Ler us now try with the
-            // classloader that loaded this class.
-            classLoader = getTCL();
-            if (classLoader != null) {
-                log.debug("Trying to find [" + resource + "] using " + classLoader + " class loader.");
-                url = classLoader.getResource(resource);
-                if (url != null) {
-                    return url;
-                }
-            }
-        } catch (Throwable t) {
-            log.warn("Caught Exception while in Loader.getResource. This may be innocuous.", t);
-        }
-    
-        // Last ditch attempt: get the resource from the class path. It
-        // may be the case that clazz was loaded by the Extentsion class
-        // loader which the parent of the system class loader. Hence the
-        // code below.
-        log.debug("Trying to find [" + resource + "] using ClassLoader.getSystemResource().");
-        return ClassLoader.getSystemResource(resource);
-    }
-    
-
-    /**
-     * Try to get the resource with the specified class loader
-     * <p/>
-     *
-     * @param loader The classloader to use
-     * @param resource The resources' path
-     * @return The URL of the resource
-     * @throws ClassNotFoundException
-     */
-    static public URL getResource(ClassLoader loader, String resource) throws ClassNotFoundException {
-        URL url = null;
-        try {
-            if (loader != null) {
-                log.debug("Trying to find [" + resource + "] using " + loader + " class loader.");
-                url = loader.getResource(resource);
-                if (url != null) {
-                    return url;
-                }
-            }
-        } catch (Throwable t) {
-            log.warn("Caught Exception while in Loader.getResource. This may be innocuous.", t);
-        }
-        return getResource(resource);
-    }
-
-    /**
-     * Get the Thread context class loader.
-     * <p/>
-     *
-     * @return
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     */
-    static public ClassLoader getTCL() throws IllegalAccessException, InvocationTargetException {
-        return Thread.currentThread().getContextClassLoader();
-    }
-
-    /**
-     * Try the specified classloader and then fall back to the loadClass
-     * <p/>
-     *
-     * @param loader
-     * @param clazz
-     * @return Class
-     * @throws ClassNotFoundException
-     */
-    static public Class loadClass(ClassLoader loader, String clazz) throws ClassNotFoundException {
-        try {
-            if(loader != null) {
-                Class c = loader.loadClass(clazz);
-                if (c != null)
-                    return c;
-            }
-        } catch (Throwable e) {
-        }
-        return loadClass(clazz);
-    }
-
-    /**
-     * If running under JDK 1.2 load the specified class using the
-     * <code>Thread</code> <code>contextClassLoader</code> if that
-     * fails try Class.forname.
-     * <p/>
-     *
-     * @param clazz
-     * @return TODO
-     * @throws ClassNotFoundException
-     */
-    static public Class loadClass(String clazz) throws ClassNotFoundException {
-        try {
-            ClassLoader tcl = getTCL();	
-            
-            if(tcl != null) {
-                Class c = tcl.loadClass(clazz);
-                if (c != null)
-                    return c;
-            }
-        } catch (Throwable e) {
-        }
-        // we reached here because tcl was null or because of a
-        // security exception, or because clazz could not be loaded...
-        // In any case we now try one more time
-        return Class.forName(clazz);
-    }
-}
+	/**
+	 * This method will search for <code>resource</code> in different places.
+	 * The rearch order is as follows:
+	 * <ol>
+	 * <p>
+	 * <li>Search for <code>resource</code> using the thread context class
+	 * loader under Java2. If that fails, search for <code>resource</code>
+	 * using the class loader that loaded this class (<code>Loader</code>).
+	 * <p>
+	 * <li>Try one last time with
+	 * <code>ClassLoader.getSystemResource(resource)</code>, that is is using
+	 * the system class loader in JDK 1.2 and virtual machine's built-in class
+	 * loader in JDK 1.1.
+	 * </ol>
+	 * <p/>
+	 * 
+	 * @param resource
+	 * @return TODO
+	 */
+	static public URL getResource(String resource) {
+		ClassLoader classLoader = null;
+		URL url = null;
+		try {
+			// We could not find resource. Ler us now try with the
+			// classloader that loaded this class.
+			classLoader = getTCL();
+			if (classLoader != null) {
+				log.debug("Trying to find [" + resource + "] using "
+						+ classLoader + " class loader.");
+				url = classLoader.getResource(resource);
+				if (url != null) {
+					return url;
+				}
+			}
+		} catch (Throwable t) {
+			log
+					.warn(
+							"Caught Exception while in Loader.getResource. This may be innocuous.",
+							t);
+		}
+
+		// Last ditch attempt: get the resource from the class path. It
+		// may be the case that clazz was loaded by the Extentsion class
+		// loader which the parent of the system class loader. Hence the
+		// code below.
+		log.debug("Trying to find [" + resource
+				+ "] using ClassLoader.getSystemResource().");
+		return ClassLoader.getSystemResource(resource);
+	}
+
+	/**
+	 * Try to get the resource with the specified class loader <p/>
+	 * 
+	 * @param loader
+	 *            The classloader to use
+	 * @param resource
+	 *            The resources' path
+	 * @return The URL of the resource
+	 * @throws ClassNotFoundException
+	 */
+	static public URL getResource(ClassLoader loader, String resource)
+			throws ClassNotFoundException {
+		URL url = null;
+		try {
+			if (loader != null) {
+				log.debug("Trying to find [" + resource + "] using " + loader
+						+ " class loader.");
+				url = loader.getResource(resource);
+				if (url != null) {
+					return url;
+				}
+			}
+		} catch (Throwable t) {
+			log
+					.warn(
+							"Caught Exception while in Loader.getResource. This may be innocuous.",
+							t);
+		}
+		return getResource(resource);
+	}
+
+	/**
+	 * Get the Thread context class loader. <p/>
+	 * 
+	 * @return
+	 * @throws IllegalAccessException
+	 * @throws InvocationTargetException
+	 */
+	static public ClassLoader getTCL() throws IllegalAccessException,
+			InvocationTargetException {
+		return Thread.currentThread().getContextClassLoader();
+	}
+
+	/**
+	 * Try the specified classloader and then fall back to the loadClass <p/>
+	 * 
+	 * @param loader
+	 * @param clazz
+	 * @return Class
+	 * @throws ClassNotFoundException
+	 */
+	static public Class loadClass(ClassLoader loader, String clazz)
+			throws ClassNotFoundException {
+		try {
+			if (loader != null) {
+				Class c = loader.loadClass(clazz);
+				if (c != null)
+					return c;
+			}
+		} catch (Throwable e) {
+		}
+		return loadClass(clazz);
+	}
+
+	/**
+	 * If running under JDK 1.2 load the specified class using the
+	 * <code>Thread</code> <code>contextClassLoader</code> if that fails try
+	 * Class.forname. <p/>
+	 * 
+	 * @param clazz
+	 * @return TODO
+	 * @throws ClassNotFoundException
+	 */
+	static public Class loadClass(String clazz) throws ClassNotFoundException {
+		try {
+			ClassLoader tcl = getTCL();
+
+			if (tcl != null) {
+				Class c = tcl.loadClass(clazz);
+				if (c != null)
+					return c;
+			}
+		} catch (Throwable e) {
+		}
+		// we reached here because tcl was null or because of a
+		// security exception, or because clazz could not be loaded...
+		// In any case we now try one more time
+		return Class.forName(clazz);
+	}
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/OMPolicyReader.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/OMPolicyReader.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/OMPolicyReader.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/OMPolicyReader.java Fri Mar  3 00:26:45 2006
@@ -40,150 +40,155 @@
 import org.apache.ws.policy.XorCompositeAssertion;
 
 /**
+ * OMPolicyReader implements PolicyReader interface and provides different
+ * methods to create a policy object It ueses AxisOM as its underlying mechanism
+ * to process XML.
+ * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public class OMPolicyReader implements PolicyReader {
-    OMPolicyReader() {
-    }
+	OMPolicyReader() {
+	}
 
-    public Policy readPolicy(InputStream in) {
-        try {
-            XMLStreamReader reader = XMLInputFactory.newInstance()
-                    .createXMLStreamReader(in);
-            OMXMLParserWrapper builder = OMXMLBuilderFactory
-                    .createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
-                            reader);
-
-            OMElement element = builder.getDocumentElement();
-            return readPolicy(element);
-
-        } catch (XMLStreamException ex) {
-            throw new RuntimeException("error : " + ex.getMessage());
-        }
-    }
-
-    private Assertion readAssertion(OMElement element) {
-        String namespace = element.getNamespace().getName();
-        String localName = element.getLocalName();
-
-        if (!(namespace.equals(PolicyConstants.WS_POLICY_NAMESPACE_URI))) {
-            return readPrimitiveAssertion(element);
-        }
-
-        if (localName.equals(PolicyConstants.WS_POLICY)) {
-            return readPolicy(element);
-
-        } else if (localName.equals(PolicyConstants.AND_COMPOSITE_ASSERTION)) {
-            return readAndComposite(element);
-
-        } else if (localName.equals(PolicyConstants.XOR_COMPOSITE_ASSERTION)) {
-            return readXorComposite(element);
-
-        } else if (localName.equals(PolicyConstants.WS_POLICY_REFERENCE)) {
-            return readPolicyReference(element);
-
-        } else {
-            throw new RuntimeException("unknown element ..");
-        }
-    }
-
-    public Policy readPolicy(OMElement element) {
-        Policy policy = new Policy();
-
-        OMAttribute attri;
-        attri = element.getAttribute(new QName(
-                PolicyConstants.WSU_NAMESPACE_URI, "Id"));
-        if (attri != null) {
-            policy.setId(attri.getAttributeValue());
-        }
-        attri = element.getAttribute(new QName(PolicyConstants.XML_NAMESPACE_URI, "base"));
-        if (attri != null) {
-            policy.setBase(attri.getAttributeValue());
-        }
-
-        policy.addTerms(readTerms(element));
-        return policy;
-    }
-
-    private AndCompositeAssertion readAndComposite(OMElement element) {
-        AndCompositeAssertion andCompositeAssertion = new AndCompositeAssertion();
-        andCompositeAssertion.addTerms(readTerms(element));
-        return andCompositeAssertion;
-    }
-
-    private XorCompositeAssertion readXorComposite(OMElement element) {
-        XorCompositeAssertion xorCompositeAssertion = new XorCompositeAssertion();
-        xorCompositeAssertion.addTerms(readTerms(element));
-        return xorCompositeAssertion;
-    }
-
-    public PolicyReference readPolicyReference(OMElement element) {
-        OMAttribute attribute = element.getAttribute(new QName("URI"));
-        return new PolicyReference(attribute.getAttributeValue());
-    }
-
-    private PrimitiveAssertion readPrimitiveAssertion(OMElement element) {
-        QName qname = element.getQName();
-        PrimitiveAssertion result = new PrimitiveAssertion(qname);
-
-        result.setAttributes(getAttributes(element));
-
-        String isOptional = result.getAttribute(new QName(
-                PolicyConstants.WS_POLICY_NAMESPACE_URI, "Optional"));
-        result.setOptional(new Boolean(isOptional).booleanValue());
-
-        // setting the text value ..
-        String strValue = element.getText();
-
-        if (strValue != null && strValue.length() != 0) {
-            result.setStrValue(strValue.trim());
-        }
-
-        //CHECK ME
-        Iterator childElements = element.getChildElements();
-
-        while (childElements.hasNext()) {
-            OMElement childElement = (OMElement) childElements.next();
-
-            if (childElement.getNamespace().getName().equals(
-                    PolicyConstants.WS_POLICY_NAMESPACE_URI)
-                    && childElement.getLocalName().equals(
-                            PolicyConstants.WS_POLICY)) {
-                Policy policy = readPolicy(childElement);
-                result.addTerm(policy);
-
-            } else {
-                PrimitiveAssertion pa = readPrimitiveAssertion(childElement);
-                result.addTerm(pa);
-            }
-        }
-        return result;
-    }
-
-    private ArrayList readTerms(OMElement element) {
-        ArrayList terms = new ArrayList();
-        Iterator childElements = element.getChildren();
-
-        while (childElements.hasNext()) {
-            Object obj = childElements.next();
-
-            if (obj instanceof OMElement) {
-                OMElement e = (OMElement) obj;
-                terms.add(readAssertion(e));
-            }
-        }
-        return terms;
-    }
-
-    private Hashtable getAttributes(OMElement element) {
-        Hashtable attributes = new Hashtable();
-        Iterator iterator = element.getAllAttributes();
-
-        while (iterator.hasNext()) {
-            OMAttribute attribute = (OMAttribute) iterator.next();
-            attributes.put(attribute.getQName(), attribute.getAttributeValue());
-        }
+	public Policy readPolicy(InputStream in) {
+		try {
+			XMLStreamReader reader = XMLInputFactory.newInstance()
+					.createXMLStreamReader(in);
+			OMXMLParserWrapper builder = OMXMLBuilderFactory
+					.createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
+							reader);
+
+			OMElement element = builder.getDocumentElement();
+			return readPolicy(element);
+
+		} catch (XMLStreamException ex) {
+			throw new RuntimeException("error : " + ex.getMessage());
+		}
+	}
+
+	private Assertion readAssertion(OMElement element) {
+		String namespace = element.getNamespace().getName();
+		String localName = element.getLocalName();
+
+		if (!(namespace.equals(PolicyConstants.WS_POLICY_NAMESPACE_URI))) {
+			return readPrimitiveAssertion(element);
+		}
+
+		if (localName.equals(PolicyConstants.WS_POLICY)) {
+			return readPolicy(element);
+
+		} else if (localName.equals(PolicyConstants.AND_COMPOSITE_ASSERTION)) {
+			return readAndComposite(element);
+
+		} else if (localName.equals(PolicyConstants.XOR_COMPOSITE_ASSERTION)) {
+			return readXorComposite(element);
+
+		} else if (localName.equals(PolicyConstants.WS_POLICY_REFERENCE)) {
+			return readPolicyReference(element);
+
+		} else {
+			throw new RuntimeException("unknown element ..");
+		}
+	}
+
+	public Policy readPolicy(OMElement element) {
+		Policy policy = new Policy();
+
+		OMAttribute attri;
+		attri = element.getAttribute(new QName(
+				PolicyConstants.WSU_NAMESPACE_URI, "Id"));
+		if (attri != null) {
+			policy.setId(attri.getAttributeValue());
+		}
+		attri = element.getAttribute(new QName(
+				PolicyConstants.XML_NAMESPACE_URI, "base"));
+		if (attri != null) {
+			policy.setBase(attri.getAttributeValue());
+		}
+
+		policy.addTerms(readTerms(element));
+		return policy;
+	}
+
+	private AndCompositeAssertion readAndComposite(OMElement element) {
+		AndCompositeAssertion andCompositeAssertion = new AndCompositeAssertion();
+		andCompositeAssertion.addTerms(readTerms(element));
+		return andCompositeAssertion;
+	}
+
+	private XorCompositeAssertion readXorComposite(OMElement element) {
+		XorCompositeAssertion xorCompositeAssertion = new XorCompositeAssertion();
+		xorCompositeAssertion.addTerms(readTerms(element));
+		return xorCompositeAssertion;
+	}
+
+	public PolicyReference readPolicyReference(OMElement element) {
+		OMAttribute attribute = element.getAttribute(new QName("URI"));
+		return new PolicyReference(attribute.getAttributeValue());
+	}
+
+	private PrimitiveAssertion readPrimitiveAssertion(OMElement element) {
+		QName qname = element.getQName();
+		PrimitiveAssertion result = new PrimitiveAssertion(qname);
+
+		result.setAttributes(getAttributes(element));
+
+		String isOptional = result.getAttribute(new QName(
+				PolicyConstants.WS_POLICY_NAMESPACE_URI, "Optional"));
+		result.setOptional(new Boolean(isOptional).booleanValue());
+
+		// setting the text value ..
+		String strValue = element.getText();
+
+		if (strValue != null && strValue.length() != 0) {
+			result.setStrValue(strValue.trim());
+		}
+
+		//CHECK ME
+		Iterator childElements = element.getChildElements();
+
+		while (childElements.hasNext()) {
+			OMElement childElement = (OMElement) childElements.next();
+
+			if (childElement.getNamespace().getName().equals(
+					PolicyConstants.WS_POLICY_NAMESPACE_URI)
+					&& childElement.getLocalName().equals(
+							PolicyConstants.WS_POLICY)) {
+				Policy policy = readPolicy(childElement);
+				result.addTerm(policy);
+
+			} else {
+				PrimitiveAssertion pa = readPrimitiveAssertion(childElement);
+				result.addTerm(pa);
+			}
+		}
+		return result;
+	}
+
+	private ArrayList readTerms(OMElement element) {
+		ArrayList terms = new ArrayList();
+		Iterator childElements = element.getChildren();
+
+		while (childElements.hasNext()) {
+			Object obj = childElements.next();
+
+			if (obj instanceof OMElement) {
+				OMElement e = (OMElement) obj;
+				terms.add(readAssertion(e));
+			}
+		}
+		return terms;
+	}
+
+	private Hashtable getAttributes(OMElement element) {
+		Hashtable attributes = new Hashtable();
+		Iterator iterator = element.getAllAttributes();
+
+		while (iterator.hasNext()) {
+			OMAttribute attribute = (OMAttribute) iterator.next();
+			attributes.put(attribute.getQName(), attribute.getAttributeValue());
+		}
 
-        return attributes;
-    }
+		return attributes;
+	}
 }

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java Fri Mar  3 00:26:45 2006
@@ -17,75 +17,86 @@
 package org.apache.ws.policy.util;
 
 /**
- * PolicyFactory is used to create PolicyReader / PolicyWriter objects of different types.
- *  
+ * PolicyFactory is used to create PolicyReader / PolicyWriter objects of
+ * different types.
+ * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public class PolicyFactory {
-    public static final int OM_POLICY_READER = 1;
-    public static final int StAX_POLICY_WRITER = 2;
-    
-    public static final int DOM_POLICY_READER = 3;
-    
-    /**
-     * Creates a specified type of PolicyReader object
-     * 
-     * DOM_POLICY_READER : Uses DOM as its underlying mechanism to process XML.
-     * 
-     * OM_POLICY_READER : Uses AXIOM as its underlying mechanism to process XML.
-     * 
-     * @param type of the PolicyReader to create
-     * @return an instance of a PolicyReader 
-     */
-    public static PolicyReader getPolicyReader(int type) {
-    	String name = null;
-        switch (type) {
-        case DOM_POLICY_READER:
-        	name = "org.apache.ws.policy.util.DOMPolicyReader";
-        	break;
-        case OM_POLICY_READER:
-        	name = "org.apache.ws.policy.util.OMPolicyReader";
-        	break;
-        default: 
-            throw new IllegalArgumentException("Unknown PolicyReader type ..");
-        }
-        try {
-			return (PolicyReader)Loader.loadClass(name).newInstance();
+	public static final int OM_POLICY_READER = 1;
+
+	public static final int StAX_POLICY_WRITER = 2;
+
+	public static final int DOM_POLICY_READER = 3;
+
+	/**
+	 * Creates a specified type of PolicyReader object
+	 * 
+	 * DOM_POLICY_READER : Uses DOM as its underlying mechanism to process XML.
+	 * 
+	 * OM_POLICY_READER : Uses AXIOM as its underlying mechanism to process XML.
+	 * 
+	 * @param type
+	 *            of the PolicyReader to create
+	 * @return an instance of a PolicyReader
+	 */
+	public static PolicyReader getPolicyReader(int type) {
+		String name = null;
+		switch (type) {
+		case DOM_POLICY_READER:
+			name = "org.apache.ws.policy.util.DOMPolicyReader";
+			break;
+		case OM_POLICY_READER:
+			name = "org.apache.ws.policy.util.OMPolicyReader";
+			break;
+		default:
+			throw new IllegalArgumentException("Unknown PolicyReader type ..");
+		}
+		try {
+			return (PolicyReader) Loader.loadClass(name).newInstance();
 		} catch (InstantiationException e) {
-            throw new IllegalArgumentException("Cannot load PolicyReader type ..");
+			throw new IllegalArgumentException(
+					"Cannot load PolicyReader type ..");
 		} catch (IllegalAccessException e) {
-            throw new IllegalArgumentException("Cannot load PolicyReader type ..");
+			throw new IllegalArgumentException(
+					"Cannot load PolicyReader type ..");
 		} catch (ClassNotFoundException e) {
-            throw new IllegalArgumentException("Cannot load PolicyReader type ..");
+			throw new IllegalArgumentException(
+					"Cannot load PolicyReader type ..");
+		}
+	}
+
+	/**
+	 * Create a specified type of PolicyWriter object
+	 * 
+	 * STAX_POLICY_WRITER: Uses StAX as its underlying mechanism to create XML
+	 * elements.
+	 * 
+	 * @param type
+	 *            of the RolicyWriter to create
+	 * @return an instance of PolicyWriter
+	 */
+	public static PolicyWriter getPolicyWriter(int type) {
+		String name = null;
+		switch (type) {
+		case StAX_POLICY_WRITER:
+			name = "org.apache.ws.policy.util.StAXPolicyWriter";
+			break;
+		default:
+			throw new IllegalArgumentException("Unknown PolicyWriter type ..");
 		}
-    }
-    
-    /**
-     * Create a specified type of PolicyWriter object
-     * 
-     * STAX_POLICY_WRITER: Uses StAX as its underlying mechanism to create XML elements.
-     * 
-     * @param type of the RolicyWriter to create
-     * @return an instance of PolicyWriter
-     */
-    public static PolicyWriter getPolicyWriter(int type) {
-    	String name = null;
-        switch (type) {
-        case StAX_POLICY_WRITER:
-        	name = "org.apache.ws.policy.util.StAXPolicyWriter";
-        	break;
-        default: 
-            throw new IllegalArgumentException("Unknown PolicyWriter type ..");
-        }
-        try {
-			return (PolicyWriter)Loader.loadClass(name).newInstance();
+		try {
+			return (PolicyWriter) Loader.loadClass(name).newInstance();
 		} catch (InstantiationException e) {
-            throw new IllegalArgumentException("Cannot load PolicyWriter type ..");
+			throw new IllegalArgumentException(
+					"Cannot load PolicyWriter type ..");
 		} catch (IllegalAccessException e) {
-            throw new IllegalArgumentException("Cannot load PolicyWriter type ..");
+			throw new IllegalArgumentException(
+					"Cannot load PolicyWriter type ..");
 		} catch (ClassNotFoundException e) {
-            throw new IllegalArgumentException("Cannot load PolicyWriter type ..");
+			throw new IllegalArgumentException(
+					"Cannot load PolicyWriter type ..");
 		}
-    }
-    
-}
+	}
+
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyReader.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyReader.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyReader.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyReader.java Fri Mar  3 00:26:45 2006
@@ -21,8 +21,21 @@
 import org.apache.ws.policy.Policy;
 
 /**
+ * PolicyReader is an interface which every PolicyReader must implement. It
+ * contains a single method to create a Policy object from an InputStream.
+ * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public interface PolicyReader {
-    public Policy readPolicy(InputStream inputStream) throws RuntimeException;
-}
+
+	/**
+	 * Creates a Policy object from an InputStream.
+	 * 
+	 * @param inputStream
+	 *            the inputStream of the source file
+	 * @return a policy object constructed from the InputStream
+	 * @throws RuntimeException
+	 *             if an error occurs while constructing the Policy object
+	 */
+	public Policy readPolicy(InputStream inputStream) throws RuntimeException;
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyRegistry.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyRegistry.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyRegistry.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyRegistry.java Fri Mar  3 00:26:45 2006
@@ -22,58 +22,82 @@
 import org.apache.ws.policy.Policy;
 
 /**
- * PolicyRegistry is contains reference to external policy that are used by the
- * policy model to resolve policy reference objects to their actual policies.
- * 
+ * PolicyRegistry is useful to resolve any PolicyReferences to actual policies.
+ * It can optionally be passed as an argument to policy operations (i.e.
+ * normalize(...), merge(...) and intersect(...)) and any PolicyReference is
+ * resovled to actually Policy within that operations.
  */
 public class PolicyRegistry {
-    HashMap     reg    = new HashMap ();
-    PolicyRegistry parent = null;
-    
-    public PolicyRegistry () {
-    }
-    
-    public PolicyRegistry (PolicyRegistry parent) {
-        this.parent = parent;
-    }
-    
-    public void setParent(PolicyRegistry parent) {
-        this.parent = parent;
-    }
-    
-    public PolicyRegistry getParent() {
-        return parent;        
-    }
-    
-    public Policy lookup (String policyURI) throws IllegalArgumentException {
-        
-        Policy policy =  (Policy) reg.get (policyURI);
-
-        if (policy == null && parent != null) {
-          policy = parent.lookup (policyURI);
-        }
-
-//      if (policy == null) {
-//        throw new IllegalArgumentException ("policy '" + policyURI + "' not in registry");
-//      }
-
-        return policy;
-      }
-      // register a policy
-      public void register (String policyURI, Policy policy) {
-        reg.put (policyURI, policy);
-      }
-      
-      // unregister a policy
-      public void unregister (String policyURI) {
-        reg.remove (policyURI);
-      }
-      
-      public Iterator keys() {
-        return reg.keySet().iterator();
-      }
-      
-      public Iterator values() {
-        return reg.values().iterator();
-      }       
-}
+	/** Stores {PolicyURI, Polcy} pairs */
+	HashMap reg = new HashMap();
+
+	/** To refer to the parent registry */
+	PolicyRegistry parent = null;
+
+	public PolicyRegistry() {
+	}
+
+	public PolicyRegistry(PolicyRegistry parent) {
+		this.parent = parent;
+	}
+
+	public void setParent(PolicyRegistry parent) {
+		this.parent = parent;
+	}
+
+	public PolicyRegistry getParent() {
+		return parent;
+	}
+
+	/**
+	 * Returns the Policy object which is uniquely identified by the policyURI
+	 * String. Returns null if there is no Policy object with the specified
+	 * policyURI. The policyURI should be the same as the String which returns
+	 * when getPolicyURI() is invoked on returning Policy object.
+	 * 
+	 * @param policyURI
+	 *            a String which uniquely indentifies the Policy
+	 * @return a Policy object which has the same policyURI
+	 * @throws IllegalArgumentException
+	 */
+	public Policy lookup(String policyURI) throws IllegalArgumentException {
+
+		Policy policy = (Policy) reg.get(policyURI);
+
+		if (policy == null && parent != null) {
+			policy = parent.lookup(policyURI);
+		}
+
+		return policy;
+	}
+
+	/**
+	 * Registers a Policy object with the specified policyURI.
+	 * 
+	 * @param policyURI
+	 *            the key which should be the policyURI of the Policy object
+	 * @param policy
+	 *            the Policy object to register
+	 */
+	public void register(String policyURI, Policy policy) {
+		reg.put(policyURI, policy);
+	}
+
+	/**
+	 * Unregisters a Policy object specified by the policyURI.
+	 * 
+	 * @param policyURI
+	 *            the policyURI of the Policy object to unregister
+	 */
+	public void unregister(String policyURI) {
+		reg.remove(policyURI);
+	}
+
+	public Iterator keys() {
+		return reg.keySet().iterator();
+	}
+
+	public Iterator values() {
+		return reg.values().iterator();
+	}
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyUtil.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyUtil.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyUtil.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyUtil.java Fri Mar  3 00:26:45 2006
@@ -32,83 +32,82 @@
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public class PolicyUtil {
-    
-    public static boolean matchByQName(PrimitiveAssertion primTermA, 
-            PrimitiveAssertion primTermB) {
-        return primTermA.getName().equals(primTermB.getName());
-    }
-    
-    public static boolean matchByQName(List primTermsA,List primTermsB) {
-        List larger = (primTermsA.size() > primTermsB.size()) 
-                ? primTermsA :primTermsB;
-        List smaller = (primTermsA.size() < primTermsB.size()) 
-                ? primTermsA : primTermsB;
-    
-        Iterator iterator = larger.iterator();
-        PrimitiveAssertion primTerm;
-        QName qname;
-        Iterator iterator2;
-        while (iterator.hasNext()) {
-            primTerm = (PrimitiveAssertion) iterator.next();
-            qname = primTerm.getName();
-            iterator2 = smaller.iterator();
-            
-            boolean match = false;
-            PrimitiveAssertion primTerm2;
-            while (iterator2.hasNext()) {
-                primTerm2 = (PrimitiveAssertion) iterator2.next();
-                if (primTerm2.getName().equals(qname)) {
-                    match = true;
-                    break;
-                }
-            }
-            if (!match) {
-                return false;
-            }
-        }
-        return true;
-    }
-    
-    
-    public static List getPrimTermsList(Policy policy) {
-        if (!policy.isNormalized()) {
-            policy = (Policy) policy.normalize();
-        }
-        
-        XorCompositeAssertion xorTerm 
-            = (XorCompositeAssertion) policy.getTerms().get(0);
-        AndCompositeAssertion andTerm 
-            = (AndCompositeAssertion) xorTerm.getTerms().get(0);
-        
-        return andTerm.getTerms();
-    }
-    
-    public static Policy getSinglePolicy(List policyList, PolicyRegistry reg) {
-        Policy policyTerm = null;
-        Iterator iterator = policyList.iterator();
-        
-        Policy policyTerm2;
-        while (iterator.hasNext()) {
-            policyTerm2 = (Policy) iterator.next();
-            policyTerm = (policyTerm == null) 
-                    ? policyTerm2 : (Policy) policyTerm.merge(policyTerm2, reg);
-        }
-        
-        if (!policyTerm.isNormalized()) {
-            policyTerm = (Policy) policyTerm.normalize();
-        }
-        return policyTerm;
-    }
-    
-    public static Policy getPolicy(List terms) {
-        Policy policyTerm = new Policy();
-        XorCompositeAssertion xorTerm = new XorCompositeAssertion();
-        AndCompositeAssertion andTerm = new AndCompositeAssertion();
-        
-        andTerm.addTerms(terms);
-        xorTerm.addTerm(andTerm);
-        policyTerm.addTerm(xorTerm);
-        
-        return policyTerm;
-    }
-}
+
+	public static boolean matchByQName(PrimitiveAssertion primTermA,
+			PrimitiveAssertion primTermB) {
+		return primTermA.getName().equals(primTermB.getName());
+	}
+
+	public static boolean matchByQName(List primTermsA, List primTermsB) {
+		List larger = (primTermsA.size() > primTermsB.size()) ? primTermsA
+				: primTermsB;
+		List smaller = (primTermsA.size() < primTermsB.size()) ? primTermsA
+				: primTermsB;
+
+		Iterator iterator = larger.iterator();
+		PrimitiveAssertion primTerm;
+		QName qname;
+		Iterator iterator2;
+		while (iterator.hasNext()) {
+			primTerm = (PrimitiveAssertion) iterator.next();
+			qname = primTerm.getName();
+			iterator2 = smaller.iterator();
+
+			boolean match = false;
+			PrimitiveAssertion primTerm2;
+			while (iterator2.hasNext()) {
+				primTerm2 = (PrimitiveAssertion) iterator2.next();
+				if (primTerm2.getName().equals(qname)) {
+					match = true;
+					break;
+				}
+			}
+			if (!match) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	public static List getPrimTermsList(Policy policy) {
+		if (!policy.isNormalized()) {
+			policy = (Policy) policy.normalize();
+		}
+
+		XorCompositeAssertion xorTerm = (XorCompositeAssertion) policy
+				.getTerms().get(0);
+		AndCompositeAssertion andTerm = (AndCompositeAssertion) xorTerm
+				.getTerms().get(0);
+
+		return andTerm.getTerms();
+	}
+
+	public static Policy getSinglePolicy(List policyList, PolicyRegistry reg) {
+		Policy policyTerm = null;
+		Iterator iterator = policyList.iterator();
+
+		Policy policyTerm2;
+		while (iterator.hasNext()) {
+			policyTerm2 = (Policy) iterator.next();
+			policyTerm = (policyTerm == null) ? policyTerm2
+					: (Policy) policyTerm.merge(policyTerm2, reg);
+		}
+
+		if (!policyTerm.isNormalized()) {
+			policyTerm = (Policy) policyTerm.normalize();
+		}
+		return policyTerm;
+	}
+
+	public static Policy getPolicy(List terms) {
+		Policy policyTerm = new Policy();
+		XorCompositeAssertion xorTerm = new XorCompositeAssertion();
+		AndCompositeAssertion andTerm = new AndCompositeAssertion();
+
+		andTerm.addTerms(terms);
+		xorTerm.addTerm(andTerm);
+		policyTerm.addTerm(xorTerm);
+
+		return policyTerm;
+	}
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyWriter.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyWriter.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyWriter.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyWriter.java Fri Mar  3 00:26:45 2006
@@ -21,8 +21,20 @@
 import org.apache.ws.policy.Policy;
 
 /**
+ * PolicyWriter is an interface which all PolicyWriters must implement. It
+ * defines a single method which writes a policy to an OutputStream.
+ * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public interface PolicyWriter {
-    public void writePolicy(Policy policy, OutputStream outputStream);
-}
+
+	/**
+	 * Writes a Policy object to an OutputStream.
+	 * 
+	 * @param policy
+	 *            the Policy object to write
+	 * @param outputStream
+	 *            the OutputStream to which the Policy obect should be written
+	 */
+	public void writePolicy(Policy policy, OutputStream outputStream);
+}
\ No newline at end of file

Modified: webservices/commons/modules/policy/src/org/apache/ws/policy/util/SchemaRegistry.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/SchemaRegistry.java?rev=382719&r1=382718&r2=382719&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/util/SchemaRegistry.java (original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/util/SchemaRegistry.java Fri Mar  3 00:26:45 2006
@@ -21,20 +21,45 @@
 import java.util.HashMap;
 
 /**
+ * SchemaRegistry holds schemas associated with URIs.
+ * 
  * @author Sanka Samaranayake (sanka@apache.org)
  */
 public class SchemaRegistry {
-    private HashMap reg = new HashMap();
-    
-    public Element lookup(String uri) {
-        return (Element) reg.get(uri);
-    }
-    
-    public void register(String uri, Element schemaElement) {
-        reg.put(uri, schemaElement);
-    }
-    
-    public void unregister(String uri) {
-        reg.remove(uri);        
-    }
-}
+
+	/** Stores {URI, schema element} pairs */
+	private HashMap reg = new HashMap();
+
+	/**
+	 * Returns the schema element associated with uri String
+	 * 
+	 * @param uri
+	 *            the URI which uniquely identify the schema element
+	 * @return the schema element which is associated with the uri.
+	 */
+	public Element lookup(String uri) {
+		return (Element) reg.get(uri);
+	}
+
+	/**
+	 * Registers a schema element with a uri.
+	 * 
+	 * @param uri
+	 *            the key for the element
+	 * @param schemaElement
+	 *            the schema element to associate with the uri
+	 */
+	public void register(String uri, Element schemaElement) {
+		reg.put(uri, schemaElement);
+	}
+
+	/**
+	 * Unregisters the schema element associated with the specified uri.
+	 * 
+	 * @param uri
+	 *            the uri of the schema element
+	 */
+	public void unregister(String uri) {
+		reg.remove(uri);
+	}
+}
\ No newline at end of file