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 java.util.List;
20  import java.util.regex.Pattern;
21  
22  import org.opensaml.xml.XMLObject;
23  import org.opensaml.xml.schema.XSBooleanValue;
24  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
25  
26  import edu.internet2.middleware.shibboleth.common.xmlobject.ShibbolethMetadataScope;
27  
28  /**
29   * Implementation of {@link ShibbolethMetadataScope}.
30   */
31  public class ShibbolethMetadataScopeImpl extends AbstractValidatingXMLObject implements ShibbolethMetadataScope {
32  
33      /** The regexp attribute value. */
34      private XSBooleanValue regexp;
35  
36      /** The string content value. */
37      private String scopeValue;
38  
39      /** Pattern used to match scopes against criteria. */
40      private Pattern matchPattern;
41  
42      /**
43       * Constructor.
44       * 
45       * @param namespaceURI the namespace the element is in
46       * @param elementLocalName the local name of the XML element this Object represents
47       * @param namespacePrefix the prefix for the given namespace
48       */
49      protected ShibbolethMetadataScopeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
50          super(namespaceURI, elementLocalName, namespacePrefix);
51          regexp = null;
52      }
53  
54      /** {@inheritDoc} */
55      public Boolean getRegexp() {
56          if (regexp == null) {
57              return Boolean.FALSE;
58          }
59          return regexp.getValue();
60      }
61  
62      /** {@inheritDoc} */
63      public void setRegexp(Boolean newRegexp) {
64          if (newRegexp != null) {
65              regexp = prepareForAssignment(regexp, new XSBooleanValue(newRegexp, false));
66          } else {
67              regexp = prepareForAssignment(regexp, null);
68          }
69      }
70  
71      /** {@inheritDoc} */
72      public XSBooleanValue getRegexpXSBoolean() {
73          return regexp;
74      }
75  
76      /** {@inheritDoc} */
77      public void setRegexp(XSBooleanValue newRegexp) {
78          regexp = prepareForAssignment(regexp, newRegexp);
79      }
80  
81      /** {@inheritDoc} */
82      public String getValue() {
83          return scopeValue;
84      }
85  
86      /** {@inheritDoc} */
87      public void setValue(String newScopeValue) {
88          scopeValue = prepareForAssignment(scopeValue, newScopeValue);
89          matchPattern = Pattern.compile(scopeValue);
90      }
91  
92      /** {@inheritDoc} */
93      public Pattern getMatchPattern() {
94          return matchPattern;
95      }
96  
97      /** {@inheritDoc} */
98      public List<XMLObject> getOrderedChildren() {
99          return null;
100     }
101 }