View Javadoc

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