|
Oracle Fusion Middleware extensions for Applications Core API Reference 11g Release 1 (11.1.2) E22562-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.apps.fnd.applcore.oaext.model.UTF8NameConverter
public final class UTF8NameConverter
Utility class for conversion between a UTF-8 string and the encoded string that conforms to the naming scheme specified by ISO 9660. Only names encoded by this class can be decoded by this class.
The encoding algorithm used by encode
is essentially a modified
version of URL encoding:
Please note that although ISO 9660 allows ".", the encoded strings generated
by this class do not have this character, mainly because "." is often
reserved as a delimiter. In addition, the
encoder/decoder in this class is case-sensitive. To generated a string only
in upper case, convert the string to upper case before calling
encode
.
The method convert
provides a convenient way to create
a string suitable for being an identifier in ISO 9660 format.
This method is optimized for strings that contain commonly used characters,
including the underscore character "_". Please note that a string converted
by this method cannot be restored (decoded) back to its original.
There is a possibility that two strings that are not equal before conversion
will become equal after the conversion. For example, "5FStr_2A" and
"Str*" will both be converted to "_5FStr_2A". In general, this collision
can be prevented by avoiding the strings that start with "5F".
The following is how this method converts a string:
encode
encode
, with "_5F" if it has been encoded by
encode
Nested Class Summary | |
---|---|
static interface |
UTF8NameConverter.IdentifierEncoder
Encoder for encoding parts of the an identifier. |
Method Summary | |
---|---|
static java.lang.String |
convert(java.lang.String s)
Converts the given string to a string that can generally be used as a identifier for programmatic access. |
static java.lang.String |
convert(java.lang.String s,
boolean alwaysPrefixedWithUnderscore)
Converts the given string to a string that can generally be used as a identifier for programmatic access. |
static java.lang.String |
convertJaxbSafe(java.lang.String s)
Converts a String to an identifier that won't cause JAXB compilation to fail when underscore is treated as a word separator. |
static java.lang.String |
decode(java.lang.String s)
Decodes a string encoded by encode . |
static java.lang.String |
encode(java.lang.String s)
Converts a string into ISO 9660 format with case preserved. |
static java.lang.String |
getIdentifier(java.lang.String head,
java.lang.String tail,
int maxNumberOfBytes,
boolean insertHexHashCodeWhenNeeded,
UTF8NameConverter.IdentifierEncoder encoder,
java.lang.String... bodies)
Gets an identifier that can generally be used as a file name. |
static java.lang.String |
makeJaxbSafe(java.lang.String r)
Modifies a String returned by convert(String) to make it JAXB safe. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String encode(java.lang.String s)
s
- the string to be converted
java.lang.NullPointerException
- if the given string is null
java.lang.IllegalArgumentException
- if the encoded string has more than 255
characters
java.lang.UnsupportedOperationException
- if utf-8 is not supported in this
platformpublic static java.lang.String decode(java.lang.String s)
encode
.
s
- the encoded string
java.lang.NullPointerException
- if the given string is null
java.lang.UnsupportedOperationException
- if UTF-8 is not supported in this platformpublic static java.lang.String convert(java.lang.String s)
s
- the string to be converted
java.lang.NullPointerException
- if the given string is nullpublic static java.lang.String convert(java.lang.String s, boolean alwaysPrefixedWithUnderscore)
s
- the string to be convertedalwaysPrefixedWithUnderscore
- true if the return String should always
be prefixed with '_'; false if the
String should be prefixed only when
then first character is a numeric
digit
java.lang.NullPointerException
- if the given string is nullpublic static java.lang.String convertJaxbSafe(java.lang.String s)
s
- the String to be converted
java.lang.NullPointerException
- if the given String is nullpublic static java.lang.String getIdentifier(java.lang.String head, java.lang.String tail, int maxNumberOfBytes, boolean insertHexHashCodeWhenNeeded, UTF8NameConverter.IdentifierEncoder encoder, java.lang.String... bodies)
Depending on the maximum number of bytes given, the head, tail or body text may be shortened. The body text, if shortened, will be shortened before encoding. The shortening process involves removing the middle portion of a String until it is short enough. Since the head, tail and the body text are shortened individually, the head or tail can almost always remain intact if they are relatively short compared to the body.
When shortening is needed to reduce the length, the hash code (in base 16) may be inserted into the identifier to increase the likelihood of uniqueness. The hash code is based on the original head, body text and tail before encoding. If this option is on, the given maximum number of bytes is adjusted to accommodate the length of the hash code.
head
- the head; null if there's nonetail
- the tail; null if there's nonemaxNumberOfBytes
- the maximum number of bytes of the return String.
The maximum number of bytes is based on the default
character encoding of the platform.insertHexHashCodeWhenNeeded
- true if the hash code of (head + bodies
+ tail) should be inserted into the identifier to
increase the likelihood of being unique when
shortening is neededencoder
- the encoderbodies
- the list of Strings that will be concatenated together
java.lang.IllegalArgumentException
- if the given body list is null or empty,
, if the maximum number of bytes
given is less than 28, or if the given
encoder is nullpublic static java.lang.String makeJaxbSafe(java.lang.String r)
convert(String)
to make it JAXB safe.
r
- the String to be modified
|
Oracle Fusion Middleware extensions for Applications Core API Reference 11g Release 1 (11.1.2) E22562-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |