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