View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  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 edu.internet2.middleware.shibboleth.common.xmlobject.impl;
19  
20  import javax.xml.namespace.QName;
21  
22  import org.opensaml.xml.schema.impl.XSAnyImpl;
23  
24  import edu.internet2.middleware.shibboleth.common.xmlobject.ShibbolethScopedValue;
25  
26  /**
27   * Concrete implementation of {@link org.opensaml.xml.schema.XSString}.
28   */
29  public class ShibbolethScopedValueImpl extends XSAnyImpl implements ShibbolethScopedValue {
30  
31      /** Scope of this string element. */
32      private String scope;
33  
34      /** Scope attribute name for this element. */
35      private String scopeAttributeName;
36  
37      /**
38       * Constructor.
39       * 
40       * @param namespaceURI the namespace the element is in
41       * @param elementLocalName the local name of the XML element this Object represents
42       * @param namespacePrefix the prefix for the given namespace
43       */
44      protected ShibbolethScopedValueImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
45          super(namespaceURI, elementLocalName, namespacePrefix);
46      }
47  
48      /** {@inheritDoc} */
49      public String getScope() {
50          return scope;
51      }
52  
53      /** {@inheritDoc} */
54      public String getScopeAttributeName() {
55          return scopeAttributeName;
56      }
57  
58      /** {@inheritDoc} */
59      public void setScope(String newScope) {
60          scope = prepareForAssignment(scope, newScope);
61          if (scope != null && scopeAttributeName != null) {
62              getUnknownAttributes().put(new QName(scopeAttributeName), scope);
63          }
64      }
65  
66      /** {@inheritDoc} */
67      public void setScopeAttributeName(String newScopeAttributeName) {
68          if (scopeAttributeName != null) {
69              QName oldName = new QName(scopeAttributeName);
70              if (getUnknownAttributes().containsKey(oldName)) {
71                  getUnknownAttributes().remove(oldName);
72              }
73          }
74  
75          scopeAttributeName = prepareForAssignment(scopeAttributeName, newScopeAttributeName);
76          
77          if (scope != null) {
78              getUnknownAttributes().put(new QName(scopeAttributeName), scope);
79          }
80      }
81  
82      /** {@inheritDoc} */
83      public String getValue() {
84          return getTextContent();
85      }
86  
87      /** {@inheritDoc} */
88      public void setValue(String newValue) {
89          setTextContent(newValue);
90      }
91  
92  }