Support decoding a few more property types

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2013-06-26 16:17:00 +00:00
parent c5893c8c34
commit b8644921c9
2 changed files with 42 additions and 1 deletions

View File

@ -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);
}

View File

@ -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);