Stellent
HowToComponents
JavaDoc

intradoc.common
Class IdcNumberFormat

java.lang.Object
  |
  +--intradoc.common.IdcNumberFormat

public class IdcNumberFormat
extends java.lang.Object


Field Summary
static int FRACTION_FIELD
           
static int INTEGER_FIELD
           
static int MAX_COUNT
          The maximum number of significant digits in an IEEE 754 double, that is, in a Java double.
 
Constructor Summary
IdcNumberFormat()
          Default constructor.
IdcNumberFormat(char decimalSeparator, char groupingSeparator, char zero)
          Create an IdcNumberFormat from the given symbols.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Overrides equals
 java.lang.String format(double number)
           
 java.lang.StringBuffer format(double number, java.lang.StringBuffer result, IdcPosition fieldPosition)
          Formats a double to produce a string.
 java.lang.String format(long number)
           
 java.lang.StringBuffer format(long number, java.lang.StringBuffer result, IdcPosition fieldPosition)
          Format a long to produce a string.
 java.lang.StringBuffer format(java.lang.Object number, java.lang.StringBuffer toAppendTo, IdcPosition pos)
           
 char getDecimalSeparator()
           
 char getGroupingSeparator()
           
 int getGroupingSize()
          Return the grouping size.
 java.lang.String getInfinity()
           
 int getMaximumFractionDigits()
          Returns the maximum number of digits allowed in the fraction portion of a number.
 int getMaximumIntegerDigits()
          Returns the maximum number of digits allowed in the integer portion of a number.
 int getMinimumFractionDigits()
          Returns the minimum number of digits allowed in the fraction portion of a number.
 int getMinimumIntegerDigits()
          Returns the minimum number of digits allowed in the integer portion of a number.
 int getMultiplier()
          Get the multiplier for use in percent, permill, etc.
 java.lang.String getNaN()
           
 java.lang.String getNegativePrefix()
          Get the negative prefix.
 java.lang.String getNegativeSuffix()
          Get the negative suffix.
 java.lang.String getPositivePrefix()
          Get the positive prefix.
 java.lang.String getPositiveSuffix()
          Get the positive suffix.
 char getZeroDigit()
           
 int hashCode()
          Overrides hashCode
 boolean isDecimalSeparatorAlwaysShown()
          Allows you to get the behavior of the decimal separator with integers.
 boolean isGroupingUsed()
          Returns true if grouping is used in this format.
 boolean isParseIntegerOnly()
          Returns true if this format will parse numbers as integers only.
 java.lang.Number parse(java.lang.String text)
           
 java.lang.Number parse(java.lang.String text, ParseStringLocation parsePosition)
          Returns an instance of Number with a value matching the given string.
 void setDecimalSeparator(char c)
           
 void setDecimalSeparatorAlwaysShown(boolean newValue)
          Allows you to set the behavior of the decimal separator with integers.
 void setGroupingSeparator(char c)
           
 void setGroupingSize(int newValue)
          Set the grouping size.
 void setGroupingUsed(boolean newValue)
          Set whether or not grouping will be used in this format.
 void setInfinity(java.lang.String s)
           
 void setMaximumFractionDigits(int newValue)
          Sets the maximum number of digits allowed in the fraction portion of a number.
 void setMaximumIntegerDigits(int newValue)
          Sets the maximum number of digits allowed in the integer portion of a number.
 void setMinimumFractionDigits(int newValue)
          Sets the minimum number of digits allowed in the fraction portion of a number.
 void setMinimumIntegerDigits(int newValue)
          Sets the minimum number of digits allowed in the integer portion of a number.
 void setMultiplier(int newValue)
          Set the multiplier for use in percent, permill, etc.
 void setNaN(java.lang.String s)
           
 void setNegativePrefix(java.lang.String newValue)
          Set the negative prefix.
 void setNegativeSuffix(java.lang.String newValue)
          Set the positive suffix.
 void setParseIntegerOnly(boolean value)
          Sets whether or not numbers should be parsed as integers only.
 void setPositivePrefix(java.lang.String newValue)
          Set the positive prefix.
 void setPositiveSuffix(java.lang.String newValue)
          Set the positive suffix.
 void setZeroDigit(char c)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_COUNT

