| java.lang.Object org.apache.poi.hpsf.Variant org.apache.poi.hpsf.VariantSupport
VariantSupport | public class VariantSupport extends Variant (Code) | | Supports reading and writing of variant data.
FIXME (3): Reading and writing should be made more
uniform than it is now. The following items should be resolved:
Reading requires a length parameter that is 4 byte greater than the
actual data, because the variant type field is included.
Reading reads from a byte array while writing writes to an byte array
output stream.
author: Rainer Klute author: href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de> since: 2003-08-08 version: $Id: VariantSupport.java 489730 2006-12-22 19:18:16Z bayard $ |
Method Summary | |
public static String | codepageToEncoding(int codepage) Turns a codepage number into the equivalent character encoding's
name.
Parameters: codepage - The codepage number The character encoding's name. | public static boolean | isLogUnsupportedTypes() Checks whether logging of unsupported variant types warning is turned
on or off.
true if logging is turned on, elsefalse . | public static Object | read(byte[] src, int offset, int length, long type, int codepage) Reads a variant type from a byte array.
Parameters: src - The byte array Parameters: offset - The offset in the byte array where the variantstarts Parameters: length - The length of the variant including the varianttype field Parameters: type - The variant type to read Parameters: codepage - The codepage to use to write non-wide strings A Java object that corresponds best to the variantfield. | public static void | setLogUnsupportedTypes(boolean logUnsupportedTypes) | public static int | write(OutputStream out, long type, Object value, int codepage) Writes a variant value to an output stream. | protected static void | writeUnsupportedTypeMessage(UnsupportedVariantTypeException ex) Writes a warning to System.err that a variant type is
unsupported by HPSF. |
unsupportedMessage | protected static List unsupportedMessage(Code) | | Keeps a list of the variant types an "unsupported" message has already
been issued for.
|
codepageToEncoding | public static String codepageToEncoding(int codepage) throws UnsupportedEncodingException(Code) | | Turns a codepage number into the equivalent character encoding's
name.
Parameters: codepage - The codepage number The character encoding's name. If the codepage number is 65001, the encoding name is "UTF-8". All other positive numbers are mapped to"cp" followed by the number, e.g. if the codepage number is 1252 the returned character encoding name will be "cp1252". exception: UnsupportedEncodingException - if the specified codepage isless than zero. |
isLogUnsupportedTypes | public static boolean isLogUnsupportedTypes()(Code) | | Checks whether logging of unsupported variant types warning is turned
on or off.
true if logging is turned on, elsefalse . |
read | public static Object read(byte[] src, int offset, int length, long type, int codepage) throws ReadingNotSupportedException, UnsupportedEncodingException(Code) | | Reads a variant type from a byte array.
Parameters: src - The byte array Parameters: offset - The offset in the byte array where the variantstarts Parameters: length - The length of the variant including the varianttype field Parameters: type - The variant type to read Parameters: codepage - The codepage to use to write non-wide strings A Java object that corresponds best to the variantfield. For example, a VT_I4 is returned as a Long, aVT_LPSTR as a String. exception: ReadingNotSupportedException - if a property is to be writtenwho's variant type HPSF does not yet support exception: UnsupportedEncodingException - if the specified codepage is notsupported. See Also: Variant |
setLogUnsupportedTypes | public static void setLogUnsupportedTypes(boolean logUnsupportedTypes)(Code) | | Specifies whether warnings about unsupported variant types are to be
written to System.err or not.
Parameters: logUnsupportedTypes - If true warnings will be written,if false they won't. |
write | public static int write(OutputStream out, long type, Object value, int codepage) throws IOException, WritingNotSupportedException(Code) | | Writes a variant value to an output stream. This method ensures that
always a multiple of 4 bytes is written.
If the codepage is UTF-16, which is encouraged, strings
must always be written as
Variant.VT_LPWSTR strings, not as
Variant.VT_LPSTR strings. This method ensure this
by converting strings appropriately, if needed.
Parameters: out - The stream to write the value to. Parameters: type - The variant's type. Parameters: value - The variant's value. Parameters: codepage - The codepage to use to write non-wide strings The number of entities that have been written. In many cases an"entity" is a byte but this is not always the case. exception: IOException - if an I/O exceptions occurs exception: WritingNotSupportedException - if a property is to be writtenwho's variant type HPSF does not yet support |
writeUnsupportedTypeMessage | protected static void writeUnsupportedTypeMessage(UnsupportedVariantTypeException ex)(Code) | | Writes a warning to System.err that a variant type is
unsupported by HPSF. Such a warning is written only once for each variant
type. Log messages can be turned on or off by
Parameters: ex - The exception to log |
|
|