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

java.lang.Object
  extended by org.apache.cocoon.components.elementprocessor.types.NumericConverter

public class NumericConverter
extends Object

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

Version:
CVS $Id: NumericConverter.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Marc Johnson (marc_johnson27591@hotmail.com)

Method Summary
static NumericResult extractDouble(String value)
          Shortcut for extractDouble without a Validator
static NumericResult extractDouble(String value, Validator validator)
          Given a string that is expected to hold a double, get the double value.
static NumericResult extractInteger(String value)
          Shortcut for extractInteger without a Validator
static NumericResult extractInteger(String value, Validator validator)
          Given a string that is expected to hold a integer, get the integer value.
static NumericResult extractNonNegativeInteger(String value)
          extract a non-negative integer (i.e., an integer with a range of 1 ...
static NumericResult extractPositiveInteger(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(String value)
Shortcut for extractDouble without a Validator

Parameters:
value - the string holding the double
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(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(String value)
Shortcut for extractInteger without a Validator

Parameters:
value - the string holding the integer
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(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(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(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-2010 The Apache Software Foundation. All Rights Reserved.