KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

7 package javax.xml.crypto.dsig.spec;
8
9 import javax.xml.crypto.dsig.CanonicalizationMethod;
10 import java.util.ArrayList JavaDoc;
11 import java.util.Collections JavaDoc;
12 import java.util.List JavaDoc;
13
14 /**
15  * Parameters for the W3C Recommendation:
16  * <a HREF="http://www.w3.org/TR/xml-exc-c14n/">
17  * Exclusive XML Canonicalization (C14N) algorithm</a>. The
18  * parameters include an optional inclusive namespace prefix list. The XML
19  * Schema Definition of the Exclusive XML Canonicalization parameters is
20  * defined as:
21  * <pre><code>
22  * &lt;schema xmlns="http://www.w3.org/2001/XMLSchema"
23  * xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"
24  * targetNamespace="http://www.w3.org/2001/10/xml-exc-c14n#"
25  * version="0.1" elementFormDefault="qualified"&gt;
26  *
27  * &lt;element name="InclusiveNamespaces" type="ec:InclusiveNamespaces"/&gt;
28  * &lt;complexType name="InclusiveNamespaces"&gt;
29  * &lt;attribute name="PrefixList" type="xsd:string"/&gt;
30  * &lt;/complexType&gt;
31  * &lt;/schema&gt;
32  * </code></pre>
33  *
34  * @author Sean Mullan
35  * @author JSR 105 Expert Group
36  * @since 1.6
37  * @see CanonicalizationMethod
38  */

39 public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
40
41     private List JavaDoc preList;
42
43     /**
44      * Indicates the default namespace ("#default").
45      */

46     public static final String JavaDoc DEFAULT = "#default";
47
48     /**
49      * Creates a <code>ExcC14NParameterSpec</code> with an empty prefix
50      * list.
51      */

52     public ExcC14NParameterSpec() {
53     preList = Collections.EMPTY_LIST;
54     }
55
56     /**
57      * Creates a <code>ExcC14NParameterSpec</code> with the specified list
58      * of prefixes. The list is copied to protect against subsequent
59      * modification.
60      *
61      * @param prefixList the inclusive namespace prefix list. Each entry in
62      * the list is a <code>String</code> that represents a namespace prefix.
63      * @throws NullPointerException if <code>prefixList</code> is
64      * <code>null</code>
65      * @throws ClassCastException if any of the entries in the list are not
66      * of type <code>String</code>
67      */

68     public ExcC14NParameterSpec(List JavaDoc prefixList) {
69     if (prefixList == null) {
70         throw new NullPointerException JavaDoc("prefixList cannot be null");
71     }
72     this.preList = new ArrayList JavaDoc(prefixList);
73     for (int i = 0, size = preList.size(); i < size; i++) {
74         if (!(preList.get(i) instanceof String JavaDoc)) {
75         throw new ClassCastException JavaDoc("not a String");
76         }
77     }
78     preList = Collections.unmodifiableList(preList);
79     }
80
81     /**
82      * Returns the inclusive namespace prefix list. Each entry in the list
83      * is a <code>String</code> that represents a namespace prefix.
84      *
85      * <p>This implementation returns an {@link
86      * java.util.Collections#unmodifiableList unmodifiable list}.
87      *
88      * @return the inclusive namespace prefix list (may be empty but never
89      * <code>null</code>)
90      */

91     public List JavaDoc getPrefixList() {
92     return preList;
93     }
94 }
95
Popular Tags