public abstract class NumberType extends BaseDataType
integer
and
decimal
Progress compatible data type wrappers. The major
role of this class is to allow a common method implementation for all
subclasses rather than an orthogonal implementation.
In addition to the implementation requirements for BaseDataType
,
each concrete subclass must implement:
double doubleValue() int intValue() long longValue() increment() decrement() String buildDefaultFormat() String buildExportFormat()
Modifier and Type | Class and Description |
---|---|
private static class |
NumberType.ContextContainer
Simple container that stores and returns a context-local instance of
the global work area.
|
static class |
NumberType.FormatSpec
Serves as a container for parsed format specifications regarding
a specific Progress-compatible numeric format string.
|
private static class |
NumberType.WorkArea
Stores global data relating to the state of the current context.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
AMERICAN_FORMAT
Constant identifying the AMERICAN format.
|
private static char |
DEC_SEP
The locale-specific decimal separator (decimal point) as reported by
the JVM.
|
private static java.lang.String |
EUROPEAN_FORMAT
Constant identifying the EURPEAN format.
|
protected static char |
FORMAT_DEC_SEP
Decimal separator used in format definition.
|
protected static char |
FORMAT_GROUP_SEP
Group separator used in format definition.
|
private static char |
GROUP_SEP
The locale-specific group separator as reported by the JVM.
|
static int |
SIGN_CR
Format has a "CR" as the sign specification.
|
static int |
SIGN_DB
Format has a "DB" as the sign specification.
|
static int |
SIGN_DR
Format has a "DR" as the sign specification.
|
static int |
SIGN_LEFT_MINUS
Format has a left minus as the sign specification.
|
static int |
SIGN_LEFT_PLUS
Format has a left plus as the sign specification.
|
static int |
SIGN_NONE
Format has no sign specification.
|
static int |
SIGN_PAREN
Format has non-embedded parenthesis as the sign specification.
|
static int |
SIGN_PAREN_EMBED
Format has embedded parenthesis as the sign specification.
|
static int |
SIGN_RIGHT_MINUS
Format has a right minus as the sign specification.
|
static int |
SIGN_RIGHT_PLUS
Format has a right plus as the sign specification.
|
private static NumberType.ContextContainer |
work
Stores context-local state variables.
|
Constructor and Description |
---|
NumberType()
Default constructor (only used for de-serialization).
|
Modifier and Type | Method and Description |
---|---|
abstract java.lang.String |
buildDefaultFormat()
Dynamically builds the default format string for this given number type
which honors the given group and decimal separators.
|
abstract java.lang.String |
buildExportFormat()
Returns the export format string for this given number type which
honors the given group and decimal separators.
|
abstract void |
decrement()
Decrements the value of this instance by 1.
|
java.lang.String |
defaultFormatString()
Return the default display format string for this type.
|
abstract double |
doubleValue()
Returns the value of this instance as a
double . |
private static void |
errorInvalidChar(char c)
Common method for reporting invalid char error.
|
private static void |
genCannotBeDisplayed(java.lang.String num,
java.lang.String fmt)
Generate (and either display OR log) an error message if there is an
invalid format, BUT DO NOT raise an error condition.
|
static java.lang.String |
generateSimpleFormat(java.lang.String fmt,
boolean sign)
Converts a given format string into a simple form that maintains the
digit specifications (number, position, zero/space fill...) and the
decimal separator (position and type) BUT converts any sign characters
into a left minus and drops all group separators/user text.
|
private static int |
genInvalidCharError(int idx,
java.lang.String fmt)
Generate an error if no digits are specified in a numeric format string.
|
private static java.lang.String |
genNoDigitsError(java.lang.String fmt)
Generate an error if no digits are specified in a numeric format string.
|
NumberType |
getBits(double pos,
double len)
Returns the number of bits from the given position as an
integer . |
NumberType |
getBits(double pos,
NumberType len)
Returns the number of bits from the given position as an
integer . |
NumberType |
getBits(NumberType pos,
double len)
Returns the number of bits from the given position as an
integer . |
NumberType |
getBits(NumberType pos,
NumberType len)
Returns the number made of the bits from the given position as an
integer . |
abstract NumberType |
getBitsWorker(double pos,
double len)
Worker method for getBits, this returns the number of bits from the
given position as an
integer . |
static char |
getDecimalSeparator()
Returns the current context's decimal separator (decimal point) which
may have been obtained from the directory or may have defaulted to the
locale-specific version.
|
static int |
getDecimalSeparatorIndex(java.lang.String fmt)
Parse the numeric format string and return the digit string on
the right if it exists.
|
static java.lang.String |
getDefaultFormat(NumberType num)
Returns the context-specific default format string (which honors
the user's defined group and decimal separators).
|
static java.lang.String |
getDigitsLeft(java.lang.String fmt)
Parse the numeric format string and return the digit string on
the left if it exists.
|
static java.lang.String |
getDigitsRight(java.lang.String fmt)
Parse the numeric format string and return the digit string on
the right if it exists.
|
static int |
getEmbedIndex(java.lang.String fmt)
Parse the numeric format string and return the index of any embedded
parenthesis (the parenthesis can be used as a sign and the left
parenthesis can be embedded inside the user string on the left).
|
static java.lang.String |
getExportFormat(NumberType num)
Returns the context-specific export format string (which honors
the user's defined group and decimal separators).
|
static char |
getGroupSeparator()
Returns the current context's group separator which may have been
obtained from the directory or may have defaulted to the locale-
specific version.
|
static character |
getNumericDecimalPoint()
Get the NUMERIC-DECIMAL-POINT attribute, which is the character that represents a number's
decimal point, in its formatted representation.
|
static character |
getNumericFormat()
Get the NUMERIC-FORMAT attribute, which provides the way of interpreting commas and periods
within numeric values.
|
static character |
getNumericSeparator()
Get the NUMERIC-SEPARATOR attribute, which is the character that represents a number's
thousands separator, in its formatted representation.
|
static int |
getNumGroupSeparators(java.lang.String fmt)
Parse the numeric format string and return the number of group
separators on the left side.
|
static java.lang.String |
getUserLeft(java.lang.String fmt)
Parse the numeric format string and return the user-specified string on
the left if it exists.
|
static java.lang.String |
getUserRight(java.lang.String fmt)
Parse the numeric format string and return the user-specified string on
the right if it exists.
|
static int |
getValueTextLength(java.lang.String text,
java.lang.String fmt)
Getting the length of the text for numeric value according to the given format string.
|
abstract void |
increment()
Increments the value of this instance by 1.
|
private static void |
initContextSpecificSeps(NumberType.WorkArea wa)
Determines the group and decimal separators for the current context
based on reading override values from the directory.
|
private static char |
initDecimalSeparator()
Returns the default locale's decimal separator (defaults to period).
|
private static char |
initGroupSeparator()
Returns the default locale's group separator (defaults to comma).
|
abstract int |
intValue()
Returns the value of this instance as an
int . |
static boolean |
isDigitChar(char c)
Tests the passed character to determine if it is a recognized digit
character or not.
|
static boolean |
isFormatChar(char c)
Tests the passed character to determine if it is a recognized format
character or not.
|
abstract long |
longValue()
Returns the value of this instance as a
long . |
abstract java.lang.String |
obtainDefaultFormat()
Returns the default format string for this given number type (which
honors the given group and decimal separators), building that format
and caching it if this is the first call in this context.
|
private static NumberType.FormatSpec |
obtainParsed(java.lang.String fmt,
NumberType.WorkArea wa)
Gets the already parsed format specification of the given
Progress-compatible format string.
|
static void |
overrideDefaultSeparators(char grp,
char dec)
Manually override the default group and decimal separators which are
read from the JVM-wide values at this class' static initialization.
|
static java.lang.String |
parseDecimal(java.lang.String str,
boolean parsingInteger)
Converts a Progress 4GL style string which represents an integer or
a decimal into a Java style string representing the same number.
|
static java.lang.String |
parseDecimal(java.lang.String str,
char decSep,
char grpSep,
boolean isInt)
Converts a Progress 4GL style string which represents an integer or
a decimal into a Java style string representing the same number.
|
private static int |
parseDigits(java.lang.String fmt,
int index,
NumberType.FormatSpec fs)
Parse out any digit characters of the format string and save these
specifications in the given format spec instance.
|
static double |
parseDouble(java.lang.String str,
boolean parsingInteger)
Converts a Progress 4GL style string which represents an integer or
a decimal into a Java double primitive.
|
static double |
parseDouble(java.lang.String str,
char decSep,
char grpSep,
boolean parsingInteger)
Converts a Progress 4GL style string which represents an integer or
a decimal into a Java double primitive.
|
static NumberType.FormatSpec |
parseFormat(java.lang.String fmt)
Parse the numeric format string and store the resulting format
specification for subsequent use.
|
private static int |
parseSign(boolean left,
int leftSignIdx,
java.lang.String fmt,
int index,
NumberType.FormatSpec fs)
Parse out any sign-related characters (which can occur on the left,
the right or both sides of the format string) and add the specifications
to the format spec instance.
|
private static int |
processDigits(java.lang.String left,
java.lang.String right,
java.lang.String fmt,
int index,
int extra,
java.lang.StringBuilder sb)
Parse out any digit characters of the format string and use these
specifications to convert the left and right portions of the number's
characters into the output string.
|
private static int |
processSign(boolean left,
int leftSignIdx,
boolean negative,
java.lang.String fmt,
int index,
java.lang.StringBuilder sb,
boolean rightAlign)
Parse out any sign-related characters (which can occur on the left,
the right or both sides of the format string) and add the corresponding
characters to the output string based on the sign of the number and
upon other state variables.
|
NumberType |
setBits(double data,
double pos,
double len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
NumberType |
setBits(double data,
double pos,
NumberType len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
NumberType |
setBits(double data,
NumberType pos,
double len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
NumberType |
setBits(NumberType data,
double pos,
double len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
NumberType |
setBits(NumberType data,
double pos,
NumberType len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
NumberType |
setBits(NumberType data,
NumberType pos,
double len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
NumberType |
setBits(NumberType data,
NumberType pos,
NumberType len)
Copies the bit representation of an integer to a location with a given number of bits
within the current integer variable.
|
abstract void |
setBitsWorker(double data,
double pos,
double len)
Worker method for setBits, this copies the bit representation of an
integer to a location with a given number of bits within the current
integer variable.
|
static logical |
setNumericFormat(character separator,
character decPoint)
Sets the NUMERIC-SEPARATOR and NUMERIC-DECIMAL-POINT attributes simultaneously.
|
static logical |
setNumericFormat(character separator,
java.lang.String decPoint)
Sets the NUMERIC-SEPARATOR and NUMERIC-DECIMAL-POINT attributes simultaneously.
|
static void |
setNumericFormat(char decSep,
char groupSep)
Replace the existing separators with the given ones.
|
static void |
setNumericFormat(java.lang.String format)
Set the NUMERIC-FORMAT attribute.
|
static logical |
setNumericFormat(java.lang.String separator,
character decPoint)
Sets the NUMERIC-SEPARATOR and NUMERIC-DECIMAL-POINT attributes simultaneously.
|
static logical |
setNumericFormat(java.lang.String separator,
java.lang.String decPoint)
Sets the NUMERIC-SEPARATOR and NUMERIC-DECIMAL-POINT attributes simultaneously.
|
static void |
setNumericFormat(Text format)
Set the NUMERIC-FORMAT attribute.
|
int |
subscript()
Generate a valid 0-based integral subscript from the 1-based numeric
value in this instance.
|
abstract java.math.BigDecimal |
toBigDecimal()
Returns the value of this instance as a
BigDecimal . |
static java.lang.String |
toString(java.lang.String left,
java.lang.String right,
boolean negative,
java.lang.String fmt)
Convert a numeric string argument into a formatted string based on
a Progress compatible formatting pattern.
|
static java.lang.String |
toString(java.lang.String left,
java.lang.String right,
boolean negative,
java.lang.String fmt,
boolean rightAlign)
Convert a numeric string argument into a formatted string based on
a Progress compatible formatting pattern.
|
assign, assign, calcFormatLength, deepCopy, duplicate, elementsOfType, equals, formatLength, generateDefault, generateUnknown, getTypeName, hashCode, incompatibleTypesOnConversion, initializeDefaultExtent, instantiateDefault, instantiateDefaultExtent, instantiateUnknown, isUnknown, isUnknownValue, maximum, minimum, notUnknownValue, sameType, setUnknown, toString, toStringExport, toStringMessage
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobal
protected static final char FORMAT_DEC_SEP
protected static final char FORMAT_GROUP_SEP
private static final java.lang.String AMERICAN_FORMAT
private static final java.lang.String EUROPEAN_FORMAT
private static char GROUP_SEP
private static char DEC_SEP
private static NumberType.ContextContainer work
public static final int SIGN_NONE
public static final int SIGN_LEFT_MINUS
public static final int SIGN_LEFT_PLUS
public static final int SIGN_PAREN
public static final int SIGN_PAREN_EMBED
public static final int SIGN_RIGHT_MINUS
public static final int SIGN_RIGHT_PLUS
public static final int SIGN_CR
public static final int SIGN_DB
public static final int SIGN_DR
public NumberType()
public abstract long longValue()
long
.
This method will fail if the instance represents the
unknown value
.
long
.java.lang.NullPointerException
- If this instance represents the unknown value
.public abstract int intValue()
int
.
This method will fail if the instance represents the
unknown value
.
int
.java.lang.NullPointerException
- If this instance represents the unknown value
.public abstract double doubleValue()
double
. Loss
of precision may occur in this conversion. Use toBigDecimal()
if keeping the precision is the concern.
If this instance represents the unknown value
, the
returned double
will be set to NaN
.
double
.public abstract java.math.BigDecimal toBigDecimal()
BigDecimal
. No loss
of precision will occur in this conversion.
If this instance represents the unknown value
, the
return value will be null
.
BigDecimal
instance, see above for details.public abstract void increment()
If this instance represents the unknown value
, nothing
is done.
public abstract void decrement()
If this instance represents the unknown value
, nothing
is done.
public abstract java.lang.String buildDefaultFormat()
public abstract java.lang.String obtainDefaultFormat()
public abstract java.lang.String buildExportFormat()
null
if this type does not use an export
format.public abstract NumberType getBitsWorker(double pos, double len)
integer
.pos
- The 1-based index position to set, must be > 0.len
- The number of bytes to take into consideration when performing
the operation.integer
.public abstract void setBitsWorker(double data, double pos, double len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bytes to take into consideration when performing
the operation.public int subscript()
int
, decrement it and
return.unknown value
.public static void overrideDefaultSeparators(char grp, char dec)
grp
- The new group separator character.dec
- The new decimal separator character.public static double parseDouble(java.lang.String str, boolean parsingInteger) throws java.lang.NumberFormatException
The default decimal and group separators for the JVM locale are used.
str
- The Progress style integer or decimal encoded as a string.
If this is an empty string, then the value 0 will be returned
(just like Progress).parsingInteger
- true
if the result of this function will be
interpreted as an integer. Affects error handling.double
.java.lang.NumberFormatException
- if the given string cannot be parsed to a double value.public static double parseDouble(java.lang.String str, char decSep, char grpSep, boolean parsingInteger) throws java.lang.NumberFormatException
This method also handles Progress 4GL string to number conversion quirk, which in some cases allows entering certain characters without triggering error condition.
str
- The Progress style integer or decimal encoded as a string.
If this is an empty string, then the value 0 will be returned
(just like Progress).decSep
- The decimal separator to use.grpSep
- The group separator to use.parsingInteger
- true
if the result of this function will be
interpreted as an integer. Affects error handling.double
.java.lang.NumberFormatException
- if the given string cannot be parsed to a double value.public static java.lang.String parseDecimal(java.lang.String str, boolean parsingInteger)
The Java BigDecimal
and Double
string parsing
is done using a '.' as the decimal separator (it deliberately ignores
the locale-specific separator). This method handles this conversion.
The default decimal and group separators for the JVM locale are used.
This method also handles Progress 4GL string to number conversion quirk, which in some cases allows entering certain characters without triggering error condition.
str
- The Progress style integer or decimal encoded as a string.
If this is an empty string, then the value 0 will be returned
(just like Progress).parsingInteger
- true
if the result of this function will be
interpreted as an integer. Affects error handling.double
or into a BigDecimal
.public static java.lang.String parseDecimal(java.lang.String str, char decSep, char grpSep, boolean isInt)
On input in the 4GL, only the following characters may be present:
During scanning, if any other character (than those noted above) is encountered, it will cause an invalid character error if some other error has not been found previously.
The parsing can be considered as having 3 phases:
Phase 1 (pre-number) ends when the first digit or "near digit" character is encountered. The near digits are the group and decimal separators. In the pre-number phase, there can be zero or one sign characters, zero or more asterisks and any amount of whitespace. The whitespace can be anywhere in this section and the amount of contiguous whitespace is not limited. If there are more one asterisk, they may be separated by whitespace however, all asterisks must occur on only one side of the sign (not on both sides of any sign character). Once phase 1 is complete, asterisks may no longer be present in the string.
Phase 2 (number parsing) is the only phase in which digits or near digits may be present. In addition, no other characters besides digits and near digits may be present in this phase. So there can be no whitespace, sign characters or asterisks. The first non-digit (or non-near-digit) ends number parsing. There may be zero or more group separators in any configuration in the number parsing phase. Group separators are simply dropped and have no meaning other than being a near-digit (and thus affecting parsing). There may be zero or one decimal separator in the number parsing section. There may be any number of digits (so long as it is not larger than can be converted into a valid integer or decimal). Leading zeros (in the portion before the decimal point) and trailing zeros (in the portion after the decimal point) are dropped. This corresponds to the 4GL behavior where an unlimited number of leading and trailing zeros can be present and are ignored (since they have no effect on the value of the number).
Phase 3 (post-number) extends after phase 2 to the end of the string. Any amount of whitespace is allowed in this section. In addition, if there was no sign character in the pre-number section, then one sign character is allowed here (as a post-fixed sign). Any other character is invalid.
There is a special case where the number parsing phase is empty. This can happen if there are no digits (or near-digits) on input. If the first sign character follows an asterisk, this is taken as the end of the number parsing phase, even if there were no digits and/or there are digits following the sign. If there were such following digits, they would be in the post-number phase and would trigger an error. If there are no digits on output (effectively the empty string or just a "-", this is a valid string and will be converted to the number "0".
Translations:
Input Character Output Result ------------------ -------------------------------------------------- digit 0 If a leading 0 to the left of the decimal point or if a trailing 0 to the right of the decimal point, then this zero is dropped. Otherwise it is copied to the output string. digit (1 - 9) Copied to output string. group separator Dropped. decimal separator 1st is copied to output string. 2nd causes an error. whitespace Dropped. + sign character 1st is dropped. 2nd causes one of 2 possible errors. - sign character 1st is prefixed in the output string. 2nd causes one of 2 possible errors. asterisks Dropped.
Sign characters are normalized (prefixed and postfixed '+' is removed, '-'. The 2nd sign character will always cause an error, but the error that occurs will depend on the parsing phase. A post-fixed sign is fine so long as it is the first sign character encountered. But any sign character (first or second) appearing in the post-number phase will generate an invalid character error. Before the 3rd phase, the 1st sign will be honored and the second sign character will raise a "more than 1 sign" error. Note that for the purposes of counting sign characters, the direction of the sign has no meaning (-+, --, ++, +- are all equivalent errors).
The Java BigDecimal
and Double
string parsing
is done using a '.' as the decimal separator (it deliberately ignores
the locale-specific separator). This method handles this conversion.
str
- The Progress style integer or decimal encoded as a string.
If this is an empty string, then the value 0 will be returned
(just like Progress).decSep
- The decimal separator to use.grpSep
- The group separator to use.isInt
- true
if the result of this function will be
interpreted as an integer. Affects error handling.double
or into a BigDecimal
.public static java.lang.String toString(java.lang.String left, java.lang.String right, boolean negative, java.lang.String fmt)
This method provides processing that can handle both integers and floating-point numbers.
left
- The simple, unformatted string representation of the digits
of this number that reside on the left side of the decimal
point. This string should NOT have a sign indicator nor any
grouping/decimal separators or leading zeros. It should only
have numeric digits.right
- The simple, unformatted string representation of the digits
of this number that reside on the right side of the decimal
point. This string should NOT have a sign indicator nor any
grouping/decimal separators or trailing zeros. It should
only have numeric digits.negative
- Flag that indicates the sign of the number.fmt
- The Progress 4GL compatible format string.public static java.lang.String toString(java.lang.String left, java.lang.String right, boolean negative, java.lang.String fmt, boolean rightAlign)
This method provides processing that can handle both integers and floating-point numbers.
left
- The simple, unformatted string representation of the digits
of this number that reside on the left side of the decimal
point. This string should NOT have a sign indicator nor any
grouping/decimal separators or leading zeros. It should only
have numeric digits.right
- The simple, unformatted string representation of the digits
of this number that reside on the right side of the decimal
point. This string should NOT have a sign indicator nor any
grouping/decimal separators or trailing zeros. It should
only have numeric digits.negative
- Flag that indicates the sign of the number.fmt
- The Progress 4GL compatible format string.rightAlign
- Pad on the left to the full size of the format string if the
format has '>' characters that match the positions of
leading zeroes.public static char getGroupSeparator()
The value returned may have been found via a search algorithm that is account (user or process) specific or group specific within the current server or a global default for all servers.
The implementation iteratively looks up the directory node under: /server/<serverID>/runtime/<account_or_group>/numberGroupSep
If no user/process or group nodes are present, then this is checked: /server/<serverID>/runtime/default/numberGroupSep
If no /server/<serverID>/runtime node exists, this is checked (it is the global default area for all servers): /server/default/runtime/<account_or_group>/numberGroupSep
Finally, if no user/process or group nodes are present in the global default area, then this is checked: /server/default/runtime/default/numberGroupSep
If no value is found via this lookup, then the JVM default is tried. If the JVM default cannot be obtained, then this defaults to a ','.
public static char getDecimalSeparator()
The value returned may have been found via a search algorithm that is account (user or process) specific or group specific within the current server or a global default for all servers.
The implementation iteratively looks up the directory node under: /server/<serverID>/runtime/<account_or_group>/numberDecimalSep
If no user/process or group nodes are present, then this is checked: /server/<serverID>/runtime/default/numberDecimalSep
If no /server/<serverID>/runtime node exists, this is checked (it is the global default area for all servers): /server/default/runtime/<account_or_group>/numberDecimalSep
Finally, if no user/process or group nodes are present in the global default area, then this is checked: /server/default/runtime/default/numberDecimalSep
If no value is found via this lookup, then the JVM default is tried. If the JVM default cannot be obtained, then this defaults to a '.'.
public static java.lang.String getDefaultFormat(NumberType num)
num
- The instance which can initialize the format if needed.public static java.lang.String getExportFormat(NumberType num)
num
- The instance which can initialize the format if needed.null
if one is
not used for this type of number.public static boolean isFormatChar(char c)
c
- The character to test.true
if the character is a format character.public static boolean isDigitChar(char c)
c
- The character to test.true
if the character is a digit character.public static java.lang.String generateSimpleFormat(java.lang.String fmt, boolean sign)
The advantage of this method is to make numbers that can be easily parsed WHICH ALSO have the same exact number of digits (on both sides of the decimal separator) which would be the result of the input format string.
fmt
- Any valid Progress-compatible numeric format string.sign
- true
if a signed value can be represented (if
the format has a sign specification), in which case the
result will have a left minus as a sign character. On
false
, the resulting simple format will NOT have
a sign character.public static NumberType.FormatSpec parseFormat(java.lang.String fmt)
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static int getEmbedIndex(java.lang.String fmt)
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static java.lang.String getUserLeft(java.lang.String fmt)
If the format string has not yet been parsed, it will be parsed using the default JVM decimal separator and group separator.
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static java.lang.String getUserRight(java.lang.String fmt)
If the format string has not yet been parsed, it will be parsed using the default JVM decimal separator and group separator.
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static java.lang.String getDigitsLeft(java.lang.String fmt)
If the format string has not yet been parsed, it will be parsed using the default JVM decimal separator and group separator.
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static java.lang.String getDigitsRight(java.lang.String fmt)
If the format string has not yet been parsed, it will be parsed using the default JVM decimal separator and group separator.
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static int getDecimalSeparatorIndex(java.lang.String fmt)
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.null
if no text exists there.public static int getNumGroupSeparators(java.lang.String fmt)
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.public static character getNumericSeparator()
public static character getNumericDecimalPoint()
public static character getNumericFormat()
The possible values are "American", "European" or a character string consisting of the thousands separator followed by the decimal point. This attribute provides the same functionality as the European Numeric Format (-E) parameter.
public static void setNumericFormat(java.lang.String format)
getNumericFormat()
for its representation.format
- The new value.public static void setNumericFormat(Text format)
getNumericFormat()
for its representation.format
- The new value.public static logical setNumericFormat(java.lang.String separator, java.lang.String decPoint)
separator
- The new NUMERIC-SEPARATOR value.decPoint
- The new NUMERIC-DECIMAL-POINT value.true
if the operation was successful.public static logical setNumericFormat(character separator, java.lang.String decPoint)
separator
- The new NUMERIC-SEPARATOR value.decPoint
- The new NUMERIC-DECIMAL-POINT value.true
if the operation was successful.public static logical setNumericFormat(java.lang.String separator, character decPoint)
separator
- The new NUMERIC-SEPARATOR value.decPoint
- The new NUMERIC-DECIMAL-POINT value.true
if the operation was successful.public static logical setNumericFormat(character separator, character decPoint)
separator
- The new NUMERIC-SEPARATOR value.decPoint
- The new NUMERIC-DECIMAL-POINT value.true
if the operation was successful.public static void setNumericFormat(char decSep, char groupSep)
decSep
- The new decimal separator.groupSep
- The new group separator.public static int getValueTextLength(java.lang.String text, java.lang.String fmt)
text
- The text value to measure.fmt
- The format string to help.public java.lang.String defaultFormatString()
defaultFormatString
in class BaseDataType
public NumberType getBits(double pos, double len)
integer
.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.integer
.public NumberType getBits(NumberType pos, double len)
integer
.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.integer
.public NumberType getBits(double pos, NumberType len)
integer
.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.integer
.public NumberType getBits(NumberType pos, NumberType len)
integer
.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.integer
.public NumberType setBits(double data, double pos, double len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.public NumberType setBits(NumberType data, double pos, double len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.public NumberType setBits(NumberType data, NumberType pos, double len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.public NumberType setBits(NumberType data, double pos, NumberType len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.public NumberType setBits(NumberType data, NumberType pos, NumberType len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.public NumberType setBits(double data, NumberType pos, double len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.public NumberType setBits(double data, double pos, NumberType len)
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.private static NumberType.FormatSpec obtainParsed(java.lang.String fmt, NumberType.WorkArea wa)
fmt
- The format string to parse. Must be a valid
Progress-compatible numeric format.wa
- Optional WorkArea
object. Many callers of this
method look up the context local work area and so can provide
it to this method to avoid an additional, unnecessary lookup
here. If null
, this method will perform the
lookup itself.null
if it could not
be obtained or parsed.private static int processSign(boolean left, int leftSignIdx, boolean negative, java.lang.String fmt, int index, java.lang.StringBuilder sb, boolean rightAlign)
left
- true
if this is the left side sign processing.leftSignIdx
- -1 if this is the left side processing or if it is the right
side processing and no left side processing occurred.
Otherwise this is the index of the single character on the
left side of the format string that was matched/processed
during the left side sign processing.negative
- true
if the number being formatted is negative.fmt
- The Progress compatible format string.index
- The character index to examine for sign indicators.sb
- The buffer in which our formatted output is built.rightAlign
- Pad on the left to the full size of the format string if the
format has '>' characters that match the positions of
leading zeroes.private static int parseSign(boolean left, int leftSignIdx, java.lang.String fmt, int index, NumberType.FormatSpec fs)
left
- true
if this is the left side sign processing.leftSignIdx
- -1 if this is the left side processing or if it is the right
side processing and no left side processing occurred.
Otherwise this is the index of the single character on the
left side of the format string that was matched/processed
during the left side sign processing.fmt
- The Progress compatible format string.index
- The character index to examine for sign indicators.fs
- The format spec in which our calculations are to be stored.private static int processDigits(java.lang.String left, java.lang.String right, java.lang.String fmt, int index, int extra, java.lang.StringBuilder sb)
left
- The digits from the left side of the decimal point.right
- The digits from the right side of the decimal point.fmt
- The Progress compatible format string.index
- The character index to begin the left side digit characters.extra
- The index into the output buffer of any replaceable minus or
plus sign in the case where a one digit overflow of a
non-negative number can be cured or -1 if such a special
case re-purposing of a left side sign position is not allowed.sb
- The buffer in which our formatted output is built.private static int parseDigits(java.lang.String fmt, int index, NumberType.FormatSpec fs)
fmt
- The Progress compatible format string.index
- The character index to examine for sign indicators.fs
- The format spec in hich our formatted output is to be stored.private static void genCannotBeDisplayed(java.lang.String num, java.lang.String fmt)
num
- The simple text form of the number that cannot be displayed.fmt
- The mis-matched format string.private static java.lang.String genNoDigitsError(java.lang.String fmt)
fmt
- The incorrect format string.private static int genInvalidCharError(int idx, java.lang.String fmt)
idx
- The 0-based index of the incorrect character in the format
string (this will be converted to a 1-based index).fmt
- The incorrect format string.private static char initGroupSeparator()
private static char initDecimalSeparator()
private static void initContextSpecificSeps(NumberType.WorkArea wa)
The value returned may have been found via a search algorithm that is account (user or process) specific or group specific within the current server or a global default for all servers.
The implementation iteratively looks up the directory node under: /server/<serverID>/runtime/<account_or_group>/numberGroupSep /server/<serverID>/runtime/<account_or_group>/numberDecimalSep
If no user/process or group nodes are present, then this is checked: /server/<serverID>/runtime/default/numberGroupSep /server/<serverID>/runtime/default/numberDecimalSep
If no /server/<serverID>/runtime node exists, this is checked (it is the global default area for all servers): /server/default/runtime/<account_or_group>/numberGroupSep /server/default/runtime/<account_or_group>/numberDecimalSep
Finally, if no user/process or group nodes are present in the global default area, then this is checked: /server/default/runtime/default/numberGroupSep /server/default/runtime/default/numberDecimalSep
Each value is controlled independently. One or the other or both can be missing from the directory. In addition, even if both appear in the directory, there is no requirement for them to be both specified in the same path in the directory.
wa
- The context's work area to edit.private static void errorInvalidChar(char c)
c
- Character which caused the error.