Package oracle.i18n.text
Class OraNumberFormat
- java.lang.Object
-
- java.text.Format
-
- oracle.i18n.text.OraNumberFormat
-
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
OraDecimalFormat
public abstract class OraNumberFormat extends Format
TheOraNumberFormat
class is an abstract class to do locale-sensitive formatting and parsing between number and string. It supports Oracle number formatting behavior.- See Also:
OraDecimalFormat
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_FIELD
Constant forALL_FIELD
alignment.static int
FRACTION_FIELD
Constant forFRACTION_FIELD
alignment.static int
INTEGER_FIELD
Constant forINTEGER_FIELD
alignment.protected boolean
SQLImplicit
-
Constructor Summary
Constructors Constructor Description OraNumberFormat()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
clone()
Overrides theclone
method.boolean
equals(Object obj)
Overrides theequals
method.String
format(double number)
Formats a double number into a string.abstract StringBuffer
format(double number, StringBuffer toAppendTo, FieldPosition position)
Formats a double number into a string.String
format(long number)
Formats a long number into a string.abstract StringBuffer
format(long number, StringBuffer toAppendTo, FieldPosition position)
Formats a long number into a string.StringBuffer
format(Object number, StringBuffer toAppendTo, FieldPosition position)
Formats an object into a string.String
format(BigDecimal number)
Formats aBigDecimal
object into a string.abstract StringBuffer
format(BigDecimal number, StringBuffer toAppendTo, FieldPosition position)
Formats aBigDecimal
object into a string.String
format(BigInteger number)
Formats aBigInteger
object into a string.abstract StringBuffer
format(BigInteger number, StringBuffer toAppendTo, FieldPosition position)
Formats aBigInteger
object into a string.static OraNumberFormat
getCurrencyInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetCurrencyInstance(Locale)
static OraNumberFormat
getCurrencyInstance(Locale locale)
Returns a number formatter that uses the default currency format pattern for the given locale.static OraNumberFormat
getCurrencyInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default currency format pattern for the givenOraLocaleInfo
object.static String
getDefaultCurrencyFormatPattern(Locale locale)
Returns the default currency format pattern for the given locale.static String
getDefaultCurrencyFormatPattern(OraLocaleInfo localeInfo)
Returns the default currency format pattern for the givenOraLocaleInfo
object.static String
getDefaultNumberFormatPattern(Locale locale)
Returns the default number format pattern for the given locale.static String
getDefaultNumberFormatPattern(OraLocaleInfo localeInfo)
Returns the default number format pattern for the givenOraLocaleInfo
object.static OraNumberFormat
getInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetInstance(Locale)
static OraNumberFormat
getInstance(Locale locale)
Returns a number formatter that uses the default currency format pattern for the given locale.static OraNumberFormat
getInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default currency format pattern for the givenOraLocaleInfo
object.protected int
getMaximumFractionDigits()
protected int
getMinimumFractionDigits()
protected int
getMinimumIntegerDigits()
static OraNumberFormat
getNumberInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetNumberInstance(Locale)
static OraNumberFormat
getNumberInstance(Locale locale)
Returns a number formatter that uses the default number format pattern for the given locale.static OraNumberFormat
getNumberInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default number format pattern for the givenOraLocaleInfo
object.static OraNumberFormat
getSQLImplicitInstance(Locale locale)
Returns a number formatter that uses the default number format pattern for the given locale and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.static OraNumberFormat
getSQLImplicitInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default number format pattern for the givenOraLocaleInfo
object and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.boolean
isGroupingUsed()
Checks if the grouping separator is used for this formatter.boolean
isParseIntegerOnly()
Checks if this formatter parses integer portion only.Number
parse(String text)
Parses a string into a number.abstract Number
parse(String text, ParsePosition parsePosition)
Parses a string into a number, starting from the given parse position.Object
parseObject(String text, ParsePosition parsePosition)
Parses a string into a (Number
) object, starting from the given parse position.void
setGroupingUsed(boolean val)
Sets the switch for grouping separator to the given boolean value.protected void
setMaximumFractionDigits(int max)
protected void
setMaximumIntegerDigits(int max)
protected void
setMinimumFractionDigits(int min)
protected void
setMinimumIntegerDigits(int min)
void
setParseIntegerOnly(boolean val)
Sets the switch for parsing integer only to the given boolean value.-
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
-
-
-
-
Field Detail
-
ALL_FIELD
public static final int ALL_FIELD
Constant forALL_FIELD
alignment. Used to specify the field position for formatting. TheALL_FIELD
constant is used to indicate all fields specified in a format pattern.- See Also:
- Constant Field Values
-
INTEGER_FIELD
public static final int INTEGER_FIELD
Constant forINTEGER_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
FRACTION_FIELD
public static final int FRACTION_FIELD
Constant forFRACTION_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SQLImplicit
protected boolean SQLImplicit
-
-
Method Detail
-
getCurrencyInstance
public static OraNumberFormat getCurrencyInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetCurrencyInstance(Locale)
Returns a number formatter that uses the default currency format pattern for the default locale.- Returns:
- a number formatter
-
getCurrencyInstance
public static OraNumberFormat getCurrencyInstance(Locale locale)
Returns a number formatter that uses the default currency format pattern for the given locale.- Parameters:
locale
- the given locale- Returns:
- a number formatter
-
getCurrencyInstance
public static OraNumberFormat getCurrencyInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default currency format pattern for the givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- a number formatter
-
getDefaultCurrencyFormatPattern
public static String getDefaultCurrencyFormatPattern(Locale locale)
Returns the default currency format pattern for the given locale.- Parameters:
locale
- the given locale- Returns:
- the default currency format pattern. The format pattern is in
the form of
"<positive pattern>;<negative pattern>"
or, if patterns for both positive and negative patterns are the same, the form is"<positive pattern>"
.
-
getDefaultCurrencyFormatPattern
public static String getDefaultCurrencyFormatPattern(OraLocaleInfo localeInfo)
Returns the default currency format pattern for the givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- the default currency format pattern. The format pattern is in
the form of
"<positive pattern>;<negative pattern>"
or, if patterns for both positive and negative patterns are the same, the form is"<positive pattern>"
.
-
getDefaultNumberFormatPattern
public static String getDefaultNumberFormatPattern(Locale locale)
Returns the default number format pattern for the given locale.- Parameters:
locale
- the given locale- Returns:
- the default number format pattern. The format pattern is in
the form of
"<positive pattern>;<negative pattern>"
or, if patterns for both positive and negative patterns are the same, the form is"<positive pattern>"
.
-
getDefaultNumberFormatPattern
public static String getDefaultNumberFormatPattern(OraLocaleInfo localeInfo)
Returns the default number format pattern for the givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- the default number format pattern. The format pattern is in
the form of
"<positive pattern>;<negative pattern>"
or, if patterns for both positive and negative patterns are the same, the form is"<positive pattern>"
.
-
getInstance
public static OraNumberFormat getInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetInstance(Locale)
Returns a number formatter that uses the default number format pattern for the default locale.- Returns:
- a number formatter
-
getInstance
public static OraNumberFormat getInstance(Locale locale)
Returns a number formatter that uses the default currency format pattern for the given locale.- Parameters:
locale
- the given locale- Returns:
- a number formatter
-
getInstance
public static OraNumberFormat getInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default currency format pattern for the givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- a number formatter
-
getNumberInstance
public static OraNumberFormat getNumberInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetNumberInstance(Locale)
Returns a number formatter that uses the default number format pattern for the default locale.- Returns:
- a number formatter
-
getNumberInstance
public static OraNumberFormat getNumberInstance(Locale locale)
Returns a number formatter that uses the default number format pattern for the given locale.- Parameters:
locale
- the given locale- Returns:
- a number formatter
-
getNumberInstance
public static OraNumberFormat getNumberInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default number format pattern for the givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- a number formatter
-
getSQLImplicitInstance
public static OraNumberFormat getSQLImplicitInstance(Locale locale)
Returns a number formatter that uses the default number format pattern for the given locale and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.- Parameters:
locale
- the given locale- Returns:
- a number formatter
-
getSQLImplicitInstance
public static OraNumberFormat getSQLImplicitInstance(OraLocaleInfo localeInfo)
Returns a number formatter that uses the default number format pattern for the givenOraLocaleInfo
object and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- a number formatter
-
format
public String format(BigDecimal number)
Formats aBigDecimal
object into a string.- Parameters:
number
- theBigDecimal
object to be formatted- Returns:
- a formatted string
-
format
public String format(BigInteger number)
Formats aBigInteger
object into a string.- Parameters:
number
- theBigInteger
object to be formatted- Returns:
- a formatted string
-
format
public String format(double number)
Formats a double number into a string.- Parameters:
number
- the double number to be formatted- Returns:
- a formatted string
-
format
public String format(long number)
Formats a long number into a string.- Parameters:
number
- the long number to be formatted- Returns:
- a formatted string
-
format
public abstract StringBuffer format(BigDecimal number, StringBuffer toAppendTo, FieldPosition position)
Formats aBigDecimal
object into a string. Sets field position if it is needed.- Parameters:
number
- theBigDecimal
object to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.position
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public abstract StringBuffer format(BigInteger number, StringBuffer toAppendTo, FieldPosition position)
Formats aBigInteger
object into a string. Sets field position if it is needed.- Parameters:
number
- theBigInteger
object to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.position
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public abstract StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition position)
Formats a double number into a string. Sets field position if it is needed.- Parameters:
number
- the double number to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.position
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public abstract StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition position)
Formats a long number into a string. Sets field position if it is needed.- Parameters:
number
- the long number to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.position
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition position)
Formats an object into a string. Sets field position if it is needed.- Specified by:
format
in classFormat
- Parameters:
number
- the object to be formatted. It must be an instance ofNumber
class.toAppendTo
- the string buffer to be appended with the formatted string.position
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
- Throws:
IllegalArgumentException
- if the given object is not an instance ofNumber
class
-
parse
public Number parse(String text) throws ParseException
Parses a string into a number.- Parameters:
text
- the string to be parsed- Returns:
- a
Number
object corresponding to the string - Throws:
ParseException
- if the format pattern associated with this formatter is not valid for parsing or the given string cannot be parsed into a instance ofNumber
class
-
parse
public abstract Number parse(String text, ParsePosition parsePosition)
Parses a string into a number, starting from the given parse position.- Parameters:
text
- the string to be parsed.parsePosition
- indicates where to start the parsing on input. On output, returns where the parse ends if parsing succeeds, or the start index if it fails.- Returns:
- a
Number
object
-
parseObject
public Object parseObject(String text, ParsePosition parsePosition)
Parses a string into a (Number
) object, starting from the given parse position. It is a convenient method which simply calls theparse(String, ParsePostion)
method.- Specified by:
parseObject
in classFormat
- See Also:
parse(String, ParsePosition)
-
isGroupingUsed
public boolean isGroupingUsed()
Checks if the grouping separator is used for this formatter.- Returns:
true
if the grouping separator is used,false
otherwise
-
setGroupingUsed
public void setGroupingUsed(boolean val)
Sets the switch for grouping separator to the given boolean value.- Parameters:
val
- the given boolean value
-
isParseIntegerOnly
public boolean isParseIntegerOnly()
Checks if this formatter parses integer portion only.- Returns:
true
if this formatter parses integer portion only,false
otherwise
-
setParseIntegerOnly
public void setParseIntegerOnly(boolean val)
Sets the switch for parsing integer only to the given boolean value.- Parameters:
val
- the given boolean value
-
setMaximumIntegerDigits
protected void setMaximumIntegerDigits(int max)
-
getMinimumIntegerDigits
protected int getMinimumIntegerDigits()
-
setMinimumIntegerDigits
protected void setMinimumIntegerDigits(int min)
-
getMaximumFractionDigits
protected int getMaximumFractionDigits()
-
setMaximumFractionDigits
protected void setMaximumFractionDigits(int max)
-
getMinimumFractionDigits
protected int getMinimumFractionDigits()
-
setMinimumFractionDigits
protected void setMinimumFractionDigits(int min)
-
clone
public Object clone()
Overrides theclone
method.
-
-