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.saml2.core.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.opensaml.common.impl.AbstractSAMLObject;
24  import org.opensaml.saml2.core.Attribute;
25  import org.opensaml.xml.XMLObject;
26  import org.opensaml.xml.util.AttributeMap;
27  import org.opensaml.xml.util.XMLObjectChildrenList;
28  
29  /**
30   * Concrete implementation of {@link org.opensaml.saml2.core.Attribute}.
31   */
32  public class AttributeImpl extends AbstractSAMLObject implements Attribute {
33  
34      /** Name of the attribute. */
35      private String name;
36  
37      /** Format of the name of the attribute. */
38      private String nameFormat;
39  
40      /** Human readable name of the attribute. */
41      private String friendlyName;
42  
43      /** "anyAttribute" attributes. */
44      private AttributeMap unknownAttributes;
45  
46      /** List of attribute values for this attribute. */
47      private final XMLObjectChildrenList<XMLObject> attributeValues;
48  
49      /**
50       * Constructor.
51       * 
52       * @param namespaceURI the namespace the element is in
53       * @param elementLocalName the local name of the XML element this Object represents
54       * @param namespacePrefix the prefix for the given namespace
55       */
56      protected AttributeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
57          super(namespaceURI, elementLocalName, namespacePrefix);
58          unknownAttributes = new AttributeMap(this);
59          attributeValues = new XMLObjectChildrenList<XMLObject>(this);
60      }
61  
62      /** {@inheritDoc} */
63      public String getName() {
64          return name;
65      }
66  
67      /** {@inheritDoc} */
68      public void setName(String name) {
69          this.name = prepareForAssignment(this.name, name);
70      }
71  
72      /** {@inheritDoc} */
73      public String getNameFormat() {
74          return nameFormat;
75      }
76  
77      /** {@inheritDoc} */
78      public void setNameFormat(String nameFormat) {
79          this.nameFormat = prepareForAssignment(this.nameFormat, nameFormat);
80      }
81  
82      /** {@inheritDoc} */
83      public String getFriendlyName() {
84          return friendlyName;
85      }
86  
87      /** {@inheritDoc} */
88      public void setFriendlyName(String friendlyName) {
89          this.friendlyName = prepareForAssignment(this.friendlyName, friendlyName);
90      }
91  
92      /**
93       * {@inheritDoc}
94       */
95      public AttributeMap getUnknownAttributes() {
96          return unknownAttributes;
97      }
98  
99      /** {@inheritDoc} */
100     public List<XMLObject> getAttributeValues() {
101         return attributeValues;
102     }
103 
104     /** {@inheritDoc} */
105     public List<XMLObject> getOrderedChildren() {
106         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
107 
108         children.addAll(attributeValues);
109 
110         return Collections.unmodifiableList(children);
111     }
112 }