001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.compiler.model.validation;
020:
021: import java.util.Map;
022: import java.util.LinkedHashMap;
023:
024: public class ValidatorRule {
025: private Map _vars;
026: private String _ruleName;
027: private String _messageKey;
028: private String _message;
029: private String _bundle;
030: private Map _args;
031:
032: public static class MessageArg {
033: private String _message;
034: private boolean _isKey;
035: private String _bundle;
036: private Integer _position;
037:
038: public MessageArg(String message, boolean isKey, String bundle,
039: Integer position) {
040: _message = message;
041: _isKey = isKey;
042: _bundle = bundle;
043: _position = position;
044: }
045:
046: public String getMessage() {
047: return _message;
048: }
049:
050: public boolean isKey() {
051: return _isKey;
052: }
053:
054: public String getBundle() {
055: return _bundle;
056: }
057:
058: public Integer getPosition() {
059: return _position;
060: }
061: }
062:
063: public ValidatorRule(String ruleName) {
064: assert ruleName != null;
065: _ruleName = ruleName;
066: }
067:
068: public void setVar(String name, String val) {
069: if (_vars == null)
070: _vars = new LinkedHashMap();
071: _vars.put(name, val);
072: }
073:
074: public Map getVars() {
075: return _vars;
076: }
077:
078: public String getRuleName() {
079: return _ruleName;
080: }
081:
082: public String getMessageKey() {
083: return _messageKey;
084: }
085:
086: public void setMessageKey(String messageKey) {
087: _messageKey = messageKey;
088: }
089:
090: public String getMessage() {
091: return _message;
092: }
093:
094: public void setMessage(String message) {
095: assert _messageKey == null;
096: _message = message;
097: }
098:
099: public String getBundle() {
100: return _bundle;
101: }
102:
103: public void setBundle(String bundle) {
104: _bundle = bundle;
105: }
106:
107: public void setArg(String message, boolean isKey, String bundle,
108: Integer position) {
109: if (_args == null) {
110: _args = new LinkedHashMap();
111: }
112: _args.put(position, new MessageArg(message, isKey, bundle,
113: position));
114: }
115:
116: public MessageArg getArg(Integer position) {
117: if (_args == null) {
118: return null;
119: }
120: return (MessageArg) _args.get(position);
121: }
122: }
|