View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.krad.datadictionary.validation.constraint;
17  
18  import org.kuali.rice.core.api.uif.DataType;
19  
20  import javax.xml.bind.annotation.XmlAccessType;
21  import javax.xml.bind.annotation.XmlAccessorType;
22  import javax.xml.bind.annotation.XmlElement;
23  
24  /**
25   * A simple constraint stores 'basic' constraints for a field.  This constraint is meant to be used as a
26   * constraint for WhenConstraints in CaseConstraint, and is also used internally in InputField.
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  @XmlAccessorType(XmlAccessType.FIELD)
31  public class SimpleConstraint extends BaseConstraint implements ExistenceConstraint, RangeConstraint, LengthConstraint{
32      
33  	@XmlElement
34  	private Boolean required;
35  	
36  	@XmlElement
37  	private Integer maxLength;
38  	
39  	@XmlElement
40  	private Integer minLength;
41  	
42  	@XmlElement
43  	protected String exclusiveMin;
44  	
45  	@XmlElement
46  	protected String inclusiveMax;
47  	
48  	//Don't know if we will support min/max occurs at this time
49  	@XmlElement
50  	private Integer minOccurs;
51  	
52  	@XmlElement
53  	private Integer maxOccurs;
54  
55      private DataType dataType;
56  
57  	/**
58  	 * If true the field is required
59  	 * @return the required
60  	 */
61  	public Boolean getRequired() {
62  		return this.required;
63  	}
64  
65  	/**
66  	 * @param required the required to set
67  	 */
68  	public void setRequired(Boolean required) {
69  		this.required = required;
70  	}
71  
72  	/**
73  	 * The maximum amount of characters this field's value can be
74  	 * @return the maxLength
75  	 */
76  	public Integer getMaxLength() {
77  		return this.maxLength;
78  	}
79  
80  	/**
81  	 * @param maxLength the maxLength to set
82  	 */
83  	public void setMaxLength(Integer maxLength) {
84  		this.maxLength = maxLength;
85  	}
86  
87  	/**
88  	 * The minimum amount of characters this field's value has to be
89  	 * @return the minLength
90  	 */
91  	public Integer getMinLength() {
92  		return this.minLength;
93  	}
94  
95  	/**
96  	 * @param minLength the minLength to set
97  	 */
98  	public void setMinLength(Integer minLength) {
99  		this.minLength = minLength;
100 	}
101 
102 	/**
103 	 * Exclusive minimum value for this field
104 	 * @return the exclusiveMin
105 	 */
106 	public String getExclusiveMin() {
107 		return this.exclusiveMin;
108 	}
109 
110 	/**
111 	 * @param exclusiveMin the exclusiveMin to set
112 	 */
113 	public void setExclusiveMin(String exclusiveMin) {
114 		this.exclusiveMin = exclusiveMin;
115 	}
116 
117 	/**
118 	 * Inclusive max value for this field
119 	 * @return the inclusiveMax
120 	 */
121 	public String getInclusiveMax() {
122 		return this.inclusiveMax;
123 	}
124 
125 	/**
126 	 * @param inclusiveMax the inclusiveMax to set
127 	 */
128 	public void setInclusiveMax(String inclusiveMax) {
129 		this.inclusiveMax = inclusiveMax;
130 	}
131 
132 	/**
133 	 * The minimum amount of items in this fields list of values - not yet used/do not use
134 	 * @return the minOccurs
135 	 */
136 	public Integer getMinOccurs() {
137 		return this.minOccurs;
138 	}
139 
140 	/**
141 	 * @param minOccurs the minOccurs to set
142 	 */
143 	public void setMinOccurs(Integer minOccurs) {
144 		this.minOccurs = minOccurs;
145 	}
146 
147 	/**
148 	 * The maximum amount of items in this field's list of values - not yet used/do not use
149 	 * @return the maxOccurs
150 	 */
151 	public Integer getMaxOccurs() {
152 		return this.maxOccurs;
153 	}
154 
155 	/**
156 	 * @param maxOccurs the maxOccurs to set
157 	 */
158 	public void setMaxOccurs(Integer maxOccurs) {
159 		this.maxOccurs = maxOccurs;
160 	}
161 
162 
163     /**
164      * @see org.kuali.rice.krad.datadictionary.validation.constraint.ExistenceConstraint#isRequired()
165      */
166     @Override
167     public Boolean isRequired() {
168         return getRequired();
169     }
170 
171     public DataType getDataType() {
172         return dataType;
173     }
174 
175     public void setDataType(DataType dataType) {
176         this.dataType = dataType;
177     }
178 }
179