View Javadoc

1   /*
2    * Copyright [2005] [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.saml1.core.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.common.impl.AbstractSAMLObject;
26  import org.opensaml.saml1.core.StatusCode;
27  import org.opensaml.xml.Namespace;
28  import org.opensaml.xml.XMLObject;
29  
30  /**
31   * Concrete implementation of {@link org.opensaml.saml1.core.StatusCode} Object.
32   */
33  public class StatusCodeImpl extends AbstractSAMLObject implements StatusCode {
34  
35      /** Contents of the Value attribute. */
36      private QName value = null;
37  
38      /** The child StatusCode sub element. */
39      private StatusCode childStatusCode = null;
40  
41      /**
42       * Constructor.
43       * 
44       * @param namespaceURI the namespace the element is in
45       * @param elementLocalName the local name of the XML element this Object represents
46       * @param namespacePrefix the prefix for the given namespace
47       */
48      protected StatusCodeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
49          super(namespaceURI, elementLocalName, namespacePrefix);
50      }
51  
52      /** {@inheritDoc} */
53      public QName getValue() {
54          return value;
55      }
56  
57      /** {@inheritDoc} */
58      public void setValue(QName newValue) {
59          this.value = prepareForAssignment(this.value, newValue);
60          if(value != null){
61              addNamespace(new Namespace(value.getNamespaceURI(), value.getPrefix()));
62          }
63      }
64  
65      /** {@inheritDoc} */
66      public StatusCode getStatusCode() {
67          return childStatusCode;
68      }
69  
70      /** {@inheritDoc} */
71      public void setStatusCode(StatusCode statusCode) {
72          childStatusCode = prepareForAssignment(childStatusCode, statusCode);
73      }
74  
75      /** {@inheritDoc} */
76      public List<XMLObject> getOrderedChildren() {
77          if (childStatusCode != null) {
78              ArrayList<XMLObject> contents = new ArrayList<XMLObject>(1);
79              contents.add(childStatusCode);
80              return Collections.unmodifiableList(contents);
81          } else {
82              return null;
83          }
84      }
85  }