Qizx fe-4.4p2 API

com.qizx.api.util.text
Class FormatNumberSieve

java.lang.Object
  extended by com.qizx.api.util.text.SieveBase
      extended by com.qizx.api.util.text.FormatNumberSieve
All Implemented Interfaces:
Indexing.NumberSieve, Indexing.Sieve

public class FormatNumberSieve
extends SieveBase
implements Indexing.NumberSieve

Converts a number using a Java NumberFormat.


Field Summary
static String FORMAT
          Name of the parameter used for specifying the format of recognized number values.
static String LOCALE
          Name of the parameter used for specifying the locale of parsed dates.
 
Constructor Summary
FormatNumberSieve()
          Constructs a sieve that recognizes a number in US format.
FormatNumberSieve(String decimalFormat)
          Constructs a sieve that recognizes a particular Decimal format.
 
Method Summary
 double convert(String value)
          Attempts to convert the text fragment to a double value.
 String getFormat()
          Returns the currently used Date Format.
 void setFormat(String numberFormat, Locale locale)
          Sets the format used.
 void setParameters(String[] parameters)
          Defines optional parameters for the sieve.
 
Methods inherited from class com.qizx.api.util.text.SieveBase
addParameter, getParameters, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.qizx.api.Indexing.Sieve
getParameters
 

Field Detail

FORMAT

public static final String FORMAT
Name of the parameter used for specifying the format of recognized number values. The value of the parameter must be accepted by DecimalFormat.

See Also:
Constant Field Values

LOCALE

public static final String LOCALE
Name of the parameter used for specifying the locale of parsed dates. The value of this parameter can be of different forms (the dash separator can also be replaced by an underscore):

See Also:
Constant Field Values
Constructor Detail

FormatNumberSieve

public FormatNumberSieve()
Constructs a sieve that recognizes a number in US format.


FormatNumberSieve

public FormatNumberSieve(String decimalFormat)
Constructs a sieve that recognizes a particular Decimal format.

Parameters:
decimalFormat - a format accepted by DecimalFormat
Method Detail

setParameters

public void setParameters(String[] parameters)
                   throws DataModelException
Description copied from interface: Indexing.Sieve
Defines optional parameters for the sieve.

Specified by:
setParameters in interface Indexing.Sieve
Parameters:
parameters - an array of even size containing alternately a parameter name and a parameter value.
Throws:
DataModelException - if the option is unknown or the value is invalid.

setFormat

public void setFormat(String numberFormat,
                      Locale locale)
Sets the format used. Convenience method equivalent to setting parameter "format".

Parameters:
numberFormat - a format accepted by DecimalFormat
locale - if not null, the format is adapted to this locale

getFormat

public String getFormat()
Returns the currently used Date Format.

Returns:
the currently used Date Format.

convert

public double convert(String value)
Description copied from interface: Indexing.NumberSieve
Attempts to convert the text fragment to a double value.

Specified by:
convert in interface Indexing.NumberSieve
Parameters:
value - an alleged numeric value in text form.
Returns:
the converted value, or NaN if the conversion is not possible. Should raise no exception

© 2010 Axyana Software