View Javadoc

1   /*
2    * Copyright 2008 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.xacml.ctx.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import javax.xml.namespace.QName;
24  
25  import org.opensaml.xacml.ctx.ResourceContentType;
26  import org.opensaml.xml.XMLObject;
27  import org.opensaml.xml.util.AttributeMap;
28  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
29  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
30  
31  /** Concrete implementation of {@link ResourceContentType}. */
32  public class ResourceContentTypeImpl extends AbstractValidatingXMLObject implements ResourceContentType {
33  
34      /** "any" elements. */
35      private IndexedXMLObjectChildrenList<XMLObject> unknownElements;
36  
37      /** "any" attributes. */
38      private AttributeMap unknownAttributes;
39      
40      /** String value of the mixed content element. */
41      private String value;
42  
43      /**
44       * Constructor.
45       * 
46       * @param namespaceURI the namespace the element is in
47       * @param elementLocalName the local name of the XML element this Object represents
48       * @param namespacePrefix the prefix for the given namespace
49       */
50      protected ResourceContentTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
51          super(namespaceURI, elementLocalName, namespacePrefix);
52          unknownAttributes = new AttributeMap(this);
53          unknownElements = new IndexedXMLObjectChildrenList<XMLObject>(this);
54      }
55  
56      /** {@inheritDoc} */
57      public List<XMLObject> getOrderedChildren() {
58          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
59          
60          children.addAll(unknownElements);
61          
62          return Collections.unmodifiableList(children);
63      }
64  
65      /** {@inheritDoc} */
66      public List<XMLObject> getUnknownXMLObjects() {
67          return unknownElements;
68      }
69  
70      /** {@inheritDoc} */
71      public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
72          return (List<XMLObject>) unknownElements.subList(typeOrName);
73      }
74  
75      /** {@inheritDoc} */
76      public AttributeMap getUnknownAttributes() {
77          return unknownAttributes;
78      }
79      
80      /** {@inheritDoc} */
81      public String getValue() {
82          return value;
83      }
84      
85      /** {@inheritDoc} */
86      public void setValue(String newValue) {
87          value = prepareForAssignment(value, newValue);
88      }
89  }