- Support for variant type VT_R8 added.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2005-04-13 16:33:22 +00:00
parent d25395a486
commit 43271e0c5e
3 changed files with 33 additions and 3 deletions

View File

@ -169,8 +169,22 @@ public class TypeWriter
/**
* <p>Writes a double value value to an output stream.</p>
*
* @param out The stream to write to.
* @param n The value to write.
* @exception IOException if an I/O error occurs
* @return The number of bytes written to the output stream.
*/
public static int writeToStream(final OutputStream out, final double n)
throws IOException
{
final int l = LittleEndian.DOUBLE_SIZE;
final byte[] buffer = new byte[l];
LittleEndian.putDouble(buffer, 0, n);
out.write(buffer, 0, l);
return l;
}
} }

View File

@ -169,6 +169,15 @@ public class VariantSupport extends Variant
value = new Long(LittleEndian.getUInt(src, o1)); value = new Long(LittleEndian.getUInt(src, o1));
break; break;
} }
case Variant.VT_R8:
{
/*
* Read an eight-byte double value. In Java it is represented as
* a Double object.
*/
value = new Double(LittleEndian.getDouble(src, o1));
break;
}
case Variant.VT_FILETIME: case Variant.VT_FILETIME:
{ {
/* /*
@ -394,6 +403,12 @@ public class VariantSupport extends Variant
((Long) value).intValue()); ((Long) value).intValue());
break; break;
} }
case Variant.VT_R8:
{
length += TypeWriter.writeToStream(out,
((Double) value).doubleValue());
break;
}
case Variant.VT_FILETIME: case Variant.VT_FILETIME:
{ {
long filetime = Util.dateToFileTime((Date) value); long filetime = Util.dateToFileTime((Date) value);

View File

@ -411,6 +411,7 @@ public class TestWrite extends TestCase
check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, codepage); check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, codepage);
check(Variant.VT_I2, new Integer(27), codepage); check(Variant.VT_I2, new Integer(27), codepage);
check(Variant.VT_I4, new Long(28), codepage); check(Variant.VT_I4, new Long(28), codepage);
check(Variant.VT_R8, new Double(29.0), codepage);
check(Variant.VT_FILETIME, new Date(), codepage); check(Variant.VT_FILETIME, new Date(), codepage);
check(Variant.VT_LPSTR, check(Variant.VT_LPSTR,