KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > model > validation > ValidatorRule


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler.model.validation;
19
20 import java.util.Map JavaDoc;
21 import java.util.LinkedHashMap JavaDoc;
22
23 public class ValidatorRule
24 {
25     private Map JavaDoc _vars;
26     private String JavaDoc _ruleName;
27     private String JavaDoc _messageKey;
28     private String JavaDoc _message;
29     private String JavaDoc _bundle;
30     private Map JavaDoc _args;
31
32
33     public static class MessageArg
34     {
35         private String JavaDoc _message;
36         private boolean _isKey;
37         private String JavaDoc _bundle;
38         private Integer JavaDoc _position;
39
40         public MessageArg( String JavaDoc message, boolean isKey, String JavaDoc bundle, Integer JavaDoc position )
41         {
42             _message = message;
43             _isKey = isKey;
44             _bundle = bundle;
45             _position = position;
46         }
47
48         public String JavaDoc getMessage()
49         {
50             return _message;
51         }
52
53         public boolean isKey()
54         {
55             return _isKey;
56         }
57
58         public String JavaDoc getBundle()
59         {
60             return _bundle;
61         }
62
63         public Integer JavaDoc getPosition()
64         {
65             return _position;
66         }
67     }
68     
69     public ValidatorRule( String JavaDoc ruleName )
70     {
71         assert ruleName != null;
72         _ruleName = ruleName;
73     }
74     
75     public void setVar( String JavaDoc name, String JavaDoc val )
76     {
77         if ( _vars == null ) _vars = new LinkedHashMap JavaDoc();
78         _vars.put( name, val );
79     }
80     
81     public Map JavaDoc getVars()
82     {
83         return _vars;
84     }
85     
86     public String JavaDoc getRuleName()
87     {
88         return _ruleName;
89     }
90     
91     public String JavaDoc getMessageKey()
92     {
93         return _messageKey;
94     }
95     
96     public void setMessageKey( String JavaDoc messageKey )
97     {
98         _messageKey = messageKey;
99     }
100     
101     public String JavaDoc getMessage()
102     {
103         return _message;
104     }
105     
106     public void setMessage( String JavaDoc message )
107     {
108         assert _messageKey == null;
109         _message = message;
110     }
111
112     public String JavaDoc getBundle()
113     {
114         return _bundle;
115     }
116
117     public void setBundle( String JavaDoc bundle )
118     {
119         _bundle = bundle;
120     }
121
122     public void setArg( String JavaDoc message, boolean isKey, String JavaDoc bundle, Integer JavaDoc position )
123     {
124         if ( _args == null ) { _args = new LinkedHashMap JavaDoc(); }
125         _args.put( position, new MessageArg( message, isKey, bundle, position ) );
126     }
127
128     public MessageArg getArg( Integer JavaDoc position )
129     {
130         if ( _args == null ) { return null; }
131         return ( MessageArg ) _args.get( position );
132     }
133 }
134
Popular Tags