Qizx fe-4.4p2 API

com.qizx.api.util.text
Class FormatDateSieve

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

public class FormatDateSieve
extends SieveBase
implements Indexing.DateSieve

DateSieve implementation: uses a DateFormat (by default the short format of the default locale.)


Field Summary
static String FORMAT
          Name of the parameter used for specifying the format of recognized date values.
static String LENIENT
          Name of the parameter used for specifying whether the parsing of date values is lenient.
static String LOCALE
          Name of the parameter used for specifying the locale of parsed dates.
static String TIMEZONE
          Name of the parameter used for specifying the default time-zone of parsed dates.
 
Constructor Summary
FormatDateSieve()
          Constructs a sieve that uses the short format of the default locale.
 
Method Summary
 double convert(String value)
          Attempts to convert the date or date-time contained in the text fragment to a double value (in milliseconds from 1970-01-01 00:00:00 UTC).
 String getFormat()
          Returns the currently used Date Format.
 void setFormat(String dateFormat, 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 date values. The value of the parameter must be accepted by DateFormat.

See Also:
Constant Field Values

LENIENT

public static final String LENIENT
Name of the parameter used for specifying whether the parsing of date values is lenient. The value of the parameter must be "true" or "yes" or "false" or "no"

See Also:
Constant Field Values

TIMEZONE

public static final String TIMEZONE
Name of the parameter used for specifying the default time-zone of parsed dates. The value must be suitable for TimeZone.getTimeZone(String).

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

FormatDateSieve

public FormatDateSieve()
Constructs a sieve that uses the short format of the default locale.

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 dateFormat,
                      Locale locale)
Sets the format used. Convenience method equivalent to setting parameter "format".

Parameters:
dateFormat - a format accepted by SimpleDateFormat
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.DateSieve
Attempts to convert the date or date-time contained in the text fragment to a double value (in milliseconds from 1970-01-01 00:00:00 UTC).

Specified by:
convert in interface Indexing.DateSieve
Specified by:
convert in interface Indexing.NumberSieve
Parameters:
value - an alleged date-time value in text form.
Returns:
the converted value, or NaN if the conversion is not possible.

© 2010 Axyana Software