public class I18nOps
extends java.lang.Object
Progress Function Java Equivalent --------------------- ---------------------- codepage-convertcodePageConvert(T, java.lang.String, java.lang.String)
get-codepagesgetCodePages()
System Handle:Attribute Java Equivalent ------------------------- ---------------------- session:charsetgetCharset()
(get) session:cpcasegetCPCase()
(get) session:cpcollgetCPColl()
(get) session:cpinternalgetCPInternal()
(get) session:cploggetCPLog()
(get) session:cpprintgetCPPrint()
(get) session:cprcodeingetCPRCodeIn()
(get) session:cprcodeoutgetCPRCodeOut()
(get) session:cpstreamgetCPStream()
(get) session:cptermgetCPTerm()
(get) rcode-info:codepagegetCodePage()
(get)
Modifier and Type | Class and Description |
---|---|
private static class |
I18nOps.ContextContainer
Simple container that stores and returns a context-local instance of
the global work area.
|
private static class |
I18nOps.WorkArea
Stores global data relating to the state of the current context.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABL_LATIN1
The 4GL name for ISO8859-1 / Latin-1 character encoding.
|
static java.lang.String |
CONVERSION_MAP_FILE
The standard name of the 4GL file containing the conversion map.
|
static java.util.Map<java.lang.String,java.lang.String> |
convmap2Java
Maps code pages from currently defined default convmap.cp to supported Java code page names.
|
static java.util.Map<java.lang.String,java.lang.String> |
convmap2JavaDefault
Maps code pages from defined default convmap.cp to supported Java code page names.
|
static java.util.Map<java.lang.String,java.lang.String> |
convmap2Progress
Maps code pages from supported Java code page names to Progress compatible code pages.
|
static java.lang.String |
CP_UNDEFINED
Special code page meaning no code page conversion for either source or target.
|
static java.lang.String |
JAVA_LATIN1
The Java name for ISO-8859-1 / Latin-1 character encoding.
|
private static I18nOps.ContextContainer |
work
Stores context-local state variables.
|
Constructor and Description |
---|
I18nOps() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
_getCharset()
Reports the default charset used by the JVM.
|
static java.lang.String |
_getCPInternal()
Reports the current value of the CPINTERNAL attribute.
|
static java.lang.String |
_getCPStream()
Reports the codepage used for streams (the equivalent of the CPSTREAM 4GL attribute, which
reports the value set using the
-cpstream startup parameter. |
static int |
asc(int intChValue,
java.lang.String targetCP,
java.lang.String sourceCP,
java.lang.String defaultCP)
Converts the given char value to integer character code according to source and target
codepage values.
|
static int |
asc(java.lang.String chValue,
java.lang.String targetCP,
java.lang.String sourceCP)
Converts the given char value to integer character code according to source and target codepage values.
|
static java.lang.String |
chr(int ascCode,
java.lang.String targetCP,
java.lang.String sourceCP)
Converts the given integer character code to char value according to source and target
codepage values (double byte enabled).
|
static int |
chr(int ascCode,
java.lang.String targetCP,
java.lang.String sourceCP,
java.lang.String defaultCP)
Converts the given integer character code to char value according to source and target
codepage values.
|
static <T extends Text> |
codePageConvert(T source,
java.lang.String targetCP,
java.lang.String sourceCP)
Converts the given text using the specified codepage, assuming the text is encoded with
the given source codepage.
|
static java.lang.String |
codePageConvertWorker(java.lang.String text,
java.lang.String srcCP,
java.lang.String tarCP)
Deprecated.
|
private static java.lang.String |
get4glCharacter(int ascCode,
java.nio.charset.Charset charset)
Use the specified
charset to construct a string containing the code of character passed as
first parameter. |
static character |
getCharset()
Reports the default charset used by the JVM.
|
private static java.lang.String |
getCharsetNative()
Reports the current value of the JVM charset properly mapped to valid 4GL code page.
|
static character |
getCodePage()
Reports the codepage used for r-code file systems handle.
|
static character |
getCodePages()
Gets the comma separated list of the codepages supported by the conversion map for the
Progress compatible environment.
|
static character |
getCPCase()
Gets the value of the SESSION:CPCASE attribute.
|
static character |
getCPColl()
Gets the value of the SESSION:CPCOLL attribute.
|
static character |
getCPInternal()
Reports the current value of the CPINTERNAL attribute.
|
static character |
getCPLog()
Gets the value of the SESSION:CPLOG attribute.
|
static character |
getCPPrint()
Gets the value of the SESSION:CPPRINT attribute.
|
static character |
getCPRCodeIn()
Gets the value of the SESSION:CPRCODEIN attribute.
|
static character |
getCPRCodeOut()
Gets the value of the SESSION:CPRCODEOUT attribute.
|
static character |
getCPStream()
Reports the codepage used for streams (the equivalent of the CPSTREAM 4GL attribute), which
reports the value set using the
-cpstream startup parameter. |
static character |
getCPTerm()
Gets the value of the SESSION:CPTERM attribute.
|
static java.lang.String |
getJavaCharset()
Reports the default charset used by the JVM (Java mapping).
|
static java.lang.String |
getJavaCharset(character proCharset)
Reports the JVM charset that maps to the 4GL code page.
|
static java.lang.String |
getJavaCharset(java.lang.String proCharset) |
private static java.lang.String |
getNativeCharacter(int charCode,
java.nio.charset.Charset charset)
Helper to convert the character code from its integer value into string in Java native representation.
|
static java.lang.String |
getStringWithBomCheck(byte[] data,
int offset,
int len)
Analyze the first bytes of the
data stream for BOM markers. |
static long |
initReferent(java.lang.Class<?> referentClass)
Initializes supplied class (aka referent class) for the purpose of i18n.
|
static boolean |
isSupported(java.lang.String cpName)
Checks if the given code page name in currently defined convmap registry.
|
static boolean |
prevalidateData(byte[] data,
int offset,
int len,
java.lang.String oecp)
Prevalidate the byte array before allowing the Java charset to decode it to a string.
|
private static int |
raiseErrorAndReturn(int errCode,
java.lang.String p1,
java.lang.String p2,
java.lang.String p3)
This function WILL return value in NO-ERROR mode even if a fatal condition occurred.
|
public static final java.lang.String ABL_LATIN1
public static final java.lang.String JAVA_LATIN1
public static final java.util.Map<java.lang.String,java.lang.String> convmap2JavaDefault
public static final java.util.Map<java.lang.String,java.lang.String> convmap2Java
public static final java.util.Map<java.lang.String,java.lang.String> convmap2Progress
public static final java.lang.String CP_UNDEFINED
public static final java.lang.String CONVERSION_MAP_FILE
private static final I18nOps.ContextContainer work
public static character getCodePages()
In original environment the map is defined either in convmap.cp
file or
by the -convmap
startup parameter for current ABL session.
public static boolean isSupported(java.lang.String cpName)
cpName
- The name of the Progress code page name.
Can be passed with lower caseTRUE
is code page is in current convmap,
FALSE
otherwise.public static <T extends Text> T codePageConvert(T source, java.lang.String targetCP, java.lang.String sourceCP)
source
- The text to be converted.targetCP
- The target codepage.sourceCP
- The source codepage. If the text is a longchar
instance, then the text's internal codepage is used.@Deprecated public static java.lang.String codePageConvertWorker(java.lang.String text, java.lang.String srcCP, java.lang.String tarCP)
text
- The text to be converted.srcCP
- The source codepage.tarCP
- The target codepage.public static int chr(int ascCode, java.lang.String targetCP, java.lang.String sourceCP, java.lang.String defaultCP)
ascCode
- The key code to be converted.targetCP
- The target codepage of the char to return (Progress code page name).sourceCP
- The source codepage of the integer key code (Progress code page name).defaultCP
- The default codepage to be used when target or source codepages is invalid.
This is the Java code page name which must be always valid.public static java.lang.String chr(int ascCode, java.lang.String targetCP, java.lang.String sourceCP)
ascCode
- The key code to be converted.targetCP
- The target codepage of the char to return (Progress code page name).sourceCP
- The source codepage of the integer key code (Progress code page name).private static java.lang.String get4glCharacter(int ascCode, java.nio.charset.Charset charset)
charset
to construct a string containing the code of character passed as
first parameter.ascCode
- The code (double byte supported) of the character to be converted.charset
- The charset to be used in conversion.ascCode
is negative or charset
is somehow
unable to process the input, null
is returned.public static int asc(int intChValue, java.lang.String targetCP, java.lang.String sourceCP, java.lang.String defaultCP)
intChValue
- The character value to be converted packed into int.targetCP
- The target codepage of the integer key code to return (Progress code page name).sourceCP
- The source codepage of the char (Progress code page name).defaultCP
- The default codepage to be used when target or source codepages is invalid.
This is the Java code page name which must be always valid.public static int asc(java.lang.String chValue, java.lang.String targetCP, java.lang.String sourceCP)
chValue
- The character to convert back to char point.targetCP
- The target codepage, if set conversion from source codepage is done before (Progress code
page name).sourceCP
- The source codepage, the char point is relative to this (Progress code page name).private static int raiseErrorAndReturn(int errCode, java.lang.String p1, java.lang.String p2, java.lang.String p3)
errCode
- The code of the error to be raised.p1
- The first parameter.p3
- The second parameter.public static character getCPInternal()
If the 4GL environment is actually configured for UTF-8, then this approach won't work. If the default codepage name for the JVM is not UTF-8, it is assumed that the codepage has been overriden already (at JVM startup). In that case, the value reported by the JVM is returned unchanged.
public static java.lang.String _getCPInternal()
If the 4GL environment is actually configured for UTF-8, then this approach won't work. If the default codepage name for the JVM is not UTF-8, it is assumed that the codepage has been overridden already (at JVM startup). In that case, the value reported by the JVM is returned unchanged.
public static character getCharset()
public static java.lang.String _getCharset()
public static java.lang.String getJavaCharset()
public static java.lang.String getJavaCharset(character proCharset)
proCharset
- The Progress code pagepublic static java.lang.String getJavaCharset(java.lang.String proCharset)
public static character getCPStream()
-cpstream
startup parameter.public static java.lang.String _getCPStream()
-cpstream
startup parameter. String returning
version.public static character getCPCase()
public static character getCPColl()
public static character getCPLog()
public static character getCPPrint()
public static character getCPRCodeIn()
public static character getCPRCodeOut()
public static character getCPTerm()
public static character getCodePage()
public static java.lang.String getStringWithBomCheck(byte[] data, int offset, int len)
data
stream for BOM markers. If one is detected, the appropriate
charset is ued to decode it and the resulting string is returned. If no BOM is detected, the default
charset is used.data
- The data to be decoded.offset
- the offset where the returned string startslen
- The number of bytes to be processed. This might not be the actual size of the returned string
because of BOM or multibyte character encoding.data
bytes, decoded automatically with detected charset.public static boolean prevalidateData(byte[] data, int offset, int len, java.lang.String oecp)
data
- The byte array to be validated.offset
- the offset where the returned string startslen
- The number of bytes to be processed. This might not be the actual size of the returned string
because of BOM or multibyte character encoding.oecp
- The original CP to be used in validation (only used for displaying OE errors).
Not Java codepage.true
if the data passed prevalidation. Otherwise false
is returned.public static long initReferent(java.lang.Class<?> referentClass)
CURRENT-LANGUAGE@
session
variable.referentClass
- The referent class.private static java.lang.String getCharsetNative()
Always return valid 4GL compatible charset or UNKNOWN one.
private static java.lang.String getNativeCharacter(int charCode, java.nio.charset.Charset charset)
charCode
- The integer to convert.String
containing the character whose code was sent as parameter.