public static final int MAX_COUNT
The maximum number of significant digits in an IEEE 754 double, that is, in a Java double. This must not be increased, or garbage digits will be generated, and should not be decreased, or accuracy will be lost.

See Also:
Constant Field Values

INTEGER_FIELD

public static final int INTEGER_FIELD
See Also:
Constant Field Values

FRACTION_FIELD

public static final int FRACTION_FIELD
See Also:
Constant Field Values
Constructor Detail

IdcNumberFormat

public IdcNumberFormat()
Default constructor.


IdcNumberFormat

public IdcNumberFormat(char decimalSeparator,
                       char groupingSeparator,
                       char zero)
Create an IdcNumberFormat from the given symbols. Use this constructor when you need to completely customize the behavior of the format.

Throws:
java.lang.IllegalArgumentException - if the given pattern is invalid
See Also:
DecimalFormatSymbols
Method Detail

format

public final java.lang.StringBuffer format(java.lang.Object number,
                                           java.lang.StringBuffer toAppendTo,
                                           IdcPosition pos)

format

public final java.lang.String format(double number)

format

public final java.lang.String format(long number)

format

public java.lang.StringBuffer format(double number,
                                     java.lang.StringBuffer result,
                                     IdcPosition fieldPosition)
Formats a double to produce a string.

Parameters:
number - The double to format
result - Where the text result is appended to.
fieldPosition - On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
The value passed in as the result parameter

format

public java.lang.StringBuffer format(long number,
                                     java.lang.StringBuffer result,
                                     IdcPosition fieldPosition)
Format a long to produce a string.

Parameters:
number - The long to format
result - Where the text result is appended to.
fieldPosition - On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
The value passed in as the result parameter

parse

public java.lang.Number parse(java.lang.String text)
                       throws ParseStringException
ParseStringException

parse

public java.lang.Number parse(java.lang.String text,
                              ParseStringLocation parsePosition)
Returns an instance of Number with a value matching the given string. The most economical subclass that can represent all the bits of the source string is chosen.

Parameters:
text - the string to be parsed
parsePosition - on entry, where to begin parsing; on exit, just past the last parsed character. If parsing fails, the index will not move and the error index will be set.
Returns:
the parsed value, or null if the parse fails

getPositivePrefix

public java.lang.String getPositivePrefix()
Get the positive prefix.

Examples: +123, $123, sFr123


setPositivePrefix

public void setPositivePrefix(java.lang.String newValue)
Set the positive prefix.

Examples: +123, $123, sFr123


getNegativePrefix

public java.lang.String getNegativePrefix()
Get the negative prefix.

Examples: -123, ($123) (with negative suffix), sFr-123


setNegativePrefix

public void setNegativePrefix(java.lang.String newValue)
Set the negative prefix.

Examples: -123, ($123) (with negative suffix), sFr-123


getPositiveSuffix

public java.lang.String getPositiveSuffix()
Get the positive suffix.

Example: 123%


setPositiveSuffix

public void setPositiveSuffix(java.lang.String newValue)
Set the positive suffix.

Example: 123%


getNegativeSuffix

public java.lang.String getNegativeSuffix()
Get the negative suffix.

Examples: -123%, ($123) (with positive suffixes)


setNegativeSuffix

public void setNegativeSuffix(java.lang.String newValue)
Set the positive suffix.

Examples: 123%


getMultiplier

public int getMultiplier()
Get the multiplier for use in percent, permill, etc. For a percentage, set the suffixes to have "%" and the multiplier to be 100. (For Arabic, use arabic percent symbol). For a permill, set the suffixes to have "?" and the multiplier to be 1000.

Examples: with 100, 1.23 -> "123", and "123" -> 1.23


setMultiplier

public void setMultiplier(int newValue)
Set the multiplier for use in percent, permill, etc. For a percentage, set the suffixes to have "%" and the multiplier to be 100. (For Arabic, use arabic percent symbol). For a permill, set the suffixes to have "?" and the multiplier to be 1000.

Examples: with 100, 1.23 -> "123", and "123" -> 1.23


getMaximumIntegerDigits

public int getMaximumIntegerDigits()
Returns the maximum number of digits allowed in the integer portion of a number.

See Also:
setMaximumIntegerDigits(int)

getMinimumIntegerDigits

public int getMinimumIntegerDigits()
Returns the minimum number of digits allowed in the integer portion of a number.

