diff options
author | Rainer Klute <klute@apache.org> | 2006-03-03 16:57:55 +0000 |
---|---|---|
committer | Rainer Klute <klute@apache.org> | 2006-03-03 16:57:55 +0000 |
commit | 73a9af683f7c986421d12e07e680111d94a609c4 (patch) | |
tree | b315b5320a537d72619cae55c393357f4737b5c0 /src/java/org/apache/poi/util/LittleEndian.java | |
parent | a36d020021bb41eade6d653005ef42f60a0a609a (diff) | |
download | poi-73a9af683f7c986421d12e07e680111d94a609c4.tar.gz poi-73a9af683f7c986421d12e07e680111d94a609c4.zip |
* Writing support added to the SummaryInformation and DocumentSummaryInformation classes. These classes now have methods for setting and removing properties. Coherent extensions are:
** Documentation section about writing standard properties added to the HPSF HOW-TO.
** Example application added showing how to modify the document summary information.
** Testcases added for testing modifying summary information and document summary information.
** PropertySetFactory extended to create SummaryInformation and DocumentSummaryInformation instances.
* Added MutablePropertySet.write(DirectoryEntry, String) to ease writing a property set to a POI filesystem document.
* Improved codepage handling.
* Bug fixed: Integral values were read and written as unsigned instead of signed.
* Reworked the mapping between variant types and Java types: Variant.VT_I4 is mapped to Integer now and Variant.VT_I8 to Long. This might cause incompatibilities if you are doing low-level HPSF programming.
* Changed SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID from a byte[] to a byte[][] in order to contain the format ID of the first and the second section. This is an incompatible change!
* Added PropertySet.getFirstSection(). This method is similar to getSingleSection() won't choke if the property set has more than one section.
* Support for low-level reading and writing of Variant.VT_I8 type properties added.
* Unnecessary casts removed.
* Poibrowser's display format changed slightly.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@382887 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/util/LittleEndian.java')
-rw-r--r-- | src/java/org/apache/poi/util/LittleEndian.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/util/LittleEndian.java b/src/java/org/apache/poi/util/LittleEndian.java index d215469247..f6c95d3d41 100644 --- a/src/java/org/apache/poi/util/LittleEndian.java +++ b/src/java/org/apache/poi/util/LittleEndian.java @@ -1,5 +1,5 @@ /* ==================================================================== - Copyright 2003-2004 Apache Software Foundation + Copyright 2003-2006 Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -64,9 +64,9 @@ public class LittleEndian short num = (short) getNumber(data, offset, SHORT_SIZE); int retNum; if (num < 0) { - retNum = ((int) Short.MAX_VALUE + 1) * 2 + (int) num; + retNum = (Short.MAX_VALUE + 1) * 2 + num; } else { - retNum = (int) num; + retNum = num; } return retNum; } @@ -163,9 +163,9 @@ public class LittleEndian int num = (int) getNumber(data, offset, INT_SIZE); long retNum; if (num < 0) { - retNum = ((long) Integer.MAX_VALUE + 1) * 2 + (long) num; + retNum = ((long) Integer.MAX_VALUE + 1) * 2 + num; } else { - retNum = (int) num; + retNum = num; } return retNum; } @@ -522,7 +522,7 @@ public class LittleEndian *@return Description of the Return Value */ public static int ubyteToInt(byte b) { - return ((b & 0x80) == 0 ? (int) b : (int) (b & (byte) 0x7f) + 0x80); + return ((b & 0x80) == 0 ? (int) b : (b & (byte) 0x7f) + 0x80); } @@ -566,5 +566,22 @@ public class LittleEndian return copy; } + /** + * <p>Gets an unsigned int value (8 bytes) from a byte array.</p> + * + * @param data the byte array + * @param offset a starting offset into the byte array + * @return the unsigned int (32-bit) value in a long + */ + public static long getULong(final byte[] data, final int offset) + { + int num = (int) getNumber(data, offset, LONG_SIZE); + long retNum; + if (num < 0) + retNum = ((long) Integer.MAX_VALUE + 1) * 2 + num; + else + retNum = num; + return retNum; + } } |