adding safety belts for property type 0x0100 and other unknown types

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1187646 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-10-22 02:40:20 +00:00
parent 392052e6df
commit 8f2c24795c
1 changed files with 8 additions and 26 deletions

View File

@ -150,39 +150,21 @@ public class VariantSupport extends Variant
* @exception UnsupportedEncodingException if the specified codepage is not
* supported.
* @see Variant
* @deprecated Use {@link #read(byte[],int,long,int)} instead
*/
@Deprecated
public static Object read( final byte[] src, final int offset,
final int length, final long type, final int codepage )
throws ReadingNotSupportedException, UnsupportedEncodingException
{
return read( src, offset, type, codepage );
}
/**
* <p>Reads a variant type from a byte array.</p>
*
* @param src The byte array
* @param offset The offset in the byte array where the variant starts
* @param type The variant type to read
* @param codepage The codepage to use for non-wide strings
* @return A Java object that corresponds best to the variant field. For
* example, a VT_I4 is returned as a {@link Long}, a VT_LPSTR as a
* {@link String}.
* @exception ReadingNotSupportedException if a property is to be written
* who's variant type HPSF does not yet support
* @exception UnsupportedEncodingException if the specified codepage is not
* supported.
* @see Variant
*/
public static Object read(final byte[] src, final int offset,
final long type, final int codepage)
throws ReadingNotSupportedException, UnsupportedEncodingException
{
TypedPropertyValue typedPropertyValue = new TypedPropertyValue(
(int) type, null );
int unpadded = typedPropertyValue.readValue( src, offset );
int unpadded;
try {
unpadded = typedPropertyValue.readValue( src, offset );
} catch (UnsupportedOperationException exc) {
final byte[] v = new byte[length];
System.arraycopy( src, offset, v, 0, length );
throw new ReadingNotSupportedException( type, v );
}
switch ( (int) type )
{