org.apache.cocoon.components.elementprocessor.types
Class NumericConverter

java.lang.Object
  |
  +--org.apache.cocoon.components.elementprocessor.types.NumericConverter

public class NumericConverter
extends java.lang.Object

This class knows how to convert strings into numbers, and also knows how to check the results against certain criteria

Author:
Marc Johnson (marc_johnson27591@hotmail.com)

Method Summary
static NumericResult extractDouble(java.lang.String value)
          Shortcut for extractDouble without a Validator
static NumericResult extractDouble(java.lang.String value, Validator validator)
          Given a string that is expected to hold a double, get the double value.
static NumericResult extractInteger(java.lang.String value)
          Shortcut for extractInteger without a Validator
static NumericResult extractInteger(java.lang.String value, Validator validator)
          Given a string that is expected to hold a integer, get the integer value.
static NumericResult extractNonNegativeInteger(java.lang.String value)
          extract a non-negative integer (i.e., an integer with a range of 1 ...
static NumericResult extractPositiveInteger(java.lang.String value)
          extract a positive integer (i.e., an integer with a range of 1 ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

extractDouble

public static NumericResult extractDouble(java.lang.String value)
Shortcut for extractDouble without a Validator
Parameters:
value - the string holding the double
validator - a Validator object; if null, no additional validation will be performed
Returns:
a NumericResult object containing either the double value or an exception generated if there was a problem with the value;

extractDouble

public static NumericResult extractDouble(java.lang.String value,
                                          Validator validator)
Given a string that is expected to hold a double, get the double value.
Parameters:
value - the string holding the double
validator - a Validator object; if null, no additional validation will be performed
Returns:
a NumericResult object containing either the double value or an exception generated if there was a problem with the value;

extractInteger

public static NumericResult extractInteger(java.lang.String value)
Shortcut for extractInteger without a Validator
Parameters:
value - the string holding the integer
validator - a Validator object; if null, no additional validation will be performed
Returns:
a NumericResult object containing either the integer value or an exception generated if there was a problem with the value;

extractInteger

public static NumericResult extractInteger(java.lang.String value,
                                           Validator validator)
Given a string that is expected to hold a integer, get the integer value.
Parameters:
value - the string holding the integer
validator - a Validator object; if null, no additional validation will be performed
Returns:
a NumericResult object containing either the integer value or an exception generated if there was a problem with the value;

extractPositiveInteger

public static NumericResult extractPositiveInteger(java.lang.String value)
extract a positive integer (i.e., an integer with a range of 1 ... MAX_VALUE)
Parameters:
value - the string holding the value
Returns:
a NumericResult object containing either the integer value or an exception generated if there was a problem with the value;

extractNonNegativeInteger

public static NumericResult extractNonNegativeInteger(java.lang.String value)
extract a non-negative integer (i.e., an integer with a range of 1 ... MAX_VALUE)
Parameters:
value - the string holding the value
Returns:
a NumericResult object containing either the integer value or an exception generated if there was a problem with the value;


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.