|
Collaboration API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.filenet.bso.api.util.BsoByteArrayWithCharset
Class to convert a byte array into a string with appropriate "guessing" used to deduce the proper charset if one is not known when an instance is constructed. If the charset is not specified then a guess is made by...
Of course, if the charset is known when the instance is constructed, then that will be used with
no guessing involved. Unfortunately, Apache 2.0.52 has an unhelpful feature of adding a default charset
of ISO-8859-1
to all text/plain, text/html, etc., type files that don't have a charset, so
that particular charset will be ignored if passed in the constructor.
After the string is decoded using a guessed at charset, some strings will contain some indication of
the actual charset that should be used to decode them (hopefully, this will be pretty close to the
start of the string!). Examples of this would be the encoding argument of an XML string, the
metadata content-type argument in an HTML string or an {$encoding} command in one of our email templates.
In this case, the resetCharset
method may be used to return a redecoded string.
This makes some attempts to handle synchronization in a multithreaded environment, but note that
the getCharset
value might not match the decoding charset used for the
getString
string if some other thread has called resetCharset
inbetween.
Constructor Summary | |
BsoByteArrayWithCharset(byte[] bytes)
Construct an BsoByteArrayWithCharset and guess at the proper charset. |
|
BsoByteArrayWithCharset(byte[] bytes,
java.lang.String charset)
Construct an BsoByteArrayWithCharset with a known charset. |
Method Summary | |
byte[] |
getBytes()
Return the byte array. |
java.lang.String |
getCharset()
Return the charset as it is currently assumed. |
java.lang.String |
getString()
Return the string version of the byte array. |
java.lang.String |
resetCharset(java.lang.String charset)
Attempt to reconvert the string using a new charset. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BsoByteArrayWithCharset(byte[] bytes)
BsoByteArrayWithCharset
and guess at the proper charset.bytes
- a byte array encoding using an unknown charsetpublic BsoByteArrayWithCharset(byte[] bytes, java.lang.String charset)
BsoByteArrayWithCharset
with a known charset. This charset may
be null
, in which case the normal guessing is made.bytes
- a byte arraycharset
- the charset to use when decoding the byte array into a string. This
may be null
if the charset is not known.Method Detail |
public byte[] getBytes()
public java.lang.String resetCharset(java.lang.String charset)
charset
does not match the known charset. This may be called
more than once, but charset
must be the same each time.charset
- the new charset decoding to use (cannot be null
)public java.lang.String getCharset()
null
if the charset
was guessed to be the system default charset. If resetCharset
has already been
called, this will return its charset.
Note that this method is really not safe to use in a multithreaded environment since the charset
returned might not match that used in the decoding of the getString
's value if some
other thread has called resetCharset
inbetween.
public java.lang.String getString()
|
Collaboration API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |