From b8644921c9496c30f6aa158295edf07ef236464e Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 26 Jun 2013 16:17:00 +0000 Subject: [PATCH] Support decoding a few more property types git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496988 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hsmf/datatypes/PropertiesChunk.java | 10 +++++- .../poi/hsmf/datatypes/PropertyValue.java | 33 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java index 605c382e6..2e6c508bb 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; import org.apache.poi.hsmf.datatypes.PropertyValue.LongLongPropertyValue; +import org.apache.poi.hsmf.datatypes.PropertyValue.LongPropertyValue; +import org.apache.poi.hsmf.datatypes.PropertyValue.ShortPropertyValue; import org.apache.poi.hsmf.datatypes.PropertyValue.TimePropertyValue; import org.apache.poi.hsmf.datatypes.Types.MAPIType; import org.apache.poi.util.IOUtils; @@ -177,13 +179,19 @@ public abstract class PropertiesChunk extends Chunk { // We'll match up the chunk later propVal = new ChunkBasedPropertyValue(prop, flags, data); } + else if (type == Types.SHORT) { + propVal = new ShortPropertyValue(prop, flags, data); + } + else if (type == Types.LONG) { + propVal = new LongPropertyValue(prop, flags, data); + } else if (type == Types.LONG_LONG) { propVal = new LongLongPropertyValue(prop, flags, data); } else if (type == Types.TIME) { propVal = new TimePropertyValue(prop, flags, data); } - // TODO Add in the rest of the type + // TODO Add in the rest of the types else { propVal = new PropertyValue(prop, flags, data); } diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java index 1ea8a2628..b76b2de29 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java @@ -73,6 +73,39 @@ public class PropertyValue { } // TODO classes for the other important value types + + public static class ShortPropertyValue extends PropertyValue { + public ShortPropertyValue(MAPIProperty property, long flags, byte[] data) { + super(property, flags, data); + } + + public Short getValue() { + return LittleEndian.getShort(data); + } + public void setValue(short value) { + if (data.length != 2) { + data = new byte[2]; + } + LittleEndian.putShort(data, 0, value); + } + } + + public static class LongPropertyValue extends PropertyValue { + public LongPropertyValue(MAPIProperty property, long flags, byte[] data) { + super(property, flags, data); + } + + public Integer getValue() { + return LittleEndian.getInt(data); + } + public void setValue(int value) { + if (data.length != 4) { + data = new byte[4]; + } + LittleEndian.putInt(data, 0, value); + } + } + public static class LongLongPropertyValue extends PropertyValue { public LongLongPropertyValue(MAPIProperty property, long flags, byte[] data) { super(property, flags, data);