View Javadoc

1   /*
2    * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
3    * Copyright 2008 Members of the EGEE Collaboration.
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * 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 org.opensaml.xacml.policy.impl;
19  
20  import java.util.List;
21  
22  import org.opensaml.xacml.policy.AttributeDesignatorType;
23  import org.opensaml.xml.XMLObject;
24  import org.opensaml.xml.schema.XSBooleanValue;
25  import org.opensaml.xml.util.LazyList;
26  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
27  
28  /**
29   * Implementation of {@link AttributeDesignatorType}.
30   */
31  public class AttributeDesignatorTypeImpl extends AbstractValidatingXMLObject
32  	implements AttributeDesignatorType {
33  
34      /** Attribute Id. */
35      private String attributeId;
36  
37      /** Datatype. */
38      private String dataType;
39  
40      /** Issuer. */
41      private String issuer;
42  
43      /** Must be present. */
44      private XSBooleanValue mustBePresentXS = null;
45  
46      /**
47       * Constructor.
48       * 
49       * @param namespaceURI
50       *                the namespace the element is in
51       * @param elementLocalName
52       *                the local name of the XML element this Object represents
53       * @param namespacePrefix
54       *                the prefix for the given namespace
55       */
56      protected AttributeDesignatorTypeImpl(String namespaceURI,
57  	    String elementLocalName, String namespacePrefix) {
58  	super(namespaceURI, elementLocalName, namespacePrefix);
59  	mustBePresentXS = XSBooleanValue.valueOf("false");
60      }
61  
62      /** {@inheritDoc} */
63      public String getAttributeId() {
64  	return attributeId;
65      }
66  
67      /** {@inheritDoc} */
68      public String getDataType() {
69  	return dataType;
70      }
71  
72      /** {@inheritDoc} */
73      public String getIssuer() {
74  	return issuer;
75      }
76  
77      /** {@inheritDoc} */
78      public XSBooleanValue getMustBePresentXSBoolean() {
79  	return mustBePresentXS;
80      }
81  
82      /** {@inheritDoc} */
83      public Boolean getMustBePresent() {
84  	if (mustBePresentXS != null) {
85  	    return mustBePresentXS.getValue();
86  	}
87  	return Boolean.FALSE;
88      }
89  
90      /** {@inheritDoc} */
91      public void setAttribtueId(String id) {
92  	this.attributeId = prepareForAssignment(this.attributeId, id);
93      }
94  
95      /** {@inheritDoc} */
96      public void setDataType(String type) {
97  	this.dataType = prepareForAssignment(this.dataType, type);
98      }
99  
100     /** {@inheritDoc} */
101     public void setIssuer(String newIssuer) {
102 	this.issuer = prepareForAssignment(this.issuer, newIssuer);
103     }
104 
105     /** {@inheritDoc} */
106     public void setMustBePresentXSBoolean(XSBooleanValue present) {
107 	this.mustBePresentXS = prepareForAssignment(this.mustBePresentXS,
108 		present);
109     }
110 
111     /** {@inheritDoc} */
112     public void setMustBePresent(Boolean present) {
113 	if (present != null) {
114 	    this.mustBePresentXS = prepareForAssignment(this.mustBePresentXS,
115 		    new XSBooleanValue(present, false));
116 	} else {
117 	    this.mustBePresentXS = prepareForAssignment(this.mustBePresentXS,
118 		    null);
119 	}
120 
121     }
122 
123     /** {@inheritDoc} */
124     public List<XMLObject> getOrderedChildren() {
125         return new LazyList<XMLObject>();
126     }
127 
128 }