All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.conversions.formatters.NumberFormatter

java.lang.Object
   |
   +----org.xmlmiddleware.conversions.formatters.NumberFormatter

public class NumberFormatter
extends Object
implements StringFormatter
Wraps a NumberFormat in an StringFormatter interface.

This can also be used to wrap subclasses of NumberFormat, such as DecimalFormat.

Version:
2.0
Author:
Ronald Bourret, 2001

Constructor Index

 o NumberFormatter(NumberFormat)

Method Index

 o canConvert(int)
Whether the class can convert to/from a certain type of object.
 o format(Object)
Format an object according to the format used by the underlying NumberFormat object.
 o getNumberFormat()
Get the underlying NumberFormat object.
 o parse(String, int)
Parse a string according to the parse format used by the underlying NumberFormat object.

Constructors

 o NumberFormatter
 public NumberFormatter(NumberFormat formatter)

Methods

 o parse
 public Object parse(String s,
                     int jdbcType) throws XMLMiddlewareException
Parse a string according to the parse format used by the underlying NumberFormat object.

Parameters:
The - string to parse.
A - JDBC Types value indicating the type of object to return.
Returns:
A number. This is a Long if possible; otherwise, it is a Double.
Throws: XMLMiddlewareException
Thrown if the string can't be parsed.
 o format
 public String format(Object o) throws XMLMiddlewareException
Format an object according to the format used by the underlying NumberFormat object.

Parameters:
The - object to serialize. Must be a Long, Integer, Short, Byte, Double, or Float.
Returns:
The string
Throws: XMLMiddlewareException
Thrown if the object is not a Long, Integer, Short, Byte, Double, or Float.
 o canConvert
 public boolean canConvert(int type)
Whether the class can convert to/from a certain type of object.

This method returns true for Types.DOUBLE, FLOAT, REAL, DECIMAL, NUMERIC, BIGINT, INTEGER, SMALLINT, TINYINT, and BIT. It returns false for all other types.

Parameters:
type - The JDBC Types value corresponding to the object type.
Returns:
Whether the type is supported
 o getNumberFormat
 public NumberFormat getNumberFormat()
Get the underlying NumberFormat object.

Returns:
The NumberFormat object.

All Packages  Class Hierarchy  This Package  Previous  Next  Index