View Javadoc

1   /*
2    * Copyright [2006] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.opensaml.xml.encryption.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import javax.xml.namespace.QName;
24  
25  import org.opensaml.xml.XMLObject;
26  import org.opensaml.xml.util.AttributeMap;
27  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
28  import org.opensaml.xml.util.XMLObjectChildrenList;
29  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
30  
31  /**
32   * Concrete implementation of {@link org.opensaml.xml.encryption.EncryptionProperty}
33   */
34  public class EncryptionPropertyImpl extends AbstractValidatingXMLObject implements
35          org.opensaml.xml.encryption.EncryptionProperty {
36      
37      /** Target attribute value */
38      private String target;
39      
40      /** Id attribute value */
41      private String id;
42      
43      /** Child elements from the <any> content model */
44      private final IndexedXMLObjectChildrenList unknownChildren;
45      
46      /** "anyAttribute" attributes */
47      private final AttributeMap unknownAttributes;
48  
49      /**
50       * Constructor
51       *
52       * @param namespaceURI
53       * @param elementLocalName
54       * @param namespacePrefix
55       */
56      protected EncryptionPropertyImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
57          super(namespaceURI, elementLocalName, namespacePrefix);
58          unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this);
59          unknownAttributes =  new AttributeMap(this);
60      }
61  
62      /** {@inheritDoc} */
63      public String getTarget() {
64          return this.target;
65      }
66  
67      /** {@inheritDoc} */
68      public void setTarget(String newTarget) {
69          this.target = prepareForAssignment(this.target, newTarget);
70      }
71  
72      /** {@inheritDoc} */
73      public String getID() {
74          return this.id;
75      }
76  
77      /** {@inheritDoc} */
78      public void setID(String newID) {
79          String oldID = this.id;
80          this.id = prepareForAssignment(this.id, newID);
81          registerOwnID(oldID, this.id);
82      }
83  
84      /** {@inheritDoc} */
85      public AttributeMap getUnknownAttributes() {
86          return unknownAttributes;
87      }
88  
89      /** {@inheritDoc} */
90      public List<XMLObject> getUnknownXMLObjects() {
91          return (List<XMLObject>) unknownChildren;
92      }
93      /** {@inheritDoc} */
94      public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
95          return (List<XMLObject>) unknownChildren.subList(typeOrName);
96      }
97  
98      /** {@inheritDoc} */
99      public List<XMLObject> getOrderedChildren() {
100         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
101         
102         children.addAll((List<XMLObject>) unknownChildren);
103         
104         if (children.size() == 0) {
105             return null;
106         }
107         
108         return Collections.unmodifiableList(children);
109     }
110 
111 }