Here is a small update to parameterparser. Main things are: * methods for dealing with long and byte datatypes * fixed some stuff in boolean handling * extension to handle the case of form-multipart request. You also need org.apache.turbine.util.FileHandler helper class that handles this: http://nemecec.one.lv/dev/FileHandler.java Any comments welcome. Neeme Index: ParameterParser.java =================================================================== RCS file: /products/cvs/turbine/turbine/src/java/org/apache/turbine/util/Parameter Parser.java,v retrieving revision 1.1.1.1 diff -r1.1.1.1 ParameterParser.java 72a73,75 > // Turbine stuff > import org.apache.turbine.services.resources.TurbineResources; > 92c95 < * @version $Id: ParameterParser.java,v 1.1.1.1 2000/07/19 02:56:52 mbryson Exp $ --- > * @version $Id: ParameterParser.java,v 1.1.1.1 2000/08/04 16:20:11 neeme Exp $ 113a117,130 > if (!FileHandler.isSimpleForm(req)) > { > String fileRepository = TurbineResources.getString( TurbineResources.UPLOAD_PATH_KEY, "."); > FileHandler handler = new FileHandler( req, this, fileRepository ); > handler.setMaxSize( TurbineResources.getLong( TurbineResources.MAX_FILE_SIZE_KEY, 0 ) ); > try > { > handler.saveStream(); > } > catch (Exception e) > { > Log.warn( e.getMessage() ); > } > } 182a200,208 > public void add ( String name, long value ) > { > add ( name, Long.toString(value)); > } > /** > Add a name/value pair into this object. > The reason for using an add() method instead of > Hashtable.put is because things must be in a String[]. > */ 232a259,263 > if ( tmp.equalsIgnoreCase ("0") || > tmp.equalsIgnoreCase ("false") ) > { > value = false; > } 251a283,287 > if ( tmp.equalsIgnoreCase ("0") || > tmp.equalsIgnoreCase ("false") ) > { > value = false; > } 270a307,311 > if ( tmp.equalsIgnoreCase ("0") || > tmp.equalsIgnoreCase ("false") ) > { > value = false; > } 289a331,335 > if ( tmp.equalsIgnoreCase ("0") || > tmp.equalsIgnoreCase ("false") ) > { > value = false; > } 365a412,447 > Return a byte for the given name. If the name does not > exist, return 0. > */ > public byte getByte(String name) > { > byte value = 0; > try > { > Object object = this.get(convert(name)); > if (object != null) > value = Byte.valueOf(((String[])object)[0]).byteValue(); > } > catch (NumberFormatException exception) > { > } > return value; > } > /** > Return an int for the given name. If the name does not > exist, return defaultValue. > */ > public byte getByte(String name, byte defaultValue ) > { > byte value = defaultValue; > try > { > Object object = this.get(convert(name)); > if (object != null) > value = Byte.valueOf(((String[])object)[0]).byteValue(); > } > catch (NumberFormatException exception) > { > } > return value; > } > /** 457a540,573 > Return an array of longs for the given name. If the name does not > exist, return null. > */ > public long[] getLongs(String name) > { > long[] value = null; > Object object = getStrings(convert(name)); > if (object != null) > { > String[] temp = (String[])object; > value = new long[temp.length]; > for (int i=0; i<temp.length; i++) > value[i] = Long.parseLong( temp[i] ); > } > return value; > } > /** > Return an array of Longs for the given name. If the name does not > exist, return null. > */ > public Long[] getLongObjects(String name) > { > Long[] value = null; > Object object = getStrings(convert(name)); > if (object != null) > { > String[] temp = (String[])object; > value = new Long[temp.length]; > for (int i=0; i<temp.length; i++) > value[i] = Long.valueOf( temp[i] ); > } > return value; > } > /** ------------------------------------------------------------ To subscribe: [EMAIL PROTECTED] To unsubscribe: [EMAIL PROTECTED] Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/> Problems?: [EMAIL PROTECTED]
