View Javadoc

1   /*
2    * Copyright [2006] [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.ws.soap.common;
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.xml.AttributeExtensibleXMLObject;
26  import org.opensaml.xml.ElementExtensibleXMLObject;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.AttributeMap;
29  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
30  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
31  
32  /**
33   * Abstract class implementating validation and element and attribute extensibility.
34   */
35  public class AbstractExtensibleSOAPObject extends AbstractValidatingXMLObject implements SOAPObject,
36          AttributeExtensibleXMLObject, ElementExtensibleXMLObject {
37  
38      /** "Any" type children. */
39      private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;
40  
41      /** Attributes of the proxied Element. */
42      private AttributeMap attributes;
43  
44      /**
45       * Constructor.
46       * 
47       * @param namespaceURI namespace of the element
48       * @param elementLocalName name of the element
49       * @param namespacePrefix namespace prefix of the element
50       */
51      protected AbstractExtensibleSOAPObject(String namespaceURI, String elementLocalName, String namespacePrefix) {
52          super(namespaceURI, elementLocalName, namespacePrefix);
53          attributes = new AttributeMap(this);
54          unknownXMLObjects = new IndexedXMLObjectChildrenList<XMLObject>(this);
55      }
56  
57      /** {@inheritDoc} */
58      public List<XMLObject> getOrderedChildren() {
59          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
60  
61          children.addAll(unknownXMLObjects);
62  
63          return Collections.unmodifiableList(children);
64      }
65  
66      /** {@inheritDoc} */
67      public List<XMLObject> getUnknownXMLObjects() {
68          return unknownXMLObjects;
69      }
70      
71      /** {@inheritDoc} */
72      public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
73          return (List<XMLObject>) unknownXMLObjects.subList(typeOrName);
74      }
75  
76      /** {@inheritDoc} */
77      public AttributeMap getUnknownAttributes() {
78          return attributes;
79      }
80  }