View Javadoc

1   /*
2    * Copyright 2008 Members of the EGEE Collaboration.
3    * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.opensaml.ws.wsaddressing.impl;
19  
20  import java.util.ArrayList;
21  import java.util.Collections;
22  import java.util.List;
23  
24  import javax.xml.namespace.QName;
25  
26  import org.opensaml.ws.wsaddressing.Address;
27  import org.opensaml.ws.wsaddressing.EndpointReferenceType;
28  import org.opensaml.ws.wsaddressing.Metadata;
29  import org.opensaml.ws.wsaddressing.ReferenceParameters;
30  import org.opensaml.xml.XMLObject;
31  import org.opensaml.xml.util.AttributeMap;
32  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
33  
34  /**
35   * Abstract implementation of the element of type {@link EndpointReferenceType }.
36   * 
37   */
38  public class EndpointReferenceTypeImpl extends AbstractWSAddressingObject implements EndpointReferenceType {
39  
40      /** {@link Address} child element. */
41      private Address address;
42  
43      /** Optional {@link Metadata} child element. */
44      private Metadata metadata;
45  
46      /** Optional {@link ReferenceParameters} child element. */
47      private ReferenceParameters referenceParameters;
48      
49      /** Wildcard child elements. */
50      private IndexedXMLObjectChildrenList<XMLObject>  unknownChildren;
51      
52      /** Wildcard attributes. */
53      private AttributeMap unknownAttributes;
54  
55      /**
56       * Constructor.
57       * 
58       * @param namespaceURI The namespace of the element
59       * @param elementLocalName The local name of the element
60       * @param namespacePrefix The namespace prefix of the element
61       */
62      public EndpointReferenceTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
63          super(namespaceURI, elementLocalName, namespacePrefix);
64          unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this);
65          unknownAttributes = new AttributeMap(this);
66      }
67  
68      /** {@inheritDoc} */
69      public Address getAddress() {
70          return address;
71      }
72  
73      /** {@inheritDoc} */
74      public void setAddress(Address newAddress) {
75          address = prepareForAssignment(address, newAddress);
76      }
77  
78      /** {@inheritDoc} */
79      public Metadata getMetadata() {
80          return metadata;
81      }
82  
83      /** {@inheritDoc} */
84      public void setMetadata(Metadata newMetadata) {
85          metadata = prepareForAssignment(metadata, newMetadata);
86      }
87  
88      /** {@inheritDoc} */
89      public ReferenceParameters getReferenceParameters() {
90          return referenceParameters;
91      }
92  
93      /** {@inheritDoc} */
94      public void setReferenceParameters(ReferenceParameters newReferenceParameters) {
95          referenceParameters = prepareForAssignment(referenceParameters, newReferenceParameters);
96      }
97  
98      /** {@inheritDoc} */
99      public AttributeMap getUnknownAttributes() {
100         return unknownAttributes;
101     }
102 
103     /** {@inheritDoc} */
104     public List<XMLObject> getUnknownXMLObjects() {
105         return unknownChildren;
106     }
107 
108     /** {@inheritDoc} */
109     public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
110         return (List<XMLObject>) unknownChildren.subList(typeOrName);
111     }
112     
113     /** {@inheritDoc} */
114     public List<XMLObject> getOrderedChildren() {
115         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
116         if (address != null) {
117             children.add(address);
118         }
119         if (referenceParameters != null) {
120             children.add(referenceParameters);
121         }
122         if (metadata != null) {
123             children.add(metadata);
124         }
125 
126         // xs:any element
127         if (!getUnknownXMLObjects().isEmpty()) {
128             children.addAll(getUnknownXMLObjects());
129         }
130 
131         return Collections.unmodifiableList(children);
132     }
133  
134 }