Added a version of requireParameter() that lets you specify the maximum

length of a parameter.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1206 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2003-08-19 23:39:25 +00:00
parent 4b4bf11074
commit d9731c97c2
@@ -1,5 +1,5 @@
//
// $Id: ParameterUtil.java,v 1.7 2003/08/19 23:09:12 ray Exp $
// $Id: ParameterUtil.java,v 1.8 2003/08/19 23:39:25 ray Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -178,6 +178,19 @@ public class ParameterUtil
return value;
}
/**
* Fetches the supplied parameter from the request and ensures that
* it is no longer than maxLength.
*/
public static String requireParameter (
HttpServletRequest req, String name, String missingDataMessage,
int maxLength)
throws DataValidationException
{
return StringUtil.truncate(
requireParameter(req, name, missingDataMessage), maxLength);
}
/**
* Fetches the supplied parameter from the request and converts it to
* a date. The value of the parameter should be a date formatted like