J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | /* |
| 26 | * $Id: XPathFilter2ParameterSpec.java,v 1.7 2005/05/13 18:45:42 mullan Exp $ |
| 27 | */ |
| 28 | package javax.xml.crypto.dsig.spec; |
| 29 | |
| 30 | import java.util.ArrayList; |
| 31 | import java.util.Collections; |
| 32 | import java.util.List; |
| 33 | import javax.xml.crypto.dsig.Transform; |
| 34 | |
| 35 | /** |
| 36 | * Parameters for the W3C Recommendation |
| 37 | * <a href="http://www.w3.org/TR/xmldsig-filter2/"> |
| 38 | * XPath Filter 2.0 Transform Algorithm</a>. |
| 39 | * The parameters include a list of one or more {@link XPathType} objects. |
| 40 | * |
| 41 | * @author Sean Mullan |
| 42 | * @author JSR 105 Expert Group |
| 43 | * @since 1.6 |
| 44 | * @see Transform |
| 45 | * @see XPathFilterParameterSpec |
| 46 | */ |
| 47 | public final class XPathFilter2ParameterSpec implements TransformParameterSpec { |
| 48 | |
| 49 | private final List xPathList; |
| 50 | |
| 51 | /** |
| 52 | * Creates an <code>XPathFilter2ParameterSpec</code>. |
| 53 | * |
| 54 | * @param xPathList a list of one or more {@link XPathType} objects. The |
| 55 | * list is defensively copied to protect against subsequent modification. |
| 56 | * @throws ClassCastException if <code>xPathList</code> contains any |
| 57 | * entries that are not of type {@link XPathType} |
| 58 | * @throws IllegalArgumentException if <code>xPathList</code> is empty |
| 59 | * @throws NullPointerException if <code>xPathList</code> is |
| 60 | * <code>null</code> |
| 61 | */ |
| 62 | public XPathFilter2ParameterSpec(List xPathList) { |
| 63 | if (xPathList == null) { |
| 64 | throw new NullPointerException("xPathList cannot be null"); |
| 65 | } |
| 66 | List xPathListCopy = new ArrayList(xPathList); |
| 67 | if (xPathListCopy.isEmpty()) { |
| 68 | throw new IllegalArgumentException("xPathList cannot be empty"); |
| 69 | } |
| 70 | int size = xPathListCopy.size(); |
| 71 | for (int i = 0; i < size; i++) { |
| 72 | if (!(xPathListCopy.get(i) instanceof XPathType)) { |
| 73 | throw new ClassCastException |
| 74 | ("xPathList["+i+"] is not a valid type"); |
| 75 | } |
| 76 | } |
| 77 | this.xPathList = Collections.unmodifiableList(xPathListCopy); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Returns a list of one or more {@link XPathType} objects. |
| 82 | * <p> |
| 83 | * This implementation returns an {@link Collections#unmodifiableList |
| 84 | * unmodifiable list}. |
| 85 | * |
| 86 | * @return a <code>List</code> of <code>XPathType</code> objects |
| 87 | * (never <code>null</code> or empty) |
| 88 | */ |
| 89 | public List getXPathList() { |
| 90 | return xPathList; |
| 91 | } |
| 92 | } |