KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > util > validators > ConstraintRule


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.util.validators;
25
26 /**
27  * ConstraintRule.java
28  * Created on 2002-sep-13
29  * @author Stefan Sik, ss@frovi.com
30  * ss
31  *
32  *
33  * This class defines a constraint rule for a specified field.
34  *
35  */

36 public class ConstraintRule
37 {
38     // Private storage
39
private int constraintType;
40     private String JavaDoc fieldName;
41     private Object JavaDoc value = null;
42     private Range validRange = new Range();
43
44
45     // Public options
46
public boolean unique = false;
47     public boolean required = false;
48
49     // Constructor
50
public ConstraintRule(int constraintType, String JavaDoc fieldName)
51     {
52         this.constraintType = constraintType;
53         this.fieldName = fieldName;
54     }
55
56     // Getters
57

58     public int getConstraintType()
59     {
60         return constraintType;
61     }
62     public String JavaDoc getFieldName()
63     {
64         return fieldName;
65     }
66
67     public Object JavaDoc getValue()
68     {
69         return value;
70     }
71
72     public void setValue(Object JavaDoc value)
73     {
74         this.value = value;
75     }
76
77     public Range getValidRange()
78     {
79         return validRange;
80     }
81
82     public void setValidRange(Range validRange)
83     {
84         this.validRange = validRange;
85     }
86
87     /**
88      * Returns the required.
89      * @return boolean
90      */

91     public boolean isRequired()
92     {
93         return required;
94     }
95
96     /**
97      * Returns the unique.
98      * @return boolean
99      */

100     public boolean isUnique()
101     {
102         return unique;
103     }
104
105     /**
106      * Sets the required.
107      * @param required The required to set
108      */

109     public void setRequired(boolean required)
110     {
111         this.required = required;
112     }
113
114     /**
115      * Sets the unique.
116      * @param unique The unique to set
117      */

118     public void setUnique(boolean unique)
119     {
120         this.unique = unique;
121     }
122
123 }
124
Popular Tags