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.validation.AbstractValidatingXMLObject;
29  
30  /**
31   * Concrete implementation of {@link org.opensaml.xml.encryption.EncryptionProperty}
32   */
33  public class EncryptionPropertyImpl extends AbstractValidatingXMLObject implements
34          org.opensaml.xml.encryption.EncryptionProperty {
35      
36      /** Target attribute value */
37      private String target;
38      
39      /** Id attribute value */
40      private String id;
41      
42      /** Child elements from the <any> content model */
43      private final IndexedXMLObjectChildrenList unknownChildren;
44      
45      /** "anyAttribute" attributes */
46      private final AttributeMap unknownAttributes;
47  
48      /**
49       * Constructor
50       *
51       * @param namespaceURI
52       * @param elementLocalName
53       * @param namespacePrefix
54       */
55      protected EncryptionPropertyImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
56          super(namespaceURI, elementLocalName, namespacePrefix);
57          unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this);
58          unknownAttributes =  new AttributeMap(this);
59      }
60  
61      /** {@inheritDoc} */
62      public String getTarget() {
63          return this.target;
64      }
65  
66      /** {@inheritDoc} */
67      public void setTarget(String newTarget) {
68          this.target = prepareForAssignment(this.target, newTarget);
69      }
70  
71      /** {@inheritDoc} */
72      public String getID() {
73          return this.id;
74      }
75  
76      /** {@inheritDoc} */
77      public void setID(String newID) {
78          String oldID = this.id;
79          this.id = prepareForAssignment(this.id, newID);
80          registerOwnID(oldID, this.id);
81      }
82  
83      /** {@inheritDoc} */
84      public AttributeMap getUnknownAttributes() {
85          return unknownAttributes;
86      }
87  
88      /** {@inheritDoc} */
89      public List<XMLObject> getUnknownXMLObjects() {
90          return (List<XMLObject>) unknownChildren;
91      }
92      /** {@inheritDoc} */
93      public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
94          return (List<XMLObject>) unknownChildren.subList(typeOrName);
95      }
96  
97      /** {@inheritDoc} */
98      public List<XMLObject> getOrderedChildren() {
99          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
100         
101         children.addAll((List<XMLObject>) unknownChildren);
102         
103         if (children.size() == 0) {
104             return null;
105         }
106         
107         return Collections.unmodifiableList(children);
108     }
109 
110 }