View Javadoc

1   /*
2    * Copyright [2007] [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 edu.internet2.middleware.shibboleth.common.xmlobject.impl;
18  
19  import javax.xml.namespace.QName;
20  
21  import org.opensaml.xml.schema.impl.XSAnyImpl;
22  
23  import edu.internet2.middleware.shibboleth.common.xmlobject.ShibbolethScopedValue;
24  
25  /**
26   * Concrete implementation of {@link org.opensaml.xml.schema.XSString}.
27   */
28  public class ShibbolethScopedValueImpl extends XSAnyImpl implements ShibbolethScopedValue {
29  
30      /** Scope of this string element. */
31      private String scope;
32  
33      /** Scope attribute name for this element. */
34      private String scopeAttributeName;
35  
36      /**
37       * Constructor.
38       * 
39       * @param namespaceURI the namespace the element is in
40       * @param elementLocalName the local name of the XML element this Object represents
41       * @param namespacePrefix the prefix for the given namespace
42       */
43      protected ShibbolethScopedValueImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
44          super(namespaceURI, elementLocalName, namespacePrefix);
45      }
46  
47      /** {@inheritDoc} */
48      public String getScope() {
49          return scope;
50      }
51  
52      /** {@inheritDoc} */
53      public String getScopeAttributeName() {
54          return scopeAttributeName;
55      }
56  
57      /** {@inheritDoc} */
58      public void setScope(String newScope) {
59          scope = prepareForAssignment(scope, newScope);
60          if (scope != null && scopeAttributeName != null) {
61              getUnknownAttributes().put(new QName(scopeAttributeName), scope);
62          }
63      }
64  
65      /** {@inheritDoc} */
66      public void setScopeAttributeName(String newScopeAttributeName) {
67          if (scopeAttributeName != null) {
68              QName oldName = new QName(scopeAttributeName);
69              if (getUnknownAttributes().containsKey(oldName)) {
70                  getUnknownAttributes().remove(oldName);
71              }
72          }
73  
74          scopeAttributeName = prepareForAssignment(scopeAttributeName, newScopeAttributeName);
75          
76          if (scope != null) {
77              getUnknownAttributes().put(new QName(scopeAttributeName), scope);
78          }
79      }
80  
81      /** {@inheritDoc} */
82      public String getValue() {
83          return getTextContent();
84      }
85  
86      /** {@inheritDoc} */
87      public void setValue(String newValue) {
88          setTextContent(newValue);
89      }
90  
91  }