View Javadoc

1   /*
2    * Copyright [2005] [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  /**
18   * 
19   */
20  
21  package org.opensaml.saml2.core.impl;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import javax.xml.namespace.QName;
28  
29  import org.opensaml.common.impl.AbstractSAMLObject;
30  import org.opensaml.saml2.core.Advice;
31  import org.opensaml.saml2.core.Assertion;
32  import org.opensaml.saml2.core.AssertionIDRef;
33  import org.opensaml.saml2.core.AssertionURIRef;
34  import org.opensaml.saml2.core.EncryptedAssertion;
35  import org.opensaml.xml.XMLObject;
36  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
37  
38  /**
39   * A concrete implementation of {@link org.opensaml.saml2.core.Advice}.
40   */
41  public class AdviceImpl extends AbstractSAMLObject implements Advice {
42  
43      /** Children. */
44      private final IndexedXMLObjectChildrenList<XMLObject> indexedChildren;
45  
46      /**
47       * Constructor.
48       * 
49       * @param namespaceURI the namespace the element is in
50       * @param elementLocalName the local name of the XML element this Object represents
51       * @param namespacePrefix the prefix for the given namespace
52       */
53      protected AdviceImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
54          super(namespaceURI, elementLocalName, namespacePrefix);
55          indexedChildren = new IndexedXMLObjectChildrenList<XMLObject>(this);
56      }
57  
58      /** {@inheritDoc} */
59      public List<XMLObject> getChildren() {
60          return indexedChildren;
61      }
62  
63      /** {@inheritDoc} */
64      public List<XMLObject> getChildren(QName typeOrName) {
65          return (List<XMLObject>) indexedChildren.subList(typeOrName);
66      }
67  
68      /** {@inheritDoc} */
69      public List<AssertionIDRef> getAssertionIDReferences() {
70          return (List<AssertionIDRef>) indexedChildren.subList(AssertionIDRef.DEFAULT_ELEMENT_NAME);
71      }
72  
73      /** {@inheritDoc} */
74      public List<AssertionURIRef> getAssertionURIReferences() {
75          return (List<AssertionURIRef>) indexedChildren.subList(AssertionURIRef.DEFAULT_ELEMENT_NAME);
76      }
77  
78      /** {@inheritDoc} */
79      public List<Assertion> getAssertions() {
80          return (List<Assertion>) indexedChildren.subList(Assertion.DEFAULT_ELEMENT_NAME);
81      }
82  
83      /** {@inheritDoc} */
84      public List<EncryptedAssertion> getEncryptedAssertions() {
85          return (List<EncryptedAssertion>) indexedChildren.subList(EncryptedAssertion.DEFAULT_ELEMENT_NAME);
86      }
87  
88      /** {@inheritDoc} */
89      public List<XMLObject> getOrderedChildren() {
90          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
91  
92          children.addAll(indexedChildren);
93  
94          return Collections.unmodifiableList(children);
95      }
96  }