public class character extends Text
CompareOps
class. Operator and functions common to character
and longchar types are implemented as statics in the TextOps
class.
In addition to the implementation of the base string processing functions
and operators, this class hides the representation of the
unknown value
and properly maintains the processing of
unknown value
.
Format string related processing is handled in this class, see method
toString(String)
.
The following is the mapping of Progress language features to the corresponding feature in this class:
contains operator not supported at this time _cbit functiontestBitAt(com.goldencode.p2j.util.character, com.goldencode.p2j.util.int64)
chr functionchr(com.goldencode.p2j.util.int64)
asc functionasc(com.goldencode.p2j.util.character)
string functionvalueOf(double)
fill functionfill(com.goldencode.p2j.util.character, com.goldencode.p2j.util.NumberType)
quoter functionquoter(com.goldencode.p2j.util.BaseDataType)
Please note that at this time, no conversion of Progress strings to
Java strings is done. All strings passed are expected to be Java
strings. This behavior may need changing in the case where a Progress
string is built at runtime but needs to be used as a Java string. In
this case the progressToJavaString(java.lang.String)
method should be used.
Modifier and Type | Class and Description |
---|---|
private static class |
character.TestCase
Encapsulates the logic of storing and executing a set of tests using
a minimum set of input (2 string operands and a set of boolean results
that are to be expected).
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
defaultFormat
The default format string.
|
Constructor and Description |
---|
character()
Default constructor, creates an instance that represents the unknown
value.
|
character(BaseDataType value)
This is a special c'tor which should be used only when converting the
value returned by a function or method with polymorphic return type into the
expected type (i.e.
|
character(char ch)
Constructs an instance that has a
char value passed
in and which does not represent the unknown value . |
character(character value)
Constructs an instance that has the
String value and
unknown value that exactly matches that of the passed-in
instance. |
character(java.lang.String value)
Constructs an instance that has the
String value passed
in and which does not represent the unknown value ,
unless the value argument is null . |
character(java.lang.String value,
boolean caseSens)
Constructs an instance that has the
String value passed
in and which does not represent the unknown value
unless the value argument is null . |
character(Text value)
Create a new instance, by copying the state of the passed
Text . |
character(Text value,
boolean output)
Create a new instance, by copying the state of the passed
Text . |
Modifier and Type | Method and Description |
---|---|
static int64 |
asc(character c)
Returns the numeric value of a character expression which must be
only 1 character in length.
|
static int64 |
asc(java.lang.String str)
Returns the numeric value of a string which must be only 1 character
in length.
|
static character |
chr(int64 i)
Returns the character value of a numeric expression which must be
between 1 and 65534 (inclusive).
|
static character |
chr(long i)
Returns the character value of a numeric expression which must be
between 1 and 65534 (inclusive).
|
java.lang.String |
defaultFormatString()
Return the default display format string for this type.
|
BaseDataType |
duplicate()
Does the same as standard
clone() method but returns an
instance of BaseDataType and doesn't throw the
CloneNotSupportedException . |
static java.lang.String |
encodeToJavaSource(java.lang.String data)
Converts a runtime string to text representation of a java string literal.
|
static character |
fill(character c,
double num)
Return a character instance that is comprised of
num
concatenated copies of a given string. |
static character |
fill(character c,
int num)
Return a character instance that is comprised of
num
concatenated copies of a given string. |
static character |
fill(character c,
NumberType num)
Return a character instance that is comprised of
num
concatenated copies of a given string. |
static character |
fill(java.lang.String str,
double num)
Return a character instance that is comprised of
num
concatenated copies of a given string. |
static character |
fill(java.lang.String str,
int num)
Return a character instance that is comprised of
num
concatenated copies of a given string. |
static character |
fill(java.lang.String str,
NumberType num)
Return a character instance that is comprised of
num
concatenated copies of a given string. |
private static character |
fillWorker(character ch,
int num,
boolean cs)
Return a character instance that is comprised of
num concatenated copies of a
given string. |
(package private) void |
forceBytes(byte[] data)
This method allows the explicit bypass of embedded null character protections that are
in place for all construction and assignment of text values.
|
int |
formatLength(java.lang.String fmt)
Calculate the length of any formatted value (the text form of the value)
using this format string.
|
static java.lang.String |
fromExportString(java.lang.String export)
Removes a set of enclosing double quotes (first and last characters)
and converts any doubled up instances (2 instances sequentially) of
double quotes into a single instance of double quotes.
|
BaseDataType |
instantiateDefault()
Creates a new instance of the same type that represents the
default initialized value.
|
protected BaseDataType |
instantiateDefaultExtent()
Get the default initialization for an extent variable of this type.
|
static java.lang.String |
javaRuntimeToProgressSourceString(java.lang.String contents)
Converts a Java runtime string into one that can be encoded in Progress 4GL source code
as a string literal.
|
static void |
main(java.lang.String[] args)
Command line interface which provides a test harness to regression
test this class.
|
static java.lang.String |
parseProgressCharLiteral(java.lang.String progress,
boolean windows)
Parses a Progress 4GL compatible string, by stripping off enclosing quotes/string options
and converting the contents (including rewriting escape sequences).
|
static java.lang.String |
preprocessFormatString(java.lang.String fmt)
Convert the Progress 4GL style character type format string into a form that is easier
to process.
|
private java.lang.String |
processDataString(java.lang.String data,
java.lang.String fmt)
Convert the input data into an output string that is formatted as
specified by the Progress 4GL style character type format string.
|
static java.lang.String |
progressToJavaString(java.lang.String progress)
Converts a Progress 4GL compatible string to the equivalent Java source
string, by stripping off enclosing quotes/string options and converting
the contents (including rewriting all escape sequences).
|
static java.lang.String |
progressToJavaString(java.lang.String progress,
boolean windows,
boolean isPathName)
Converts a Progress 4GL compatible string to the equivalent Java source string, by stripping
off enclosing quotes/string options and converting the contents (including rewriting all
escape sequences).
|
static character |
quoter()
No parameter quoter function implementation.
|
static character |
quoter(BaseDataType var)
General quoter function implementation without additional parameters.
|
static character |
quoter(BaseDataType var,
character customQuote)
Quoter function call for 2 parameters.
|
static character |
quoter(BaseDataType var,
character customQuote,
character customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(BaseDataType var,
character customQuote,
java.lang.String customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(BaseDataType var,
java.lang.String customQuote)
Quoter function call for 2 parameters.
|
static character |
quoter(BaseDataType var,
java.lang.String customQuote,
character customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(BaseDataType var,
java.lang.String customQuote,
java.lang.String customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(java.lang.String var)
General quoter function implementation without additional parameters.
|
static character |
quoter(java.lang.String var,
character customQuote)
Quoter function call for 2 parameters.
|
static character |
quoter(java.lang.String var,
character customQuote,
character customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(java.lang.String var,
character customQuote,
java.lang.String customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(java.lang.String var,
java.lang.String customQuote)
Quoter function call for 2 parameters.
|
static character |
quoter(java.lang.String var,
java.lang.String customQuote,
character customNull)
Quoter function implementation for 3 parameters.
|
static character |
quoter(java.lang.String var,
java.lang.String customQuote,
java.lang.String customNull)
Quoter function implementation for 3 parameters.
|
private static character |
quoterWorker(BaseDataType var,
java.lang.String customQuote,
java.lang.String customNull)
This is the core quoter function implementation.
|
character |
safeDuplicate()
Returns a clone of the current instance which has all
null
characters removed from its data (in particular, the data is truncated
starting at any null character). |
protected java.lang.String |
safeValue()
Returns the instance's value safely truncated at any
null
byte. |
static logical |
testBitAt(character data,
int index)
Tests a bit in the given position in the input array to determine if
that bit is a 0 or 1.
|
static logical |
testBitAt(character data,
int64 index)
Tests a bit in the given position in the input array to determine if
that bit is a 0 or 1.
|
static logical |
testBitAt(java.lang.String data,
int index)
Tests a bit in the given position in the input array to determine if
that bit is a 0 or 1.
|
static logical |
testBitAt(java.lang.String data,
int64 index)
Tests a bit in the given position in the input array to determine if
that bit is a 0 or 1.
|
java.lang.String |
toString()
Creates a string representation of the instance data with the default
Progress 4GL format of 'x(8)'.
|
java.lang.String |
toString(java.lang.String fmt)
Creates a string representation of the instance data using the user-
specified Progress 4GL format string.
|
java.lang.String |
toStringExport()
Creates a string representation of the instance data using the 'export'
format.
|
java.lang.String |
toStringMessage()
Creates a string representation of the instance data in a form that is
compatible with the
MESSAGE language statement. |
static character |
valueOf(BaseDataType bdt)
Convert any Progress compatible wrapper into a character object using the 'message' format
for the data type being converted.
|
static character |
valueOf(BaseDataType bdt,
character fmt)
Convert any Progress compatible wrapper into a character object using
the given format for the data type being converted.
|
static character |
valueOf(BaseDataType bdt,
java.lang.String fmt)
Convert any Progress compatible wrapper into a character object using
the given format for the data type being converted.
|
static character |
valueOf(boolean b)
Convert a
boolean into a character object using
the 'message' format for the logical data type. |
static character |
valueOf(boolean b,
character fmt)
Convert a
boolean into a character object using
the given format for the logical data type. |
static character |
valueOf(boolean b,
java.lang.String fmt)
Convert a
boolean into a character object using
the given format for the logical data type. |
static character |
valueOf(double num)
Convert a
double into a character object using
the 'message' format for the decimal data type. |
static character |
valueOf(double num,
character fmt)
Convert a
double into a character object using
the given format for the decimal data type. |
static character |
valueOf(double num,
java.lang.String fmt)
Convert a
double into a character object using
the given format for the decimal data type. |
static character |
valueOf(long num)
Convert an
int into a character object using
the 'message' format for the int64 data type. |
static character |
valueOf(long num,
character fmt)
Convert an
int into a character object using
the given format for the int64 data type. |
static character |
valueOf(long num,
java.lang.String fmt)
Convert an
int into a character object using
the given format for the int64 data type. |
static character |
valueOf(rowid r)
Convert a
rowid into a character object using
the 'message' format for the rowid data type. |
static character |
valueOf(java.lang.String s)
Convert a
String into a character object using
the 'message' format for the character data type. |
static character |
valueOf(java.lang.String s,
character fmt)
Convert a
String into a character object using
the given format for the character data type. |
static character |
valueOf(java.lang.String s,
java.lang.String fmt)
Convert a
String into a character object using
the given format for the character data type. |
assign, assign, assign, assign, caseSensitiveHashCode, compareTo, deepAssign, equalsCaseSensitively, getValue, hashCode, instantiateUnknown, isCaseSensitive, isEmbeddedNullAllowed, isUnknown, javaSpacifyNull, javaTruncateNull, maximum, minimum, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, overlay, progressSpacifyNull, readChar, readExternal, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, replaceEntry, setCaseSensitive, setTemporaryCaseSensitive, setUnknown, setValue, toJavaType, writeExternal
calcFormatLength, deepCopy, elementsOfType, equals, generateDefault, generateUnknown, getTypeName, incompatibleTypesOnConversion, initializeDefaultExtent, isUnknownValue, maximum, minimum, notUnknownValue, sameType
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobal
private static final java.lang.String defaultFormat
public character()
public character(BaseDataType value)
value
- The value to be used for this instance.public character(Text value)
Text
.value
- The value which needs to be copied.public character(Text value, boolean output)
Text
.
If the output
parameter is set to true
, it
means that the referenced value is saved, as the passed instance will
be passed to a function call, and the state might need to be updated
on function exit.value
- The value which needs to be copied.output
- Flag indicating if this instance is passed to as a reference
for an output parameter.public character(java.lang.String value)
String
value passed
in and which does not represent the unknown value
,
unless the value
argument is null
.value
- The character value of the resulting instance.public character(java.lang.String value, boolean caseSens)
String
value passed
in and which does not represent the unknown value
unless the value
argument is null
.value
- The character value of the resulting instance.caseSens
- Specifies whether this instance should use case sensitive
comparisons.public character(char ch)
char
value passed
in and which does not represent the unknown value
.ch
- The character value of the resulting instance.public character(character value)
String
value and
unknown value
that exactly matches that of the passed-in
instance.value
- The character and unknown value of the resulting instance.public static int64 asc(character c)
This method does not handle the case of user-specified source and/or target codepages as is possible in Progress.
c
- The character expression to convert (must be 1 character in
length).public static int64 asc(java.lang.String str)
This method does not handle the case of user-specified source and/or target codepages as is possible in Progress.
str
- The string to convert (must be 1 character in length).public static character chr(int64 i)
This method does not handle the case of user-specified source and/or target codepages as is possible in Progress.
i
- The int64 to convert.unknown value
if the input is
unknown value
.public static character chr(long i)
This method does not handle the case of user-specified source and/or target codepages as is possible in Progress.
i
- The long to convert.public static character fill(character c, NumberType num)
num
concatenated copies of a given string.c
- The string to be repeated.num
- The number of times to repeat.unknown value
if any
input is unknown value
or an empty string if
num
< 1.public static character fill(character c, int num)
num
concatenated copies of a given string.c
- The string to be repeated.num
- The number of times to repeat.unknown value
if any
input is unknown value
or an empty string if
num
< 1.public static character fill(character c, double num)
num
concatenated copies of a given string.c
- The string to be repeated.num
- The number of times to repeat.unknown value
if any
input is unknown value
or an empty string if
num
< 1.public static character fill(java.lang.String str, NumberType num)
num
concatenated copies of a given string.str
- The string to be repeated.num
- The number of times to repeat.unknown value
if any
input is unknown value
or an empty string if
num
< 1.public static character fill(java.lang.String str, double num)
num
concatenated copies of a given string.str
- The string to be repeated.num
- The number of times to repeat.unknown value
if any
input is unknown value
or an empty string if
num
< 1.public static character fill(java.lang.String str, int num)
num
concatenated copies of a given string.str
- The string to be repeated.num
- The number of times to repeat.unknown value
if any
input is unknown value
or an empty string if
num
< 1.public static character quoter(BaseDataType var)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
var
- The BaseDataType
variable to operate upon.public static character quoter(java.lang.String var)
This puts the character
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
var
- The String
variable to operate upon.public static character quoter()
public static character quoter(BaseDataType var, java.lang.String customQuote)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
Additionally a parameter representing a custom quote character
replacement is provided. If not null
, then the first
character of the given text will be used instead of the "
character.
A custom unknown value can only be given in the 3 parameter call.
var
- The BaseDataType
variable to operate uponcustomQuote
- The String
variable
that represents the custom quoter.Custom unknown
can only be given in 3 parameter call.public static character quoter(java.lang.String var, java.lang.String customQuote)
This puts the String
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
Additionally a parameter representing a custom quote character
replacement is provided. If not null
, then the first
character of the given text will be used instead of the "
character.
A custom unknown value can only be given in the 3 parameter call.
var
- The String
variable to operate uponcustomQuote
- The String
variable
that represents the custom quoter.Custom unknown
can only be given in 3 parameter call.public static character quoter(BaseDataType var, character customQuote)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
Additionally a parameter representing a custom character
replacement is provided. If not null
, then the first
character of the given text will be used instead of the "
character.
A custom unknown value can only be given in the 3 parameter call.
var
- The BaseDataType
variable to operate uponcustomQuote
- The String
variable
that represents the custom quoter.Custom unknown
can only be given in 3 parameter call.public static character quoter(java.lang.String var, character customQuote)
This puts the String
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
Additionally a parameter representing a custom character
replacement is provided. If not null
, then the first
character of the given text will be used instead of the "
character.
A custom unknown value can only be given in the 3 parameter call.
var
- The String
variable to operate uponcustomQuote
- The String
variable
that represents the custom quoter.Custom unknown
can only be given in 3 parameter call.public static character quoter(BaseDataType var, character customQuote, character customNull)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The BaseDataType
variable to operate upon.customQuote
- The custom character
quoter variable.customNull
- The custom character
unknown
replacement to be used.character
value
of the function.public static character quoter(java.lang.String var, character customQuote, character customNull)
This puts the String
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The String
variable to operate upon.customQuote
- The custom character
quoter variable.customNull
- The custom character
unknown
replacement to be used.character
value
of the function.public static character quoter(BaseDataType var, java.lang.String customQuote, character customNull)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The BaseDataType
variable to operate upon.customQuote
- The custom String
quoter variable.customNull
- The custom character
unknown
replacement to be used.character
value
of the function.public static character quoter(java.lang.String var, java.lang.String customQuote, character customNull)
This puts the String
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The String
variable to operate upon.customQuote
- The custom String
quoter variable.customNull
- The custom character
unknown
replacement to be used.character
value
of the function.public static character quoter(BaseDataType var, character customQuote, java.lang.String customNull)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The BaseDataType
variable to operate upon.customQuote
- The custom character
quoter variable.customNull
- The custom String
unknown
replacement to be used.character
value
of the function.public static character quoter(java.lang.String var, character customQuote, java.lang.String customNull)
This puts the String
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The String
variable to operate upon.customQuote
- The custom character
quoter variable.customNull
- The custom String
unknown
replacement to be used.character
value
of the function.public static character quoter(BaseDataType var, java.lang.String customQuote, java.lang.String customNull)
This puts the character
value of the variable between
double quotes if the value is not unknown
or replace it
with '?' if the value is unknown
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The BaseDataType
variable to operate upon.customQuote
- The custom String
quoter variable.customNull
- The custom String
unknown
replacement to be used.character
value
of the function.public static character quoter(java.lang.String var, java.lang.String customQuote, java.lang.String customNull)
This puts the String
value of the variable between
double quotes if the value is not null
or replace it
with '?' if the value is null
.
Additionally, a parameter representing a custom quote character
is provided. If not null
, then the first character
of the given text will be used instead of the "
character.
A custom unknown value can also be provided. If
not null
, then the given text will be used instead
of the default ? unknown
replacement to be used.
var
- The String
variable to operate upon.customQuote
- The custom String
quoter variable.customNull
- The custom String
unknown
replacement to be used.character
value
of the function.public static logical testBitAt(character data, int64 index)
This feature supports an undocumented Progress built-in function called _cbit().
data
- A string with 0 or more characters.index
- The bit position to test.false
if the empty string
is input or if a negative index is specified. For any string
of > 0 bytes length, the return is true
if the
bit in the specified position is 1 and false
if
it is 0.public static logical testBitAt(character data, int index)
This feature supports an undocumented Progress built-in function called _cbit().
data
- A string with 0 or more characters.index
- The bit position to test.false
if the empty string
is input or if a negative index is specified. For any string
of > 0 bytes length, the return is true
if the
bit in the specified position is 1 and false
if
it is 0.public static logical testBitAt(java.lang.String data, int64 index)
This feature supports an undocumented Progress built-in function called _cbit().
data
- A string with 0 or more characters.index
- The bit position to test.false
if the empty string
is input or if a negative index is specified. For any string
of > 0 bytes length, the return is true
if the
bit in the specified position is 1 and false
if
it is 0.public static logical testBitAt(java.lang.String data, int index)
This feature supports an undocumented Progress built-in function called _cbit().
data
- A string with 0 or more characters.index
- The bit position to test.false
if the empty string
is input or if a negative index is specified. For any string
of > 0 bytes length, the return is true
if the
bit in the specified position is 1 and false
if
it is 0.public static character valueOf(double num)
double
into a character object using
the 'message' format for the decimal
data type.num
- The data to convert.public static character valueOf(long num)
int
into a character object using
the 'message' format for the int64
data type.num
- The data to convert.public static character valueOf(java.lang.String s)
String
into a character object using
the 'message' format for the character
data type.s
- The data to convert.public static character valueOf(boolean b)
boolean
into a character object using
the 'message' format for the logical
data type.b
- The data to convert.public static character valueOf(rowid r)
rowid
into a character object using
the 'message' format for the rowid
data type.
The returned value is guaranteed to have:
As the actual internal storage is a java signed long
and the utility method Long.toString()
will convert
negative values into string representations prefixed with '-' some
special code is needed to warp back the negative values and treat the
internal data as being an unsigned int.
r
- The data to convert.public static character valueOf(BaseDataType bdt)
bdt
- The data to convert.public static character valueOf(double num, java.lang.String fmt)
double
into a character object using
the given format for the decimal
data type.num
- The data to convert.fmt
- The format string to use.public static character valueOf(long num, java.lang.String fmt)
int
into a character object using
the given format for the int64
data type.num
- The data to convert.fmt
- The format string to use.public static character valueOf(java.lang.String s, java.lang.String fmt)
String
into a character object using
the given format for the character
data type.s
- The data to convert.fmt
- The format string to use.public static character valueOf(boolean b, java.lang.String fmt)
boolean
into a character object using
the given format for the logical
data type.b
- The data to convert.fmt
- The format string to use.public static character valueOf(BaseDataType bdt, java.lang.String fmt)
bdt
- The data to convert.fmt
- The format string to use.public static character valueOf(double num, character fmt)
double
into a character object using
the given format for the decimal
data type.num
- The data to convert.fmt
- The format string to use.public static character valueOf(long num, character fmt)
int
into a character object using
the given format for the int64
data type.num
- The data to convert.fmt
- The format string to use.public static character valueOf(java.lang.String s, character fmt)
String
into a character object using
the given format for the character
data type.s
- The data to convert.fmt
- The format string to use.public static character valueOf(boolean b, character fmt)
boolean
into a character object using
the given format for the logical
data type.b
- The data to convert.fmt
- The format string to use.public static character valueOf(BaseDataType bdt, character fmt)
bdt
- The data to convert.fmt
- The format string to use.public static java.lang.String fromExportString(java.lang.String export)
export
- A string with the contents in export format as created by
toStringExport()
.public static java.lang.String progressToJavaString(java.lang.String progress) throws java.lang.IllegalArgumentException
Escaped characters (using either the tilde or the backslash character) and special formations will be converted to native representations and any characters that need to be escaped will be so escaped. In particular, almost all usage of the backslash is compatible between Progress and Java, so only those constructs that must be different will be handled differently.
The following conversions will be made:
~b to '\b' - backspace ~t to '\t' - horizontal tab ~n to '\n' - linefeed ~f to '\f' - formfeed ~r to '\r' - carriage return ~" to '\"' - double quote ~' to '\'' - single quote ~\ to '\\' - backslash ~~ to '~' - single tilde ~{ to '{' - left curly brace ~E to '\033' - the ASCII escape char ~nnn to '\nnn' - octal escape sequence (nnn is a 3 digit octal number) '' to '\'' - single quote (only when inside a string that was enclosed by single quotes) "" to '\"' - double quote (only when inside a string that was enclosed by double quotes) \~ to '~' - single tilde \\ to '\\' - backslash \{ to '{' - left curly brace \E to '\033' - the ASCII escape char
Any other escape sequence that is unrecognized will result in the tilde or backslash being dropped and the following character output unchanged which is the same behavior as Progress.
The final result when output will be output inside enclosing double quotes but there is no need for those quotes inside the AST form.
progress
- The Progress compatible string as parsed from the source
file.java.lang.IllegalArgumentException
public static java.lang.String progressToJavaString(java.lang.String progress, boolean windows, boolean isPathName) throws java.lang.IllegalArgumentException
Escaped characters (using either the tilde or the backslash character) and special formations will be converted to native representations and any characters that need to be escaped will be so escaped. In particular, almost all usage of the backslash is compatible between Progress and Java, so only those constructs that must be different will be handled differently.
The following conversions will be made:
~b to '\b' - backspace ~t to '\t' - horizontal tab ~n to '\n' - linefeed ~f to '\f' - formfeed ~r to '\r' - carriage return ~" to '\"' - double quote ~' to '\'' - single quote ~\ to '\\' - backslash ~~ to '~' - single tilde ~{ to '{' - left curly brace ~E to '\033' - the ASCII escape char ~nnn to '\nnn' - octal escape sequence (nnn is a 3 digit octal number) '' to '\'' - single quote (only when inside a string that was enclosed by single quotes) "" to '\"' - double quote (only when inside a string that was enclosed by double quotes) \~ to '~' - tilde \\ to '\\' - backslash \{ to '{' - left curly brace \E to '\033' - the ASCII escape char
Any other escape sequence that is unrecognized will result in the tilde or backslash being dropped and the following character output unchanged which is the same behavior as Progress.
The final result when output will be output inside enclosing double quotes but there is no need for those quotes inside the AST form.
Note:
Do NOT SQL postprocess the resulting string before it is written to java source!
progress
- The Progress compatible string as parsed from the source file.windows
- The flag indicating the OS is Windows for possible '\' characters.isPathName
- The flag indicating the special processing for path elements in Windows.java.lang.IllegalArgumentException
public static java.lang.String javaRuntimeToProgressSourceString(java.lang.String contents) throws java.lang.IllegalArgumentException
If the runtime Java string is a converted version of a 4GL string literal, then the result of this call is not guaranteed to generate the exact same literal representation. This is due to the fact that Progress has two escape characters (tilde and backslash) on input but on output to Java there is only a single escape character (backslash). For this reason, all mappings are to the tilde escaped version since this will work on UNIX/Linux and Windows in the 4GL.
The following conversions will be made:
'\b' to ~b - backspace '\t' to ~t - horizontal tab '\n' to ~n - linefeed '\f' to ~f - formfeed '\r' to ~r - carriage return '\"' to ~" - double quote '\'' to ~' - single quote '\\' to ~\ - backslash '~' to ~~ - tilde '{' to ~{ - left curly brace '\033' to ~E - the ASCII escape char control chars to ~nnn - octal escape sequence (nnn is a 3 digit octal number)
The final result when output will be output inside enclosing double quotes.
contents
- The Java runtime string which should be encoded.java.lang.IllegalArgumentException
public static java.lang.String parseProgressCharLiteral(java.lang.String progress, boolean windows)
Escaped characters (using either the tilde or the backslash character) and special formations will be converted to native representations and any characters that need to be escaped will be so escaped.
The following conversions will be made:
~b to '\b' - backspace ~t to '\t' - horizontal tab ~n to '\n' - linefeed ~f to '\f' - formfeed ~r to '\r' - carriage return ~" to '"' - double quote ~' to ''' - single quote ~\ to '\' - backslash ~~ to '~' - single tilde ~{ to '{' - left curly brace ~E to '\033' - the ASCII escape char ~nnn to '\nnn' - octal escape sequence (nnn is a 3 digit octal number) '' to ''' - single quote (only when inside a string that was enclosed by single quotes) "" to '"' - double quote (only when inside a string that was enclosed by double quotes) \~ to '~' - tilde \\ to '\' - backslash \{ to '{' - left curly brace \E to '\033' - the ASCII escape char
Any other escape sequence that is unrecognized will result in the tilde or backslash being dropped and the following character output unchanged which is the same behavior as Progress.
The final result must be encodeToJavaSource
when it will be output inside
enclosing double quotes in a java source file.
progress
- The Progress compatible string as parsed from the source file.
true
if additional escaping for writing the result into a java source
file is needed. If false
the result is the normal text representation
of the literal used at runtime or if supplementary processing is needed, in which
case must be applied.public static java.lang.String encodeToJavaSource(java.lang.String data)
data
- The runtime string.public static java.lang.String preprocessFormatString(java.lang.String fmt)
DO NOT directly use the result of this expansion for calculation of the format
length without also processing any the unescaped tildes that are present in the
resulting returned format string. If you are looking for the format length, please
use the formatLength()
method of this class.
fmt
- The Progress 4GL format string for a character data type.void forceBytes(byte[] data)
The data will be converted to a string and stored as the instance's data. DO NOT USE THIS METHOD except for duplicating the 4GL "null character leaking" behavior.
data
- The bytes to force in.public character safeDuplicate()
null
characters removed from its data (in particular, the data is truncated
starting at any null
character).null
characters.protected java.lang.String safeValue()
null
byte.null
bytes.public java.lang.String defaultFormatString()
defaultFormatString
in class BaseDataType
public int formatLength(java.lang.String fmt)
formatLength
in class BaseDataType
fmt
- The format string.public BaseDataType duplicate()
clone()
method but returns an
instance of BaseDataType
and doesn't throw the
CloneNotSupportedException
.duplicate
in class BaseDataType
public BaseDataType instantiateDefault()
instantiateDefault
in class BaseDataType
public java.lang.String toStringMessage()
MESSAGE
language statement. If the
instance represents the unknown value
, a '?' will be
returned.toStringMessage
in class BaseDataType
public java.lang.String toStringExport()
unknown value
, a '?' will be returned. Any instances of
double quotes inside the string will be doubled up on output.toStringExport
in class BaseDataType
public java.lang.String toString()
unknown value
, a '?' will be returned.toString
in class java.lang.Object
public java.lang.String toString(java.lang.String fmt)
null
, then a default format string of 'x(8)' will be
used. If the instance represents the unknown value
,
a '?' will be returned.toString
in class BaseDataType
fmt
- The Progress 4GL format string for a character data type.protected BaseDataType instantiateDefaultExtent()
instantiateDefaultExtent
in class BaseDataType
private java.lang.String processDataString(java.lang.String data, java.lang.String fmt)
Recognized format specifier characters are x, X, n, N, a, A, 9 and !. The presence of any unescaped (with tilde) instance of one of these characters in the format string means that should there be a corresponding character (at the same format specifier index) in the data string, it will be copied to the output string at that same position. No transformation of the data is done except for the ! specifier which causes the data character to be uppercased before output.
Any non-recognized format specifier and any escaped character (including escaped format specifiers) are considered user-defined "fill" characters. These characters are copied from the format string (not the data string) into the output string. They are copied unchanged. If present in the input string they are ignored as non-significant characters. Any unescaped tildes are dropped (not copied to the output).
The input data will be copied to a location in the output string based on the simple index position in the input data AND the relative position of each format specifier. The presence of fill characters does not change the relative position of format specifier characters. This means that the 1st character in the input string will be copied on output to the location of the 1st format specifier character in the format string, which may not be the first position in the output string (if there are fill characters in the format string before the first format specifier). The 2nd character in the input string will be copied on output to the location of the 2nd format specifier, which may not immediately follow the 1st data character in the output string if there are intervening fill characters between the first and second format specifiers.
If there is less data characters (in the input string) than format specifier characters (in the format string), then a ' ' (space) will be output for each trailing format specifier position which has no data to be copied. This is a kind of padding.
If there are more data characters (in the input string) than format specifier characters (in the format string), then the output string will be truncated, not copying those extra data characters (in the input string) to the output string.
The output string length will always be equivalent to the size of the format string less any dropped tilde escape characters.
data
- The input string.fmt
- The Progress 4GL format string for a character data type.private static character fillWorker(character ch, int num, boolean cs)
num
concatenated copies of a
given string.ch
- The string to be repeated.num
- The number of times to repeat.unknown value
if any input is
unknown
value or an empty string if num
< 1.private static character quoterWorker(BaseDataType var, java.lang.String customQuote, java.lang.String customNull)
?
character if the value is unknown
. If the variable is a
character
type, any contained double quote character will be doubled (another
double quote character will be added next to it - Progress behavior).
The caller can provide replacement characters to use instead of the double quote character
(") and instead of the default unknown
character ?
.
var
- The BaseDataType
variable to operate upon.customQuote
- The custom quoter character to be used. If null
, the default is the
double quote character.customNull
- The custom unknown text replacement to be used. If null
the default
is '?'.unknown
, if the input is
unknown
.public static void main(java.lang.String[] args)