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  package org.opensaml.saml1.core.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.opensaml.saml1.core.Attribute;
24  import org.opensaml.saml1.core.AttributeStatement;
25  import org.opensaml.xml.XMLObject;
26  import org.opensaml.xml.util.XMLObjectChildrenList;
27  
28  /**
29   * A Concrete implementation of the {@link org.opensaml.saml1.core.AttributeStatement} Interface
30   */
31  public class AttributeStatementImpl extends SubjectStatementImpl implements AttributeStatement {
32  
33      /** Contains the Attributes (in order) */
34      private final XMLObjectChildrenList<Attribute> attributes;
35  
36      /**
37       * Constructor
38       * 
39       * @param namespaceURI the namespace the element is in
40       * @param elementLocalName the local name of the XML element this Object represents
41       * @param namespacePrefix the prefix for the given namespace
42       */
43      protected AttributeStatementImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
44          super(namespaceURI, elementLocalName, namespacePrefix);
45          attributes = new XMLObjectChildrenList<Attribute>(this);
46      }
47  
48      /** {@inheritDoc} */
49      public List<Attribute> getAttributes() {
50          return attributes;
51      }
52  
53      /** {@inheritDoc} */
54      public List<XMLObject> getOrderedChildren() {
55          List<XMLObject> list = new ArrayList<XMLObject>(attributes.size() + 1);
56  
57          if (super.getOrderedChildren() != null) {
58              list.addAll(super.getOrderedChildren());
59          }
60  
61          list.addAll(attributes);
62  
63          if (list.size() == 0) {
64              return null;
65          }
66  
67          return Collections.unmodifiableList(list);
68      }
69  }