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  /**
18   * 
19   */
20  
21  package org.opensaml.saml2.metadata.impl;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.opensaml.common.impl.AbstractSAMLObject;
28  import org.opensaml.saml2.metadata.AttributeConsumingService;
29  import org.opensaml.saml2.metadata.RequestedAttribute;
30  import org.opensaml.saml2.metadata.ServiceDescription;
31  import org.opensaml.saml2.metadata.ServiceName;
32  import org.opensaml.xml.XMLObject;
33  import org.opensaml.xml.schema.XSBooleanValue;
34  import org.opensaml.xml.util.XMLObjectChildrenList;
35  
36  /**
37   * Concrete implementation of {@link org.opensaml.saml2.metadata.AttributeConsumingService}.
38   */
39  public class AttributeConsumingServiceImpl extends AbstractSAMLObject implements AttributeConsumingService {
40  
41      /** Index of this service */
42      private int index;
43  
44      /** isDefault attribute of this service */
45      private XSBooleanValue isDefault;
46  
47      /** ServiceName children */
48      private final XMLObjectChildrenList<ServiceName> serviceNames;
49  
50      /** ServiceDescription children */
51      private final XMLObjectChildrenList<ServiceDescription> serviceDescriptions;
52  
53      /** RequestedAttribute children */
54      private final XMLObjectChildrenList<RequestedAttribute> requestAttributes;
55      
56      /**
57       * Constructor
58       * 
59       * @param namespaceURI
60       * @param elementLocalName
61       * @param namespacePrefix
62       */
63      protected AttributeConsumingServiceImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
64          super(namespaceURI, elementLocalName, namespacePrefix);
65          serviceNames = new XMLObjectChildrenList<ServiceName>(this);
66          serviceDescriptions = new XMLObjectChildrenList<ServiceDescription>(this);
67          requestAttributes = new XMLObjectChildrenList<RequestedAttribute>(this);
68      }
69  
70      /** {@inheritDoc} */
71      public int getIndex() {
72          return index;
73      }
74  
75      /** {@inheritDoc} */
76      public void setIndex(int index) {
77          if (this.index != index) {
78              releaseThisandParentDOM();
79              this.index = index;
80          }
81      }
82      
83      /** {@inheritDoc} */
84      public Boolean isDefault(){
85          if(isDefault != null){
86              return isDefault.getValue();
87          }
88          
89          return Boolean.FALSE;
90      }
91  
92      /** {@inheritDoc} */
93      public XSBooleanValue isDefaultXSBoolean() {
94          return isDefault;
95      }
96      
97      /** {@inheritDoc} */
98      public void setIsDefault(Boolean newIsDefault){
99          if(newIsDefault != null){
100             isDefault = prepareForAssignment(isDefault, new XSBooleanValue(newIsDefault, false));
101         }else{
102             isDefault = prepareForAssignment(isDefault, null);
103         }
104     }
105 
106     /** {@inheritDoc} */
107     public void setIsDefault(XSBooleanValue newIsDefault) {
108         isDefault = prepareForAssignment(isDefault, newIsDefault);
109     }
110 
111     /** {@inheritDoc} */
112     public List<ServiceName> getNames() {
113         return serviceNames;
114     }
115 
116     /** {@inheritDoc} */
117     public List<ServiceDescription> getDescriptions() {
118         return serviceDescriptions;
119     }
120 
121     /** {@inheritDoc} */
122     public List<RequestedAttribute> getRequestAttributes() {
123         return requestAttributes;
124     }
125 
126     /** {@inheritDoc} */
127     public List<XMLObject> getOrderedChildren() {
128         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
129 
130         children.addAll(serviceNames);
131         children.addAll(serviceDescriptions);
132         children.addAll(requestAttributes);
133 
134         return Collections.unmodifiableList(children);
135     }
136 }