org.scopemvc.util.convertor
Class NumberStringConvertor

java.lang.Object
  |
  +--org.scopemvc.util.convertor.NullStringConvertor
        |
        +--org.scopemvc.util.convertor.NumberStringConvertor
All Implemented Interfaces:
StringConvertor
Direct Known Subclasses:
BigIntegerStringConvertor, DoubleStringConvertor, FloatStringConvertor, IntegerStringConvertor, LongStringConvertor

public abstract class NumberStringConvertor
extends NullStringConvertor

Abstract base class for numeric StringConvertors.

It uses default java.text.Number format. New format can be set.

Version:
$Revision: 1.5 $ $Date: 2002/09/05 15:41:47 $
Author:
Daniel Michalik

Constructor Summary
NumberStringConvertor()
          Creates new NumberStringConvertor with default platform number format.
 
Method Summary
 java.text.NumberFormat getNumberFormat()
           
 void setNumberFormat(java.text.NumberFormat inFormat)
           
 java.lang.Object stringAsValue(java.lang.String inString)
          Returns instance of some subclass of Number as returned by NumberFormat.
 java.lang.String valueAsString(java.lang.Object inValue)
          Formats object into String.
 
Methods inherited from class org.scopemvc.util.convertor.NullStringConvertor
getNullAsString, isNull, setNullAsString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberStringConvertor

public NumberStringConvertor()
Creates new NumberStringConvertor with default platform number format.

See Also:
NumberFormat.getInstance()
Method Detail

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Returns:
a instance of format used in this convertor. The value is never null.

setNumberFormat

public void setNumberFormat(java.text.NumberFormat inFormat)
                     throws java.lang.IllegalArgumentException
Parameters:
inFormat - The new numberFormat value
Throws:
java.lang.IllegalArgumentException - if passed format is null.

stringAsValue

public java.lang.Object stringAsValue(java.lang.String inString)
                               throws java.lang.IllegalArgumentException
Returns instance of some subclass of Number as returned by NumberFormat. If there is required specific numeric class, corresponding XXXStringConvertor should be used. Subclasses use this method and result converts to proper type.

Empty, null and getNullAsString() strings are converted into null.

Parameters:
inString - TODO: Describe the Parameter
Returns:
TODO: Describe the Return Value
Throws:
java.lang.IllegalArgumentException - can't convert from String using current NumberFormat.
See Also:
DoubleStringConvertor, FloatStringConvertor, IntegerStringConvertor, LongStringConvertor

valueAsString

public java.lang.String valueAsString(java.lang.Object inValue)
                               throws java.lang.IllegalArgumentException
Description copied from interface: StringConvertor
Formats object into String. It never return a null. Implementing class can offer posibility to set string representation of null (such as "null" or ""), however default representation should be "". Slightly different null handling is performed in StringStringConvertor class.

Parameters:
inValue - TODO: Describe the Parameter
Returns:
text representation of numeric object. For null argument is called method getNullAsString()
Throws:
java.lang.IllegalArgumentException - when argument is not subclass of java.lang.Number


Copyright © 2000-2002 The Scope Team. All Rights Reserved.