You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/09 15:11:14 UTC
svn commit: r376300 [6/6] - in
/struts/action/trunk/src/java/org/apache/struts: ./ action/ chain/
chain/commands/ chain/commands/generic/ chain/commands/servlet/
chain/commands/util/ chain/contexts/ config/ config/impl/ mock/ upload/
util/ validator/ v...
Modified: struts/action/trunk/src/java/org/apache/struts/validator/LazyValidatorForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/LazyValidatorForm.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/LazyValidatorForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/LazyValidatorForm.java Thu Feb 9 06:11:07 2006
@@ -35,15 +35,24 @@
* <code>LazyDynaBean<code> in the <code>get(name, index)</code> method.</p>
*
* <p><i>Lazy</i> DynaBeans provide several types of <i>lazy</i>
- * behaviour:</p> <ul> <li><b><i>lazy</i> property addition</b> - properties
- * which do not exist are automatically added.</li> <li><b><i>lazy</i> List
+ * behaviour:</p>
+ *
+ * <ul>
+ *
+ * <li><b><i>lazy</i> property addition</b> - properties
+ * which do not exist are automatically added.</li>
+ *
+ * <li><b><i>lazy</i> List
* facilities</b> - automatically <i>grows</i> a <code>List</code> or
* <code>Array</code> to accomodate the index value being set.</li>
+ *
* <li><b><i>lazy</i> List creation</b> - automatic creation of a
* <code>List</code> or <code>Array</code> for <i>indexed</i> properties, if
* it doesn't exist.</li> <li><b><i>lazy</i> Map creation</b> - automatic
* creation of a <code>Map</code> for <i>mapped</i> properties, if it doesn't
- * exist.</li> </ul>
+ * exist.</li>
+ *
+ * </ul>
*
* <p>Using this <i>lazy</i> <code>ActionForm</code> means that you don't have
* to define the ActionForm's properties in the <code>struts-config.xml</code>.
Modified: struts/action/trunk/src/java/org/apache/struts/validator/Resources.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/Resources.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/Resources.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/Resources.java Thu Feb 9 06:11:07 2006
@@ -36,6 +36,7 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
+
import java.util.Locale;
/**
@@ -50,8 +51,9 @@
/**
* The message resources for this package.
*/
- private static MessageResources sysmsgs = MessageResources
- .getMessageResources("org.apache.struts.validator.LocalStrings");
+ private static MessageResources sysmsgs =
+ MessageResources.getMessageResources(
+ "org.apache.struts.validator.LocalStrings");
/**
* <p>Commons Logging instance.</p>
@@ -62,19 +64,19 @@
* Resources key the <code>ServletContext</code> is stored under.
*/
private static String SERVLET_CONTEXT_PARAM =
- "javax.servlet.ServletContext";
+ "javax.servlet.ServletContext";
/**
* Resources key the <code>HttpServletRequest</code> is stored under.
*/
private static String HTTP_SERVLET_REQUEST_PARAM =
- "javax.servlet.http.HttpServletRequest";
+ "javax.servlet.http.HttpServletRequest";
/**
* Resources key the <code>ActionMessages</code> is stored under.
*/
private static String ACTION_MESSAGES_PARAM =
- "org.apache.struts.action.ActionMessages";
+ "org.apache.struts.action.ActionMessages";
/**
* Retrieve <code>ValidatorResources</code> for the current module.
@@ -83,14 +85,13 @@
* @param request The ServletRequest
*/
public static ValidatorResources getValidatorResources(
- ServletContext application, HttpServletRequest request) {
- String prefix = ModuleUtils.getInstance()
- .getModuleConfig(request, application)
- .getPrefix();
-
- return (ValidatorResources) application
- .getAttribute(ValidatorPlugIn.VALIDATOR_KEY
- + prefix);
+ ServletContext application, HttpServletRequest request) {
+ String prefix =
+ ModuleUtils.getInstance().getModuleConfig(request, application)
+ .getPrefix();
+
+ return (ValidatorResources) application.getAttribute(ValidatorPlugIn.VALIDATOR_KEY
+ + prefix);
}
/**
@@ -99,7 +100,7 @@
* @param request the servlet request
*/
public static MessageResources getMessageResources(
- HttpServletRequest request) {
+ HttpServletRequest request) {
return (MessageResources) request.getAttribute(Globals.MESSAGES_KEY);
}
@@ -111,21 +112,20 @@
* @param bundle the bundle key
*/
public static MessageResources getMessageResources(
- ServletContext application, HttpServletRequest request,
- String bundle) {
+ ServletContext application, HttpServletRequest request, String bundle) {
if (bundle == null) {
bundle = Globals.MESSAGES_KEY;
}
MessageResources resources =
- (MessageResources) request.getAttribute(bundle);
+ (MessageResources) request.getAttribute(bundle);
if (resources == null) {
- ModuleConfig moduleConfig = ModuleUtils.getInstance()
- .getModuleConfig(request,
- application);
+ ModuleConfig moduleConfig =
+ ModuleUtils.getInstance().getModuleConfig(request, application);
- resources = (MessageResources) application.getAttribute(bundle
+ resources =
+ (MessageResources) application.getAttribute(bundle
+ moduleConfig.getPrefix());
}
@@ -135,7 +135,7 @@
if (resources == null) {
throw new NullPointerException(
- "No message resources found for bundle: " + bundle);
+ "No message resources found for bundle: " + bundle);
}
return resources;
@@ -152,9 +152,7 @@
* @return The variable's value
*/
public static String getVarValue(String varName, Field field,
- Validator validator,
- HttpServletRequest request,
- boolean required) {
+ Validator validator, HttpServletRequest request, boolean required) {
Var var = field.getVar(varName);
if (var == null) {
@@ -171,8 +169,8 @@
return null;
}
- ServletContext application = (ServletContext) validator
- .getParameterValue(SERVLET_CONTEXT_PARAM);
+ ServletContext application =
+ (ServletContext) validator.getParameterValue(SERVLET_CONTEXT_PARAM);
return getVarValue(var, application, request, required);
}
@@ -187,8 +185,7 @@
* @return The variables values
*/
public static String getVarValue(Var var, ServletContext application,
- HttpServletRequest request,
- boolean required) {
+ HttpServletRequest request, boolean required) {
String varName = var.getName();
String varValue = var.getValue();
@@ -199,8 +196,8 @@
// Get the message resources
String bundle = var.getBundle();
- MessageResources messages = getMessageResources(application, request,
- bundle);
+ MessageResources messages =
+ getMessageResources(application, request, bundle);
// Retrieve variable's value from message resources
Locale locale = RequestUtils.getUserLocale(request, null);
@@ -214,7 +211,7 @@
if (log.isDebugEnabled()) {
log.debug("Var=[" + varName + "], " + "bundle=[" + bundle + "], "
- + "key=[" + varValue + "], " + "value=[" + value + "]");
+ + "key=[" + varValue + "], " + "value=[" + value + "]");
}
return value;
@@ -229,7 +226,7 @@
* @param key Key used to lookup the message
*/
public static String getMessage(MessageResources messages, Locale locale,
- String key) {
+ String key) {
String message = null;
if (messages != null) {
@@ -250,7 +247,7 @@
MessageResources messages = getMessageResources(request);
return getMessage(messages, RequestUtils.getUserLocale(request, null),
- key);
+ key);
}
/**
@@ -263,10 +260,11 @@
* @param field The Validator Field
*/
public static String getMessage(MessageResources messages, Locale locale,
- ValidatorAction va, Field field) {
+ ValidatorAction va, Field field) {
String[] args = getArgs(va.getName(), messages, locale, field);
- String msg = (field.getMsg(va.getName()) != null)
- ? field.getMsg(va.getName()) : va.getMsg();
+ String msg =
+ (field.getMsg(va.getName()) != null) ? field.getMsg(va.getName())
+ : va.getMsg();
return messages.getMessage(locale, msg, args);
}
@@ -283,10 +281,8 @@
* @param field The Validator Field
*/
public static String getMessage(ServletContext application,
- HttpServletRequest request,
- MessageResources defaultMessages,
- Locale locale, ValidatorAction va,
- Field field) {
+ HttpServletRequest request, MessageResources defaultMessages,
+ Locale locale, ValidatorAction va, Field field) {
Msg msg = field.getMessage(va.getName());
if ((msg != null) && !msg.isResource()) {
@@ -304,8 +300,8 @@
msgBundle = msg.getBundle();
if (msg.getBundle() != null) {
- messages = getMessageResources(application, request,
- msg.getBundle());
+ messages =
+ getMessageResources(application, request, msg.getBundle());
}
}
@@ -315,8 +311,8 @@
// Get the arguments
Arg[] args = field.getArgs(va.getName());
- String[] argValues = getArgValues(application, request, messages,
- locale, args);
+ String[] argValues =
+ getArgValues(application, request, messages, locale, args);
// Return the message
return messages.getMessage(locale, msgKey, argValues);
@@ -332,13 +328,14 @@
* @param field the validator Field
*/
public static ActionMessage getActionMessage(HttpServletRequest request,
- ValidatorAction va,
- Field field) {
- String[] args = getArgs(va.getName(), getMessageResources(request),
+ ValidatorAction va, Field field) {
+ String[] args =
+ getArgs(va.getName(), getMessageResources(request),
RequestUtils.getUserLocale(request, null), field);
- String msg = (field.getMsg(va.getName()) != null)
- ? field.getMsg(va.getName()) : va.getMsg();
+ String msg =
+ (field.getMsg(va.getName()) != null) ? field.getMsg(va.getName())
+ : va.getMsg();
return new ActionMessage(msg, args);
}
@@ -354,9 +351,7 @@
* @param field the validator Field
*/
public static ActionMessage getActionMessage(Validator validator,
- HttpServletRequest request,
- ValidatorAction va,
- Field field) {
+ HttpServletRequest request, ValidatorAction va, Field field) {
Msg msg = field.getMessage(va.getName());
if ((msg != null) && !msg.isResource()) {
@@ -375,18 +370,18 @@
if ((msgKey == null) || (msgKey.length() == 0)) {
return new ActionMessage("??? " + va.getName() + "."
- + field.getProperty() + " ???", false);
+ + field.getProperty() + " ???", false);
}
- ServletContext application = (ServletContext) validator
- .getParameterValue(SERVLET_CONTEXT_PARAM);
- MessageResources messages = getMessageResources(application, request,
- msgBundle);
+ ServletContext application =
+ (ServletContext) validator.getParameterValue(SERVLET_CONTEXT_PARAM);
+ MessageResources messages =
+ getMessageResources(application, request, msgBundle);
Locale locale = RequestUtils.getUserLocale(request, null);
Arg[] args = field.getArgs(va.getName());
- String[] argValues = getArgValues(application, request, messages,
- locale, args);
+ String[] argValues =
+ getArgValues(application, request, messages, locale, args);
ActionMessage actionMessage = null;
@@ -411,14 +406,14 @@
* @param field the validator field
*/
public static String[] getArgs(String actionName,
- MessageResources messages, Locale locale,
- Field field) {
+ MessageResources messages, Locale locale, Field field) {
String[] argMessages = new String[4];
- Arg[] args = new Arg[]{
+ Arg[] args =
+ new Arg[] {
field.getArg(actionName, 0), field.getArg(actionName, 1),
field.getArg(actionName, 2), field.getArg(actionName, 3)
- };
+ };
for (int i = 0; i < args.length; i++) {
if (args[i] == null) {
@@ -426,8 +421,7 @@
}
if (args[i].isResource()) {
- argMessages[i] =
- getMessage(messages, locale, args[i].getKey());
+ argMessages[i] = getMessage(messages, locale, args[i].getKey());
} else {
argMessages[i] = args[i].getKey();
}
@@ -447,9 +441,8 @@
* @param args The arguments for the message
*/
private static String[] getArgValues(ServletContext application,
- HttpServletRequest request,
- MessageResources defaultMessages,
- Locale locale, Arg[] args) {
+ HttpServletRequest request, MessageResources defaultMessages,
+ Locale locale, Arg[] args) {
if ((args == null) || (args.length == 0)) {
return null;
}
@@ -462,7 +455,8 @@
MessageResources messages = defaultMessages;
if (args[i].getBundle() != null) {
- messages = getMessageResources(application, request,
+ messages =
+ getMessageResources(application, request,
args[i].getBundle());
}
@@ -491,12 +485,10 @@
* to this page value, it will be processed.
*/
public static Validator initValidator(String key, Object bean,
- ServletContext application,
- HttpServletRequest request,
- ActionMessages errors, int page) {
+ ServletContext application, HttpServletRequest request,
+ ActionMessages errors, int page) {
ValidatorResources resources =
- Resources.getValidatorResources(application,
- request);
+ Resources.getValidatorResources(application, request);
Locale locale = RequestUtils.getUserLocale(request, null);
Modified: struts/action/trunk/src/java/org/apache/struts/validator/ValidatorActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/ValidatorActionForm.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/ValidatorActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/ValidatorActionForm.java Thu Feb 9 06:11:07 2006
@@ -20,6 +20,7 @@
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
+
import java.io.Serializable;
/**
@@ -28,15 +29,18 @@
* is the action element's 'path' attribute from the struts-config.xml which
* should match the form element's name attribute in the validation.xml.</p>
*
- * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
- * for validation rules.</li></ul>
+ * <ul>
+ *
+ * <li>See <code>ValidatorPlugin</code> definition in struts-config.xml for
+ * validation rules.</li>
+ *
+ * </ul>
*
* @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
* $
* @since Struts 1.1
*/
-public class ValidatorActionForm extends ValidatorForm
- implements Serializable {
+public class ValidatorActionForm extends ValidatorForm implements Serializable {
/**
* Returns the Validation key.
*
@@ -46,7 +50,7 @@
* case
*/
public String getValidationKey(ActionMapping mapping,
- HttpServletRequest request) {
+ HttpServletRequest request) {
return mapping.getPath();
}
}
Modified: struts/action/trunk/src/java/org/apache/struts/validator/ValidatorForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/ValidatorForm.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/ValidatorForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/ValidatorForm.java Thu Feb 9 06:11:07 2006
@@ -28,7 +28,9 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
+
import java.io.Serializable;
+
import java.util.Map;
/**
@@ -37,8 +39,12 @@
* action element's 'name' attribute from the struts-config.xml which should
* match the form element's name attribute in the validation.xml.</p>
*
- * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
- * for validation rules.</li></ul>
+ * <ul>
+ *
+ * <li>See <code>ValidatorPlugin</code> definition in struts-config.xml for
+ * validation rules.</li>
+ *
+ * </ul>
*
* @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
* $
@@ -93,19 +99,19 @@
* validation errors
*/
public ActionErrors validate(ActionMapping mapping,
- HttpServletRequest request) {
+ HttpServletRequest request) {
ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
String validationKey = getValidationKey(mapping, request);
- Validator validator = Resources.initValidator(validationKey, this,
- application, request, errors, page);
+ Validator validator =
+ Resources.initValidator(validationKey, this, application, request,
+ errors, page);
try {
validatorResults = validator.validate();
- }
- catch (ValidatorException e) {
+ } catch (ValidatorException e) {
log.error(e.getMessage(), e);
}
@@ -120,7 +126,7 @@
* @return validation key - the form element's name in this case
*/
public String getValidationKey(ActionMapping mapping,
- HttpServletRequest request) {
+ HttpServletRequest request) {
return mapping.getAttribute();
}
@@ -163,6 +169,6 @@
*/
public Map getResultValueMap() {
return ((validatorResults != null)
- ? validatorResults.getResultValueMap() : null);
+ ? validatorResults.getResultValueMap() : null);
}
}
Modified: struts/action/trunk/src/java/org/apache/struts/validator/ValidatorPlugIn.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/ValidatorPlugIn.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/ValidatorPlugIn.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/ValidatorPlugIn.java Thu Feb 9 06:11:07 2006
@@ -27,8 +27,11 @@
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
+
import java.io.IOException;
+
import java.net.URL;
+
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -57,7 +60,7 @@
* under.
*/
public final static String VALIDATOR_KEY =
- "org.apache.commons.validator.VALIDATOR_RESOURCES";
+ "org.apache.commons.validator.VALIDATOR_RESOURCES";
/**
* Application scope key that <code>StopOnError</code> is stored under.
@@ -65,7 +68,7 @@
* @since Struts 1.2
*/
public final static String STOP_ON_ERROR_KEY =
- "org.apache.struts.validator.STOP_ON_ERROR";
+ "org.apache.struts.validator.STOP_ON_ERROR";
/**
* The module configuration for our owning module.
@@ -148,7 +151,7 @@
* @throws ServletException if we cannot configure ourselves correctly
*/
public void init(ActionServlet servlet, ModuleConfig config)
- throws ServletException {
+ throws ServletException {
// Remember our associated configuration and servlet
this.config = config;
this.servlet = servlet;
@@ -158,17 +161,15 @@
this.initResources();
servlet.getServletContext().setAttribute(VALIDATOR_KEY
- + config.getPrefix(), resources);
+ + config.getPrefix(), resources);
servlet.getServletContext().setAttribute(STOP_ON_ERROR_KEY + '.'
- + config.getPrefix(),
- (this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE));
- }
- catch (Exception e) {
+ + config.getPrefix(),
+ (this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE));
+ } catch (Exception e) {
log.error(e.getMessage(), e);
throw new UnavailableException(
- "Cannot load a validator resource from '" + pathnames
- + "'");
+ "Cannot load a validator resource from '" + pathnames + "'");
}
}
@@ -194,7 +195,7 @@
* @throws ServletException if we cannot initialize these resources
*/
protected void initResources()
- throws IOException, ServletException {
+ throws IOException, ServletException {
if ((pathnames == null) || (pathnames.length() <= 0)) {
return;
}
@@ -209,11 +210,11 @@
if (log.isInfoEnabled()) {
log.info("Loading validation rules file from '"
- + validatorRules + "'");
+ + validatorRules + "'");
}
- URL input = servlet.getServletContext()
- .getResource(validatorRules);
+ URL input =
+ servlet.getServletContext().getResource(validatorRules);
// If the config isn't in the servlet context, try the class loader
// which allows the config files to be stored in a jar
@@ -225,9 +226,8 @@
urlList.add(input);
} else {
throw new ServletException(
- "Skipping validation rules file from '"
- + validatorRules
- + "'. No url could be located.");
+ "Skipping validation rules file from '"
+ + validatorRules + "'. No url could be located.");
}
}
@@ -241,8 +241,7 @@
}
this.resources = new ValidatorResources(urlArray);
- }
- catch (SAXException sex) {
+ } catch (SAXException sex) {
log.error("Skipping all validation", sex);
throw new ServletException(sex);
}
Modified: struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhen.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhen.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhen.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhen.java Thu Feb 9 06:11:07 2006
@@ -29,6 +29,7 @@
import org.apache.struts.validator.Resources;
import javax.servlet.http.HttpServletRequest;
+
import java.io.StringReader;
/**
@@ -46,8 +47,9 @@
/**
* The message resources for this package.
*/
- private static MessageResources sysmsgs = MessageResources
- .getMessageResources("org.apache.struts.validator.LocalStrings");
+ private static MessageResources sysmsgs =
+ MessageResources.getMessageResources(
+ "org.apache.struts.validator.LocalStrings");
/**
* Returns true if <code>obj</code> is null or a String.
@@ -72,10 +74,8 @@
* <code>false</code> otherwise.
*/
public static boolean validateValidWhen(Object bean, ValidatorAction va,
- Field field,
- ActionMessages errors,
- Validator validator,
- HttpServletRequest request) {
+ Field field, ActionMessages errors, Validator validator,
+ HttpServletRequest request) {
Object form = validator.getParameterValue(Validator.BEAN_PARAM);
String value = null;
boolean valid = false;
@@ -88,34 +88,32 @@
final int rightBracket = key.indexOf("]");
if ((leftBracket > -1) && (rightBracket > -1)) {
- index = Integer.parseInt(key.substring(leftBracket + 1,
- rightBracket));
+ index =
+ Integer.parseInt(key.substring(leftBracket + 1, rightBracket));
}
}
if (isString(bean)) {
value = (String) bean;
} else {
- value = ValidatorUtils
- .getValueAsString(bean, field.getProperty());
+ value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
String test = null;
try {
- test = Resources
- .getVarValue("test", field, validator, request, true);
- }
- catch (IllegalArgumentException ex) {
- String logErrorMsg = sysmsgs.getMessage("validation.failed",
- "validwhen", field.getProperty(), ex.toString());
+ test =
+ Resources.getVarValue("test", field, validator, request, true);
+ } catch (IllegalArgumentException ex) {
+ String logErrorMsg =
+ sysmsgs.getMessage("validation.failed", "validwhen",
+ field.getProperty(), ex.toString());
log.error(logErrorMsg);
String userErrorMsg = sysmsgs.getMessage("system.error");
- errors.add(field.getKey(),
- new ActionMessage(userErrorMsg, false));
+ errors.add(field.getKey(), new ActionMessage(userErrorMsg, false));
return false;
}
@@ -125,17 +123,16 @@
try {
lexer = new ValidWhenLexer(new StringReader(test));
- }
- catch (Exception ex) {
- String logErrorMsg = "ValidWhenLexer Error for field ' "
- + field.getKey() + "' - " + ex;
+ } catch (Exception ex) {
+ String logErrorMsg =
+ "ValidWhenLexer Error for field ' " + field.getKey() + "' - "
+ + ex;
log.error(logErrorMsg);
String userErrorMsg = sysmsgs.getMessage("system.error");
- errors.add(field.getKey(),
- new ActionMessage(userErrorMsg, false));
+ errors.add(field.getKey(), new ActionMessage(userErrorMsg, false));
return false;
}
@@ -145,17 +142,16 @@
try {
parser = new ValidWhenParser(lexer);
- }
- catch (Exception ex) {
- String logErrorMsg = "ValidWhenParser Error for field ' "
- + field.getKey() + "' - " + ex;
+ } catch (Exception ex) {
+ String logErrorMsg =
+ "ValidWhenParser Error for field ' " + field.getKey() + "' - "
+ + ex;
log.error(logErrorMsg);
String userErrorMsg = sysmsgs.getMessage("system.error");
- errors.add(field.getKey(),
- new ActionMessage(userErrorMsg, false));
+ errors.add(field.getKey(), new ActionMessage(userErrorMsg, false));
return false;
}
@@ -167,27 +163,22 @@
try {
parser.expression();
valid = parser.getResult();
- }
- catch (Exception ex) {
- String logErrorMsg = "ValidWhen Error for field ' "
- + field.getKey() + "' - " + ex;
+ } catch (Exception ex) {
+ String logErrorMsg =
+ "ValidWhen Error for field ' " + field.getKey() + "' - " + ex;
log.error(logErrorMsg);
String userErrorMsg = sysmsgs.getMessage("system.error");
- errors.add(field.getKey(),
- new ActionMessage(userErrorMsg, false));
+ errors.add(field.getKey(), new ActionMessage(userErrorMsg, false));
return false;
}
if (!valid) {
errors.add(field.getKey(),
- Resources.getActionMessage(validator,
- request,
- va,
- field));
+ Resources.getActionMessage(validator, request, va, field));
return false;
}
Modified: struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenLexer.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenLexer.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenLexer.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenLexer.java Thu Feb 9 06:11:07 2006
@@ -36,10 +36,11 @@
import java.io.InputStream;
import java.io.Reader;
+
import java.util.Hashtable;
public class ValidWhenLexer extends antlr.CharScanner
- implements ValidWhenParserTokenTypes, TokenStream {
+ implements ValidWhenParserTokenTypes, TokenStream {
public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
@@ -68,8 +69,8 @@
public Token nextToken() throws TokenStreamException {
Token theRetToken = null;
- tryAgain:
- for (; ;) {
+tryAgain:
+ for (;;) {
Token _token = null;
int _ttype = Token.INVALID_TYPE;
@@ -80,153 +81,153 @@
try { // for lexical error handling
switch (LA(1)) {
- case '\t':
- case '\n':
- case '\r':
- case ' ': {
- mWS(true);
- theRetToken = _returnToken;
+ case '\t':
+ case '\n':
+ case '\r':
+ case ' ': {
+ mWS(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '-':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': {
- mDECIMAL_LITERAL(true);
- theRetToken = _returnToken;
+ case '-':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': {
+ mDECIMAL_LITERAL(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '"':
- case '\'': {
- mSTRING_LITERAL(true);
- theRetToken = _returnToken;
+ case '"':
+ case '\'': {
+ mSTRING_LITERAL(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '[': {
- mLBRACKET(true);
- theRetToken = _returnToken;
+ case '[': {
+ mLBRACKET(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case ']': {
- mRBRACKET(true);
- theRetToken = _returnToken;
+ case ']': {
+ mRBRACKET(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '(': {
- mLPAREN(true);
- theRetToken = _returnToken;
+ case '(': {
+ mLPAREN(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case ')': {
- mRPAREN(true);
- theRetToken = _returnToken;
+ case ')': {
+ mRPAREN(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '*': {
- mTHIS(true);
- theRetToken = _returnToken;
+ case '*': {
+ mTHIS(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '.':
- case '_':
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z': {
- mIDENTIFIER(true);
- theRetToken = _returnToken;
+ case '.':
+ case '_':
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': {
+ mIDENTIFIER(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '=': {
- mEQUALSIGN(true);
- theRetToken = _returnToken;
+ case '=': {
+ mEQUALSIGN(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- case '!': {
- mNOTEQUALSIGN(true);
- theRetToken = _returnToken;
+ case '!': {
+ mNOTEQUALSIGN(true);
+ theRetToken = _returnToken;
- break;
- }
+ break;
+ }
- default:
+ default:
- if ((LA(1) == '0') && (LA(2) == 'x')) {
- mHEX_LITERAL(true);
- theRetToken = _returnToken;
- } else if ((LA(1) == '<') && (LA(2) == '=')) {
- mLESSEQUALSIGN(true);
- theRetToken = _returnToken;
- } else if ((LA(1) == '>') && (LA(2) == '=')) {
- mGREATEREQUALSIGN(true);
- theRetToken = _returnToken;
- } else if ((LA(1) == '0') && (true)) {
- mOCTAL_LITERAL(true);
- theRetToken = _returnToken;
- } else if ((LA(1) == '<') && (true)) {
- mLESSTHANSIGN(true);
- theRetToken = _returnToken;
- } else if ((LA(1) == '>') && (true)) {
- mGREATERTHANSIGN(true);
- theRetToken = _returnToken;
+ if ((LA(1) == '0') && (LA(2) == 'x')) {
+ mHEX_LITERAL(true);
+ theRetToken = _returnToken;
+ } else if ((LA(1) == '<') && (LA(2) == '=')) {
+ mLESSEQUALSIGN(true);
+ theRetToken = _returnToken;
+ } else if ((LA(1) == '>') && (LA(2) == '=')) {
+ mGREATEREQUALSIGN(true);
+ theRetToken = _returnToken;
+ } else if ((LA(1) == '0') && (true)) {
+ mOCTAL_LITERAL(true);
+ theRetToken = _returnToken;
+ } else if ((LA(1) == '<') && (true)) {
+ mLESSTHANSIGN(true);
+ theRetToken = _returnToken;
+ } else if ((LA(1) == '>') && (true)) {
+ mGREATERTHANSIGN(true);
+ theRetToken = _returnToken;
+ } else {
+ if (LA(1) == EOF_CHAR) {
+ uponEOF();
+ _returnToken = makeToken(Token.EOF_TYPE);
} else {
- if (LA(1) == EOF_CHAR) {
- uponEOF();
- _returnToken = makeToken(Token.EOF_TYPE);
- } else {
- throw new NoViableAltForCharException((char) LA(
- 1), getFilename(), getLine(),
- getColumn());
- }
+ throw new NoViableAltForCharException((char) LA(
+ 1), getFilename(), getLine(),
+ getColumn());
}
+ }
}
if (_returnToken == null) {
@@ -238,12 +239,10 @@
_returnToken.setType(_ttype);
return _returnToken;
- }
- catch (RecognitionException e) {
+ } catch (RecognitionException e) {
throw new TokenStreamRecognitionException(e);
}
- }
- catch (CharStreamException cse) {
+ } catch (CharStreamException cse) {
if (cse instanceof CharStreamIOException) {
throw new TokenStreamIOException(((CharStreamIOException) cse).io);
} else {
@@ -254,8 +253,7 @@
}
public final void mWS(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -267,46 +265,45 @@
{
int _cnt15 = 0;
- _loop15:
+_loop15:
do {
switch (LA(1)) {
- case ' ': {
- match(' ');
+ case ' ': {
+ match(' ');
- break;
- }
+ break;
+ }
- case '\t': {
- match('\t');
+ case '\t': {
+ match('\t');
- break;
- }
+ break;
+ }
- case '\n': {
- match('\n');
+ case '\n': {
+ match('\n');
- break;
- }
+ break;
+ }
- case '\r': {
- match('\r');
+ case '\r': {
+ match('\r');
- break;
- }
+ break;
+ }
- default: {
- if (_cnt15 >= 1) {
- break _loop15;
- } else {
- throw new NoViableAltForCharException((char) LA(1),
- getFilename(), getLine(), getColumn());
- }
+ default: {
+ if (_cnt15 >= 1) {
+ break _loop15;
+ } else {
+ throw new NoViableAltForCharException((char) LA(1),
+ getFilename(), getLine(), getColumn());
}
}
+ }
_cnt15++;
- }
- while (true);
+ } while (true);
}
_ttype = Token.SKIP;
@@ -321,8 +318,7 @@
}
public final void mDECIMAL_LITERAL(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -332,40 +328,37 @@
int _saveIndex;
switch (LA(1)) {
- case '-': {
- match('-');
+ case '-': {
+ match('-');
- break;
- }
+ break;
+ }
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- break;
-
- default:
- throw new NoViableAltForCharException((char) LA(1),
- getFilename(),
- getLine(),
- getColumn());
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ break;
+
+ default:
+ throw new NoViableAltForCharException((char) LA(1), getFilename(),
+ getLine(), getColumn());
}
matchRange('1', '9');
- _loop20:
+_loop20:
do {
if ((((LA(1) >= '0') && (LA(1) <= '9')))) {
matchRange('0', '9');
} else {
break _loop20;
}
- }
- while (true);
+ } while (true);
if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
_token = makeToken(_ttype);
@@ -377,8 +370,7 @@
}
public final void mHEX_LITERAL(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -393,48 +385,47 @@
{
int _cnt23 = 0;
- _loop23:
+_loop23:
do {
switch (LA(1)) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': {
- matchRange('0', '9');
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': {
+ matchRange('0', '9');
- break;
- }
+ break;
+ }
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f': {
- matchRange('a', 'f');
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f': {
+ matchRange('a', 'f');
- break;
- }
+ break;
+ }
- default: {
- if (_cnt23 >= 1) {
- break _loop23;
- } else {
- throw new NoViableAltForCharException((char) LA(1),
- getFilename(), getLine(), getColumn());
- }
+ default: {
+ if (_cnt23 >= 1) {
+ break _loop23;
+ } else {
+ throw new NoViableAltForCharException((char) LA(1),
+ getFilename(), getLine(), getColumn());
}
}
+ }
_cnt23++;
- }
- while (true);
+ } while (true);
}
if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
@@ -447,8 +438,7 @@
}
public final void mOCTAL_LITERAL(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -458,15 +448,14 @@
int _saveIndex;
match('0');
- _loop26:
+_loop26:
do {
if ((((LA(1) >= '0') && (LA(1) <= '7')))) {
matchRange('0', '7');
} else {
break _loop26;
}
- }
- while (true);
+ } while (true);
if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
_token = makeToken(_ttype);
@@ -478,8 +467,7 @@
}
public final void mSTRING_LITERAL(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -489,75 +477,65 @@
int _saveIndex;
switch (LA(1)) {
- case '\'': {
- match('\'');
+ case '\'': {
+ match('\'');
- {
- int _cnt30 = 0;
+ {
+ int _cnt30 = 0;
- _loop30:
- do {
- if ((_tokenSet_0.member(LA(1)))) {
- matchNot('\'');
+_loop30:
+ do {
+ if ((_tokenSet_0.member(LA(1)))) {
+ matchNot('\'');
+ } else {
+ if (_cnt30 >= 1) {
+ break _loop30;
} else {
- if (_cnt30 >= 1) {
- break _loop30;
- } else {
- throw new NoViableAltForCharException((char) LA(
- 1),
- getFilename(),
- getLine(),
- getColumn());
- }
+ throw new NoViableAltForCharException((char) LA(1),
+ getFilename(), getLine(), getColumn());
}
-
- _cnt30++;
}
- while (true);
- }
- match('\'');
-
- break;
+ _cnt30++;
+ } while (true);
}
- case '"': {
- match('\"');
+ match('\'');
+
+ break;
+ }
+
+ case '"': {
+ match('\"');
- {
- int _cnt33 = 0;
+ {
+ int _cnt33 = 0;
- _loop33:
- do {
- if ((_tokenSet_1.member(LA(1)))) {
- matchNot('\"');
+_loop33:
+ do {
+ if ((_tokenSet_1.member(LA(1)))) {
+ matchNot('\"');
+ } else {
+ if (_cnt33 >= 1) {
+ break _loop33;
} else {
- if (_cnt33 >= 1) {
- break _loop33;
- } else {
- throw new NoViableAltForCharException((char) LA(
- 1),
- getFilename(),
- getLine(),
- getColumn());
- }
+ throw new NoViableAltForCharException((char) LA(1),
+ getFilename(), getLine(), getColumn());
}
-
- _cnt33++;
}
- while (true);
- }
-
- match('\"');
- break;
+ _cnt33++;
+ } while (true);
}
- default:
- throw new NoViableAltForCharException((char) LA(1),
- getFilename(),
- getLine(),
- getColumn());
+ match('\"');
+
+ break;
+ }
+
+ default:
+ throw new NoViableAltForCharException((char) LA(1), getFilename(),
+ getLine(), getColumn());
}
if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
@@ -570,8 +548,7 @@
}
public final void mLBRACKET(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -592,8 +569,7 @@
}
public final void mRBRACKET(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -614,8 +590,7 @@
}
public final void mLPAREN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -636,8 +611,7 @@
}
public final void mRPAREN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -658,8 +632,7 @@
}
public final void mTHIS(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -680,8 +653,7 @@
}
public final void mIDENTIFIER(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -691,133 +663,130 @@
int _saveIndex;
switch (LA(1)) {
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z': {
- matchRange('a', 'z');
-
- break;
- }
-
- case '.': {
- match('.');
-
- break;
- }
-
- case '_': {
- match('_');
-
- break;
- }
-
- default:
- throw new NoViableAltForCharException((char) LA(1),
- getFilename(),
- getLine(),
- getColumn());
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': {
+ matchRange('a', 'z');
+
+ break;
+ }
+
+ case '.': {
+ match('.');
+
+ break;
+ }
+
+ case '_': {
+ match('_');
+
+ break;
+ }
+
+ default:
+ throw new NoViableAltForCharException((char) LA(1), getFilename(),
+ getLine(), getColumn());
}
{
int _cnt42 = 0;
- _loop42:
+_loop42:
do {
switch (LA(1)) {
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z': {
- matchRange('a', 'z');
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': {
+ matchRange('a', 'z');
- break;
- }
+ break;
+ }
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': {
- matchRange('0', '9');
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': {
+ matchRange('0', '9');
- break;
- }
+ break;
+ }
- case '.': {
- match('.');
+ case '.': {
+ match('.');
- break;
- }
+ break;
+ }
- case '_': {
- match('_');
+ case '_': {
+ match('_');
- break;
- }
+ break;
+ }
- default: {
- if (_cnt42 >= 1) {
- break _loop42;
- } else {
- throw new NoViableAltForCharException((char) LA(1),
- getFilename(), getLine(), getColumn());
- }
+ default: {
+ if (_cnt42 >= 1) {
+ break _loop42;
+ } else {
+ throw new NoViableAltForCharException((char) LA(1),
+ getFilename(), getLine(), getColumn());
}
}
+ }
_cnt42++;
- }
- while (true);
+ } while (true);
}
if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
@@ -830,8 +799,7 @@
}
public final void mEQUALSIGN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -853,8 +821,7 @@
}
public final void mNOTEQUALSIGN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -876,8 +843,7 @@
}
public final void mLESSTHANSIGN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -898,8 +864,7 @@
}
public final void mGREATERTHANSIGN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -920,8 +885,7 @@
}
public final void mLESSEQUALSIGN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -943,8 +907,7 @@
}
public final void mGREATEREQUALSIGN(boolean _createToken)
- throws RecognitionException, CharStreamException,
- TokenStreamException {
+ throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
@@ -966,13 +929,13 @@
}
private static final long[] mk_tokenSet_0() {
- long[] data = {8358512713185371648L, 576460746532061184L, 0L, 0L};
+ long[] data = { 8358512713185371648L, 576460746532061184L, 0L, 0L };
return data;
}
private static final long[] mk_tokenSet_1() {
- long[] data = {8358513245761316352L, 576460746532061184L, 0L, 0L};
+ long[] data = { 8358513245761316352L, 576460746532061184L, 0L, 0L };
return data;
}
Modified: struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenParser.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenParser.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenParser.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/validwhen/ValidWhenParser.java Thu Feb 9 06:11:07 2006
@@ -26,21 +26,22 @@
import antlr.TokenStream;
import antlr.TokenStreamException;
import antlr.collections.impl.BitSet;
+
import org.apache.commons.validator.util.ValidatorUtils;
import java.util.Stack;
public class ValidWhenParser extends antlr.LLkParser
- implements ValidWhenParserTokenTypes {
- public static final String[] _tokenNames = {
+ implements ValidWhenParserTokenTypes {
+ public static final String[] _tokenNames =
+ {
"<0>", "EOF", "<2>", "NULL_TREE_LOOKAHEAD", "DECIMAL_LITERAL",
"HEX_LITERAL", "OCTAL_LITERAL", "STRING_LITERAL", "IDENTIFIER",
"LBRACKET", "RBRACKET", "\"null\"", "THIS", "LPAREN", "RPAREN",
"\"and\"", "\"or\"", "EQUALSIGN", "GREATERTHANSIGN",
- "GREATEREQUALSIGN", "LESSTHANSIGN", "LESSEQUALSIGN",
- "NOTEQUALSIGN",
+ "GREATEREQUALSIGN", "LESSTHANSIGN", "LESSEQUALSIGN", "NOTEQUALSIGN",
"WS"
- };
+ };
public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
Stack argStack = new Stack();
@@ -112,23 +113,22 @@
}
switch (((Integer) compare).intValue()) {
- case LESS_EQUAL:
- case GREATER_THAN:
- case LESS_THAN:
- case GREATER_EQUAL:
- return false;
+ case LESS_EQUAL:
+ case GREATER_THAN:
+ case LESS_THAN:
+ case GREATER_EQUAL:
+ return false;
- case EQUAL:
- return (v1 == v2);
+ case EQUAL:
+ return (v1 == v2);
- case NOT_EQUAL:
- return (v1 != v2);
+ case NOT_EQUAL:
+ return (v1 != v2);
}
}
if ((Integer.class.isInstance(v1) || String.class.isInstance(v1))
- && (Integer.class.isInstance(v2) || String.class
- .isInstance(v2))) {
+ && (Integer.class.isInstance(v2) || String.class.isInstance(v2))) {
intCompare = true;
} else {
intCompare = false;
@@ -152,26 +152,25 @@
}
switch (((Integer) compare).intValue()) {
- case LESS_EQUAL:
- return (v1i <= v2i);
+ case LESS_EQUAL:
+ return (v1i <= v2i);
- case LESS_THAN:
- return (v1i < v2i);
+ case LESS_THAN:
+ return (v1i < v2i);
- case EQUAL:
- return (v1i == v2i);
+ case EQUAL:
+ return (v1i == v2i);
- case GREATER_THAN:
- return (v1i > v2i);
+ case GREATER_THAN:
+ return (v1i > v2i);
- case GREATER_EQUAL:
- return (v1i >= v2i);
+ case GREATER_EQUAL:
+ return (v1i >= v2i);
- case NOT_EQUAL:
- return (v1i != v2i);
+ case NOT_EQUAL:
+ return (v1i != v2i);
}
- }
- catch (NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
; // do nothing
}
@@ -196,66 +195,66 @@
int res = v1s.compareTo(v2s);
switch (((Integer) compare).intValue()) {
- case LESS_EQUAL:
- return (res <= 0);
+ case LESS_EQUAL:
+ return (res <= 0);
- case LESS_THAN:
- return (res < 0);
+ case LESS_THAN:
+ return (res < 0);
- case EQUAL:
- return (res == 0);
+ case EQUAL:
+ return (res == 0);
- case GREATER_THAN:
- return (res > 0);
+ case GREATER_THAN:
+ return (res > 0);
- case GREATER_EQUAL:
- return (res >= 0);
+ case GREATER_EQUAL:
+ return (res >= 0);
- case NOT_EQUAL:
- return (res != 0);
+ case NOT_EQUAL:
+ return (res != 0);
}
return true;
}
public final void integer()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
Token d = null;
Token h = null;
Token o = null;
switch (LA(1)) {
- case DECIMAL_LITERAL: {
- d = LT(1);
- match(DECIMAL_LITERAL);
- argStack.push(Integer.decode(d.getText()));
+ case DECIMAL_LITERAL: {
+ d = LT(1);
+ match(DECIMAL_LITERAL);
+ argStack.push(Integer.decode(d.getText()));
- break;
- }
+ break;
+ }
- case HEX_LITERAL: {
- h = LT(1);
- match(HEX_LITERAL);
- argStack.push(Integer.decode(h.getText()));
+ case HEX_LITERAL: {
+ h = LT(1);
+ match(HEX_LITERAL);
+ argStack.push(Integer.decode(h.getText()));
- break;
- }
+ break;
+ }
- case OCTAL_LITERAL: {
- o = LT(1);
- match(OCTAL_LITERAL);
- argStack.push(Integer.decode(o.getText()));
+ case OCTAL_LITERAL: {
+ o = LT(1);
+ match(OCTAL_LITERAL);
+ argStack.push(Integer.decode(o.getText()));
- break;
- }
+ break;
+ }
- default:
- throw new NoViableAltException(LT(1), getFilename());
+ default:
+ throw new NoViableAltException(LT(1), getFilename());
}
}
public final void string()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
Token str = null;
str = LT(1);
@@ -264,7 +263,7 @@
}
public final void identifier()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
Token str = null;
str = LT(1);
@@ -273,10 +272,9 @@
}
public final void field()
- throws RecognitionException, TokenStreamException {
- if ((LA(1) == IDENTIFIER) && (LA(2) == LBRACKET)
- && (LA(3) == RBRACKET)
- && (LA(4) == IDENTIFIER)) {
+ throws RecognitionException, TokenStreamException {
+ if ((LA(1) == IDENTIFIER) && (LA(2) == LBRACKET) && (LA(3) == RBRACKET)
+ && (LA(4) == IDENTIFIER)) {
identifier();
match(LBRACKET);
match(RBRACKET);
@@ -288,8 +286,8 @@
argStack.push(ValidatorUtils.getValueAsString(form,
i1 + "[" + index + "]" + i2));
} else if ((LA(1) == IDENTIFIER) && (LA(2) == LBRACKET)
- && ((LA(3) >= DECIMAL_LITERAL) && (LA(3) <= OCTAL_LITERAL))
- && (LA(4) == RBRACKET) && (LA(5) == IDENTIFIER)) {
+ && ((LA(3) >= DECIMAL_LITERAL) && (LA(3) <= OCTAL_LITERAL))
+ && (LA(4) == RBRACKET) && (LA(5) == IDENTIFIER)) {
identifier();
match(LBRACKET);
integer();
@@ -303,8 +301,8 @@
argStack.push(ValidatorUtils.getValueAsString(form,
i3 + "[" + i4 + "]" + i5));
} else if ((LA(1) == IDENTIFIER) && (LA(2) == LBRACKET)
- && ((LA(3) >= DECIMAL_LITERAL) && (LA(3) <= OCTAL_LITERAL))
- && (LA(4) == RBRACKET) && (LA(5) == LBRACKET)) {
+ && ((LA(3) >= DECIMAL_LITERAL) && (LA(3) <= OCTAL_LITERAL))
+ && (LA(4) == RBRACKET) && (LA(5) == LBRACKET)) {
identifier();
match(LBRACKET);
integer();
@@ -317,7 +315,7 @@
argStack.push(ValidatorUtils.getValueAsString(form,
i6 + "[" + i7 + "]"));
} else if ((LA(1) == IDENTIFIER) && (LA(2) == LBRACKET)
- && (LA(3) == RBRACKET) && (_tokenSet_0.member(LA(4)))) {
+ && (LA(3) == RBRACKET) && (_tokenSet_0.member(LA(4)))) {
identifier();
match(LBRACKET);
match(RBRACKET);
@@ -338,74 +336,73 @@
}
public final void literal()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
switch (LA(1)) {
- case DECIMAL_LITERAL:
- case HEX_LITERAL:
- case OCTAL_LITERAL: {
- integer();
+ case DECIMAL_LITERAL:
+ case HEX_LITERAL:
+ case OCTAL_LITERAL: {
+ integer();
- break;
- }
+ break;
+ }
- case STRING_LITERAL: {
- string();
+ case STRING_LITERAL: {
+ string();
- break;
- }
+ break;
+ }
- case LITERAL_null: {
- match(LITERAL_null);
- argStack.push(null);
+ case LITERAL_null: {
+ match(LITERAL_null);
+ argStack.push(null);
- break;
- }
+ break;
+ }
- case THIS: {
- match(THIS);
- argStack.push(value);
+ case THIS: {
+ match(THIS);
+ argStack.push(value);
- break;
- }
+ break;
+ }
- default:
- throw new NoViableAltException(LT(1), getFilename());
+ default:
+ throw new NoViableAltException(LT(1), getFilename());
}
}
public final void value()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
switch (LA(1)) {
- case IDENTIFIER: {
- field();
+ case IDENTIFIER: {
+ field();
- break;
- }
+ break;
+ }
- case DECIMAL_LITERAL:
- case HEX_LITERAL:
- case OCTAL_LITERAL:
- case STRING_LITERAL:
- case LITERAL_null:
- case THIS: {
- literal();
+ case DECIMAL_LITERAL:
+ case HEX_LITERAL:
+ case OCTAL_LITERAL:
+ case STRING_LITERAL:
+ case LITERAL_null:
+ case THIS: {
+ literal();
- break;
- }
+ break;
+ }
- default:
- throw new NoViableAltException(LT(1), getFilename());
+ default:
+ throw new NoViableAltException(LT(1), getFilename());
}
}
public final void expression()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
expr();
match(Token.EOF_TYPE);
}
- public final void expr()
- throws RecognitionException, TokenStreamException {
+ public final void expr() throws RecognitionException, TokenStreamException {
if ((LA(1) == LPAREN) && (_tokenSet_1.member(LA(2)))) {
match(LPAREN);
comparisonExpression();
@@ -420,7 +417,7 @@
}
public final void comparisonExpression()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
value();
comparison();
value();
@@ -433,7 +430,7 @@
}
public final void joinedExpression()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
expr();
join();
expr();
@@ -443,94 +440,91 @@
Boolean v2 = (Boolean) argStack.pop();
if (join.intValue() == AND) {
- argStack.push(new Boolean(
- v1.booleanValue() && v2.booleanValue()));
+ argStack.push(new Boolean(v1.booleanValue() && v2.booleanValue()));
} else {
- argStack.push(new Boolean(
- v1.booleanValue() || v2.booleanValue()));
+ argStack.push(new Boolean(v1.booleanValue() || v2.booleanValue()));
}
}
- public final void join()
- throws RecognitionException, TokenStreamException {
+ public final void join() throws RecognitionException, TokenStreamException {
switch (LA(1)) {
- case ANDSIGN: {
- match(ANDSIGN);
- argStack.push(new Integer(AND));
+ case ANDSIGN: {
+ match(ANDSIGN);
+ argStack.push(new Integer(AND));
- break;
- }
+ break;
+ }
- case ORSIGN: {
- match(ORSIGN);
- argStack.push(new Integer(OR));
+ case ORSIGN: {
+ match(ORSIGN);
+ argStack.push(new Integer(OR));
- break;
- }
+ break;
+ }
- default:
- throw new NoViableAltException(LT(1), getFilename());
+ default:
+ throw new NoViableAltException(LT(1), getFilename());
}
}
public final void comparison()
- throws RecognitionException, TokenStreamException {
+ throws RecognitionException, TokenStreamException {
switch (LA(1)) {
- case EQUALSIGN: {
- match(EQUALSIGN);
- argStack.push(new Integer(EQUAL));
+ case EQUALSIGN: {
+ match(EQUALSIGN);
+ argStack.push(new Integer(EQUAL));
- break;
- }
+ break;
+ }
- case GREATERTHANSIGN: {
- match(GREATERTHANSIGN);
- argStack.push(new Integer(GREATER_THAN));
+ case GREATERTHANSIGN: {
+ match(GREATERTHANSIGN);
+ argStack.push(new Integer(GREATER_THAN));
- break;
- }
+ break;
+ }
- case GREATEREQUALSIGN: {
- match(GREATEREQUALSIGN);
- argStack.push(new Integer(GREATER_EQUAL));
+ case GREATEREQUALSIGN: {
+ match(GREATEREQUALSIGN);
+ argStack.push(new Integer(GREATER_EQUAL));
- break;
- }
+ break;
+ }
- case LESSTHANSIGN: {
- match(LESSTHANSIGN);
- argStack.push(new Integer(LESS_THAN));
+ case LESSTHANSIGN: {
+ match(LESSTHANSIGN);
+ argStack.push(new Integer(LESS_THAN));
- break;
- }
+ break;
+ }
- case LESSEQUALSIGN: {
- match(LESSEQUALSIGN);
- argStack.push(new Integer(LESS_EQUAL));
+ case LESSEQUALSIGN: {
+ match(LESSEQUALSIGN);
+ argStack.push(new Integer(LESS_EQUAL));
- break;
- }
+ break;
+ }
- case NOTEQUALSIGN: {
- match(NOTEQUALSIGN);
- argStack.push(new Integer(NOT_EQUAL));
+ case NOTEQUALSIGN: {
+ match(NOTEQUALSIGN);
+ argStack.push(new Integer(NOT_EQUAL));
- break;
- }
+ break;
+ }
- default:
- throw new NoViableAltException(LT(1), getFilename());
+ default:
+ throw new NoViableAltException(LT(1), getFilename());
}
}
private static final long[] mk_tokenSet_0() {
- long[] data = {8273920L, 0L};
+ long[] data = { 8273920L, 0L };
return data;
}
private static final long[] mk_tokenSet_1() {
- long[] data = {6640L, 0L};
+ long[] data = { 6640L, 0L };
return data;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org