org.efaps.number2words.converters
Class AbstractDecimalConverter

java.lang.Object
  extended by org.efaps.number2words.converters.AbstractDecimalConverter
All Implemented Interfaces:
IConverter
Direct Known Subclasses:
English, German, Spanish

public abstract class AbstractDecimalConverter
extends java.lang.Object
implements IConverter

Abstract helper class which implements the main methods for the conversion of numbers to words for languages which uses the decimal system.

Version:
$Id: AbstractDecimalConverter.java 2699 2009-06-27 12:58:51Z tim.moxter $
Author:
The eFaps Team

Constructor Summary
AbstractDecimalConverter()
           
 
Method Summary
 java.lang.String convert(long _number)
          Method to convert a number into words.
protected abstract  java.lang.String convertLessThanOneHundred(int _number)
          The method converts the numbers from 1 to 99 into words.
protected  java.lang.String convertLessThanOneThousand(int _number)
          Method to convert the numbers from 1 to 999.
protected  java.lang.String convertPower(int _number, int _power)
          The method converts the given _number depending on the _power to words.
protected abstract  java.lang.String getMinus()
          Returns the language specific word for "minus".
protected abstract  java.lang.String[] getNumNames()
          Returns the string array to define the conversion of numbers for 1 till 19.
protected abstract  java.lang.String[] getPowerNames()
          Returns the string array for power numbers 1000^n.
protected abstract  java.lang.String[] getTensNames()
          Returns the string array for a zero length string and the words for numbers 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100.
protected abstract  java.lang.String getZero()
          Returns the language specific word for the number 0.
 boolean isDecimal()
          The abstract class helps to implement converters for languages which are using the decimal system.
 boolean usesShortScale()
          A false is returned because typically a language should use the long scale numerical system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDecimalConverter

public AbstractDecimalConverter()
Method Detail

convertLessThanOneThousand

protected java.lang.String convertLessThanOneThousand(int _number)
Method to convert the numbers from 1 to 999. The last to digits (_number modular 100) are converted to words with convertLessThanOneHundred(int) so that some special kinds for languages could be easy implemented.

Parameters:
_number - number less than one thousand to be converted
Returns:
return words for number
See Also:
convertLessThanOneHundred(int)

convertLessThanOneHundred

protected abstract java.lang.String convertLessThanOneHundred(int _number)
The method converts the numbers from 1 to 99 into words. The method is used from convertLessThanOneThousand(int).

Parameters:
_number - number less than one hundred to convert
Returns:
converted _number in words

getNumNames

protected abstract java.lang.String[] getNumNames()
Returns the string array to define the conversion of numbers for 1 till 19.

Returns:
string array of numbers

getTensNames

protected abstract java.lang.String[] getTensNames()
Returns the string array for a zero length string and the words for numbers 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100.

Returns:
string array of tens names

getPowerNames

protected abstract java.lang.String[] getPowerNames()
Returns the string array for power numbers 1000^n. The translated word values must be defined in this order:

Returns:
string array of power numbers

getZero

protected abstract java.lang.String getZero()
Returns the language specific word for the number 0.

Returns:
string for the number 0

getMinus

protected abstract java.lang.String getMinus()
Returns the language specific word for "minus". The word is needed to convert negative numbers.

Returns:
language specific wording for minus

convertPower

protected java.lang.String convertPower(int _number,
                                        int _power)
The method converts the given _number depending on the _power to words. The real number to convert is "_number * (10 ^ _power)".

Parameters:
_number - number to convert
_power - power of the number
Returns:
converted string

convert

public java.lang.String convert(long _number)
Method to convert a number into words.

Specified by:
convert in interface IConverter
Parameters:
_number - number to convert
Returns:
words representing the number
See Also:
IConverter.convert(long), FORMAT_MASK

isDecimal

public boolean isDecimal()
The abstract class helps to implement converters for languages which are using the decimal system. Therefore the method always returns true.

Specified by:
isDecimal in interface IConverter
Returns:
always true

usesShortScale

public boolean usesShortScale()
A false is returned because typically a language should use the long scale numerical system.

Specified by:
usesShortScale in interface IConverter
Returns:
always false
See Also:
IConverter.isDecimal()


Copyright © 2009 eFaps. All Rights Reserved.