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.ResourceContentType;
27  import org.opensaml.xacml.ctx.ResourceType;
28  import org.opensaml.xml.XMLObject;
29  import org.opensaml.xml.util.XMLObjectChildrenList;
30  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
31  
32  /** Concrete implementation of {@link ResourceType}. */
33  public class ResourceTypeImpl extends AbstractValidatingXMLObject implements ResourceType {
34  
35      /** Lists of the attributes in the subject. */
36      private XMLObjectChildrenList<AttributeType> attributes;
37  
38      /** Resources content. */
39      private ResourceContentType resourceContent;
40  
41      /**
42       * Constructor.
43       * 
44       * @param namespaceURI the namespace the element is in
45       * @param elementLocalName the local name of the XML element this Object represents
46       * @param namespacePrefix the prefix for the given namespace
47       */
48      protected ResourceTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
49          super(namespaceURI, elementLocalName, namespacePrefix);
50          attributes = new XMLObjectChildrenList<AttributeType>(this);
51      }
52  
53      /** {@inheritDoc} */
54      public List<AttributeType> getAttributes() {
55          return attributes;
56      }
57  
58      /** {@inheritDoc} */
59      public List<XMLObject> getOrderedChildren() {
60          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
61          if (resourceContent != null) {
62              children.add(resourceContent);
63          }
64          children.addAll(attributes);
65          return Collections.unmodifiableList(children);
66      }
67  
68      /** {@inheritDoc} */
69      public ResourceContentType getResourceContent() {
70          return resourceContent;
71      }
72  
73      /** {@inheritDoc} */
74      public void setResourceContent(ResourceContentType content) {
75          resourceContent = prepareForAssignment(resourceContent, content);
76      }
77  }