KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > crypto > dsig > spec > XPathFilter2ParameterSpec


1 /*
2  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3  */

4 /*
5  * $Id: XPathFilter2ParameterSpec.java,v 1.7 2005/05/13 18:45:42 mullan Exp $
6  */

7 package javax.xml.crypto.dsig.spec;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Collections JavaDoc;
11 import java.util.List JavaDoc;
12 import javax.xml.crypto.dsig.Transform;
13
14 /**
15  * Parameters for the W3C Recommendation
16  * <a HREF="http://www.w3.org/TR/xmldsig-filter2/">
17  * XPath Filter 2.0 Transform Algorithm</a>.
18  * The parameters include a list of one or more {@link XPathType} objects.
19  *
20  * @author Sean Mullan
21  * @author JSR 105 Expert Group
22  * @since 1.6
23  * @see Transform
24  * @see XPathFilterParameterSpec
25  */

26 public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
27
28     private final List JavaDoc xPathList;
29
30     /**
31      * Creates an <code>XPathFilter2ParameterSpec</code>.
32      *
33      * @param xPathList a list of one or more {@link XPathType} objects. The
34      * list is defensively copied to protect against subsequent modification.
35      * @throws ClassCastException if <code>xPathList</code> contains any
36      * entries that are not of type {@link XPathType}
37      * @throws IllegalArgumentException if <code>xPathList</code> is empty
38      * @throws NullPointerException if <code>xPathList</code> is
39      * <code>null</code>
40      */

41     public XPathFilter2ParameterSpec(List JavaDoc xPathList) {
42     if (xPathList == null) {
43         throw new NullPointerException JavaDoc("xPathList cannot be null");
44     }
45         List JavaDoc xPathListCopy = new ArrayList JavaDoc(xPathList);
46     if (xPathListCopy.isEmpty()) {
47         throw new IllegalArgumentException JavaDoc("xPathList cannot be empty");
48     }
49     int size = xPathListCopy.size();
50         for (int i = 0; i < size; i++) {
51             if (!(xPathListCopy.get(i) instanceof XPathType)) {
52                 throw new ClassCastException JavaDoc
53                     ("xPathList["+i+"] is not a valid type");
54             }
55         }
56     this.xPathList = Collections.unmodifiableList(xPathListCopy);
57     }
58
59     /**
60      * Returns a list of one or more {@link XPathType} objects.
61      * <p>
62      * This implementation returns an {@link Collections#unmodifiableList
63      * unmodifiable list}.
64      *
65      * @return a <code>List</code> of <code>XPathType</code> objects
66      * (never <code>null</code> or empty)
67      */

68     public List JavaDoc getXPathList() {
69     return xPathList;
70     }
71 }
72
Popular Tags