summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRainer Klute <klute@apache.org>2003-02-22 14:27:16 +0000
committerRainer Klute <klute@apache.org>2003-02-22 14:27:16 +0000
commitdbc26d76253bd7f30bea7cd042df4ac391c95d2e (patch)
tree79bb6d5cee19bb394230aa74d7b54ce8367ffc7d /src
parent3948949f07578dc17e621f11c7ab5cc4f519d368 (diff)
downloadpoi-dbc26d76253bd7f30bea7cd042df4ac391c95d2e.tar.gz
poi-dbc26d76253bd7f30bea7cd042df4ac391c95d2e.zip
First preparations for HPSF writing functionality.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353013 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hpsf/ClassID.java52
-rw-r--r--src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java9
-rw-r--r--src/java/org/apache/poi/hpsf/PropertySet.java44
-rw-r--r--src/java/org/apache/poi/hpsf/Section.java18
-rw-r--r--src/java/org/apache/poi/hpsf/SpecialPropertySet.java14
-rw-r--r--src/java/org/apache/poi/hpsf/SummaryInformation.java8
6 files changed, 124 insertions, 21 deletions
diff --git a/src/java/org/apache/poi/hpsf/ClassID.java b/src/java/org/apache/poi/hpsf/ClassID.java
index 37cc490583..6d56767030 100644
--- a/src/java/org/apache/poi/hpsf/ClassID.java
+++ b/src/java/org/apache/poi/hpsf/ClassID.java
@@ -92,6 +92,18 @@ public class ClassID
}
+ /**
+ * <p>Creates a {@link ClassID} and initializes its value with
+ * 0x00 bytes.</p>
+ */
+ public ClassID()
+ {
+ bytes = new byte[LENGTH];
+ for (int i = 0; i < LENGTH; i++)
+ bytes[i] = 0x00;
+ }
+
+
public final static int LENGTH = 16;
@@ -114,8 +126,8 @@ public class ClassID
/**
- * <p>Reads a class ID from a byte array by turning little-endian
- * into big-endian.</p>
+ * <p>Reads the class ID's value from a byte array by turning
+ * little-endian into big-endian.</p>
*
* @param src The byte array to read from
*
@@ -148,4 +160,40 @@ public class ClassID
return bytes;
}
+
+
+ /**
+ * <p>Writes the class ID to a byte array in the
+ * little-endian.</p>
+ *
+ * @param dst The byte array to write to.
+ *
+ * @param offset The offset within the <var>dst</var> byte array.
+ *
+ * @throws ArrayIndexOutOfBoundsException if there is not enough
+ * room for the class ID in the byte array. There must be at least
+ * 16 bytes in the byte array after the <var>offset</var>
+ * position.
+ */
+ public void write(final byte[] dst, final int offset)
+ {
+ /* Write double word. */
+ dst[0 + offset] = bytes[3];
+ dst[1 + offset] = bytes[2];
+ dst[2 + offset] = bytes[1];
+ dst[3 + offset] = bytes[0];
+
+ /* Write first word. */
+ dst[4 + offset] = bytes[5];
+ dst[5 + offset] = bytes[4];
+
+ /* Write second word. */
+ dst[6 + offset] = bytes[7];
+ dst[7 + offset] = bytes[6];
+
+ /* Write 8 bytes. */
+ for (int i = 8; i < 16; i++)
+ dst[i + offset] = bytes[i];
+ }
+
}
diff --git a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
index aa5a844783..92005867a5 100644
--- a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
+++ b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
@@ -72,6 +72,15 @@ public class DocumentSummaryInformation extends SpecialPropertySet
{
/**
+ * <p>The document name a document summary information stream
+ * usually has in a POIFS filesystem.</p>
+ */
+ public static final String DEFAULT_STREAM_NAME =
+ "\005DocumentSummaryInformation";
+
+
+
+ /**
* <p>Creates a {@link DocumentSummaryInformation} from a given
* {@link PropertySet}.</p>
*
diff --git a/src/java/org/apache/poi/hpsf/PropertySet.java b/src/java/org/apache/poi/hpsf/PropertySet.java
index f98384206f..17eda580a4 100644
--- a/src/java/org/apache/poi/hpsf/PropertySet.java
+++ b/src/java/org/apache/poi/hpsf/PropertySet.java
@@ -103,16 +103,10 @@ public class PropertySet
new byte[]{(byte) 0xFE, (byte) 0xFF};
/**
- * <p>The "format" field must equal this value.</p>
- */
- final static byte[] FORMAT_ASSERTION =
- new byte[]{(byte) 0x00, (byte) 0x00};
-
- /**
* <p>Specifies this {@link PropertySet}'s byte order. See the
* HPFS documentation for details!</p>
*/
- private int byteOrder;
+ protected int byteOrder;
/**
* <p>Returns the property set stream's low-level "byte order"
@@ -128,10 +122,16 @@ public class PropertySet
/**
+ * <p>The "format" field must equal this value.</p>
+ */
+ final static byte[] FORMAT_ASSERTION =
+ new byte[]{(byte) 0x00, (byte) 0x00};
+
+ /**
* <p>Specifies this {@link PropertySet}'s format. See the HPFS
* documentation for details!</p>
*/
- private int format;
+ protected int format;
/**
* <p>Returns the property set stream's low-level "format"
@@ -151,12 +151,21 @@ public class PropertySet
* this {@link PropertySet}. See the HPFS documentation for
* details!</p>
*/
- private long osVersion;
+ protected int osVersion;
+
+
+ public final static int OS_WIN16 = 0x0000;
+ public final static int OS_MACINTOSH = 0x0001;
+ public final static int OS_WIN32 = 0x0002;
/**
* <p>Returns the property set stream's low-level "OS version"
* field.</p>
*
+ * <p><strong>FIXME:</strong> Return an <code>int</code> instead
+ * of a <code>long</code> in the next major version, i.e. when
+ * incompatible changes are allowed.</p>
+ *
* @return The property set stream's low-level "OS version" field.
*/
public long getOSVersion()
@@ -170,7 +179,7 @@ public class PropertySet
* <p>Specifies this {@link PropertySet}'s "classID" field. See
* the HPFS documentation for details!</p>
*/
- private ClassID classID;
+ protected ClassID classID;
/**
* <p>Returns the property set stream's low-level "class ID"
@@ -188,13 +197,17 @@ public class PropertySet
/**
* <p>The number of sections in this {@link PropertySet}.</p>
*/
- private long sectionCount;
+ protected int sectionCount;
/**
* <p>Returns the number of {@link Section}s in the property
* set.</p>
*
+ * <p><strong>FIXME:</strong> Return an <code>int</code> instead
+ * of a <code>long</code> in the next major version, i.e. when
+ * incompatible changes are allowed.</p>
+ *
* @return The number of {@link Section}s in the property set.
*/
public long getSectionCount()
@@ -207,7 +220,7 @@ public class PropertySet
/**
* <p>The sections in this {@link PropertySet}.</p>
*/
- private List sections;
+ protected List sections;
/**
@@ -420,12 +433,15 @@ public class PropertySet
offset += LittleEndian.SHORT_SIZE;
format = LittleEndian.getUShort(src, offset);
offset += LittleEndian.SHORT_SIZE;
- osVersion = LittleEndian.getUInt(src, offset);
+ osVersion = (int) LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
classID = new ClassID(src, offset);
offset += ClassID.LENGTH;
- sectionCount = LittleEndian.getUInt(src, offset);
+ sectionCount = LittleEndian.getInt(src, offset);
offset += LittleEndian.INT_SIZE;
+ if (sectionCount <= 0)
+ throw new HPSFRuntimeException("Section count " + sectionCount +
+ " must be greater than 0.");
/*
* Read the sections, which are following the header. They
diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java
index ccfee27998..ac75accda5 100644
--- a/src/java/org/apache/poi/hpsf/Section.java
+++ b/src/java/org/apache/poi/hpsf/Section.java
@@ -75,7 +75,7 @@ public class Section
*/
protected Map dictionary;
- private ClassID formatID;
+ protected ClassID formatID;
/**
@@ -95,7 +95,7 @@ public class Section
- private long offset;
+ protected long offset;
/**
@@ -110,7 +110,7 @@ public class Section
- private int size;
+ protected int size;
/**
@@ -125,7 +125,7 @@ public class Section
- private int propertyCount;
+ protected int propertyCount;
/**
@@ -140,7 +140,7 @@ public class Section
- private Property[] properties;
+ protected Property[] properties;
/**
@@ -156,6 +156,14 @@ public class Section
/**
+ * <p>Creates an empty and uninitialized {@link Section}.
+ */
+ protected Section()
+ {}
+
+
+
+ /**
* <p>Creates a {@link Section} instance from a byte array.</p>
*
* @param src Contains the complete property set stream.
diff --git a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java
index f9cddd819a..286180e9d6 100644
--- a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java
+++ b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java
@@ -115,6 +115,13 @@ public abstract class SpecialPropertySet extends PropertySet
+ /*
+ * This is intentionally no javadoc comment.
+ *
+ * FIXME: Return an <code>int</code> instead of a
+ * <code>long</code> in the next major version, i.e. when
+ * incompatible changes are allowed.
+ */
public long getOSVersion()
{
return delegate.getOSVersion();
@@ -129,6 +136,13 @@ public abstract class SpecialPropertySet extends PropertySet
+ /*
+ * This is intentionally no javadoc comment.
+ *
+ * FIXME: Return an <code>int</code> instead of a
+ * <code>long</code> in the next major version, i.e. when
+ * incompatible changes are allowed.
+ */
public long getSectionCount()
{
return delegate.getSectionCount();
diff --git a/src/java/org/apache/poi/hpsf/SummaryInformation.java b/src/java/org/apache/poi/hpsf/SummaryInformation.java
index 1fc4ef168b..c9a5e8ebb4 100644
--- a/src/java/org/apache/poi/hpsf/SummaryInformation.java
+++ b/src/java/org/apache/poi/hpsf/SummaryInformation.java
@@ -79,6 +79,14 @@ public class SummaryInformation extends SpecialPropertySet
{
/**
+ * <p>The document name a summary information stream usually has
+ * in a POIFS filesystem.</p>
+ */
+ public static final String DEFAULT_STREAM_NAME = "\005SummaryInformation";
+
+
+
+ /**
* <p>Creates a {@link SummaryInformation} from a given {@link
* PropertySet}.</p>
*