View Javadoc

1   /*
2   Copyright 2008 Members of the EGEE Collaboration.
3   Copyright 2008 University Corporation for Advanced Internet Development,
4   Inc.
5   
6   Licensed under the Apache License, Version 2.0 (the "License");
7   you may not use this file except in compliance with the License.
8   You may obtain a copy of the License at
9   
10      http://www.apache.org/licenses/LICENSE-2.0
11  
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17   */
18  
19  package org.opensaml.xacml.ctx.impl;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  
25  import org.opensaml.xacml.ctx.AttributeType;
26  import org.opensaml.xacml.ctx.AttributeValueType;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.XMLObjectChildrenList;
29  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
30  
31  /** Concrete implementation of {@link AttributeType}. */
32  public class AttributeTypeImpl extends AbstractValidatingXMLObject implements AttributeType {
33  
34      /** Issuer of the attribute. */
35      private String issuer;
36  
37      /** AttributeID of the attribute. */
38      private String attributeID;
39  
40      /** Datatype of the attribute. */
41      private String datatype;
42  
43      /** List of values for this attribute. */
44      private final XMLObjectChildrenList<AttributeValueType> attributeValues;
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 AttributeTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
54          super(namespaceURI, elementLocalName, namespacePrefix);
55          attributeValues = new XMLObjectChildrenList<AttributeValueType>(this);
56      }
57  
58      /** {@inheritDoc} */
59      public String getAttributeID() {
60          return attributeID;
61      }
62  
63      /** {@inheritDoc} */
64      public String getDataType() {
65          return datatype;
66      }
67  
68      /** {@inheritDoc} */
69      public String getIssuer() {
70          return issuer;
71      }
72  
73      /** {@inheritDoc} */
74      public void setAttributeID(String attributeId) {
75          this.attributeID = prepareForAssignment(this.attributeID, attributeId);
76      }
77  
78      /** {@inheritDoc} */
79      public void setDataType(String datatype) {
80          this.datatype = prepareForAssignment(this.datatype, datatype);
81      }
82  
83      /** {@inheritDoc} */
84      public void setIssuer(String issuer) {
85          this.issuer = prepareForAssignment(this.issuer, issuer);
86      }
87  
88      /** {@inheritDoc} */
89      public List<XMLObject> getOrderedChildren() {
90          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
91  
92          children.addAll(attributeValues);
93  
94          return Collections.unmodifiableList(children);
95      }
96  
97      /** {@inheritDoc} */
98      public List<AttributeValueType> getAttributeValues() {
99          return attributeValues;
100     }
101 }