See Also:
setMinimumIntegerDigits(int)

getMaximumFractionDigits

public int getMaximumFractionDigits()
Returns the maximum number of digits allowed in the fraction portion of a number.

See Also:
setMaximumFractionDigits(int)

getMinimumFractionDigits

public int getMinimumFractionDigits()
Returns the minimum number of digits allowed in the fraction portion of a number.

See Also:
setMinimumFractionDigits(int)

setMinimumFractionDigits

public void setMinimumFractionDigits(int newValue)
Sets the minimum number of digits allowed in the fraction portion of a number. m_minimumFractionDigits must be <= m_maximumFractionDigits. If the new value for m_minimumFractionDigits exceeds the current value of m_maximumFractionDigits, then m_maximumIntegerDigits will also be set to the new value

Parameters:
newValue - the minimum number of fraction digits to be shown; if less than zero, then zero is used. The concrete subclass may enforce an upper limit to this value appropriate to the numeric type being formatted.
See Also:
getMinimumFractionDigits()

getGroupingSize

public int getGroupingSize()
Return the grouping size. Grouping size is the number of digits between grouping separators in the integer portion of a number. For example, in the number "123,456.78", the grouping size is 3.

See Also:
setGroupingSize(int), DecimalFormatSymbols.getGroupingSeparator()

setGroupingSize

public void setGroupingSize(int newValue)
Set the grouping size. Grouping size is the number of digits between grouping separators in the integer portion of a number. For example, in the number "123,456.78", the grouping size is 3.

See Also:
getGroupingSize(), DecimalFormatSymbols.setGroupingSeparator(char)

isDecimalSeparatorAlwaysShown

public boolean isDecimalSeparatorAlwaysShown()
Allows you to get the behavior of the decimal separator with integers. (The decimal separator will always appear with decimals.)

Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345


setDecimalSeparatorAlwaysShown

public void setDecimalSeparatorAlwaysShown(boolean newValue)
Allows you to set the behavior of the decimal separator with integers. (The decimal separator will always appear with decimals.)

Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345


equals

public boolean equals(java.lang.Object obj)
Overrides equals

Overrides:
equals in class java.lang.Object

isGroupingUsed

public boolean isGroupingUsed()
Returns true if grouping is used in this format. For example, in the English locale, with grouping on, the number 1234567 might be formatted as "1,234,567".

See Also:
setGroupingUsed(boolean)

setGroupingUsed

public void setGroupingUsed(boolean newValue)
Set whether or not grouping will be used in this format.

See Also:
isGroupingUsed()

isParseIntegerOnly

public boolean isParseIntegerOnly()
Returns true if this format will parse numbers as integers only. For example in the English locale, with ParseIntegerOnly true, the string "1234." would be parsed as the integer value 1234 and parsing would stop at the "." character.


setParseIntegerOnly

public void setParseIntegerOnly(boolean value)
Sets whether or not numbers should be parsed as integers only.

See Also:
isParseIntegerOnly()

hashCode

public int hashCode()
Overrides hashCode

Overrides:
hashCode in class java.lang.Object

setMaximumIntegerDigits

public void setMaximumIntegerDigits(int newValue)
Sets the maximum number of digits allowed in the integer portion of a number. This override limits the integer digit count to 309.


setMinimumIntegerDigits

public void setMinimumIntegerDigits(int newValue)
Sets the minimum number of digits allowed in the integer portion of a number. This override limits the integer digit count to 309.


setMaximumFractionDigits

public void setMaximumFractionDigits(int newValue)
Sets the maximum number of digits allowed in the fraction portion of a number. This override limits the fraction digit count to 340.

See Also:
setMaximumFractionDigits(int)

getNaN

public java.lang.String getNaN()

setNaN

public void setNaN(java.lang.String s)

getInfinity

public java.lang.String getInfinity()

setInfinity

public void setInfinity(java.lang.String s)

getZeroDigit

public char getZeroDigit()

setZeroDigit

public void setZeroDigit(char c)

getDecimalSeparator

public char getDecimalSeparator()

setDecimalSeparator

public void setDecimalSeparator(char c)

getGroupingSeparator

public char getGroupingSeparator()

setGroupingSeparator

public void setGroupingSeparator(char c)


(c) 1996-2005  All rights reserved.  Stellent, Inc.