Javadoc, formatting and style improvements
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353280 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed6a27c2be
commit
7e303c76c2
17
.classpath
17
.classpath
@ -1,14 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src/testcases"/>
|
<classpathentry excluding="**/CVS/*" kind="src" path="src/testcases"/>
|
||||||
<classpathentry kind="src" path="src/java"/>
|
<classpathentry excluding="**/CVS/*" kind="src" path="src/java"/>
|
||||||
|
<classpathentry excluding="**/CVS/*" kind="src" path="src/contrib/src"/>
|
||||||
<classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
<classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jboss/test/apache-ant-1.5.3-1/lib/ant.jar"/>
|
<classpathentry kind="lib" path="lib/commons-logging-1.0.1.jar"/>
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jboss/test/apache-ant-1.5.3-1/lib/junit.jar"/>
|
<classpathentry kind="lib" path="lib/log4j-1.2.8.jar"/>
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jboss/test/apache-ant-1.5.3-1/lib/commons-logging.jar"/>
|
<classpathentry kind="lib" path="src/contrib/lib/commons-lang-1.0-b1.jar"/>
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jboss/test/apache-ant-1.5.3-1/lib/xerces-2.3.0.jar"/>
|
<classpathentry kind="lib" path="src/contrib/lib/commons-beanutils-1.6.jar"/>
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jboss/test/apache-ant-1.5.3-1/lib/xercesImpl.jar"/>
|
<classpathentry kind="lib" path="lib/junit-3.8.1.jar"/>
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jboss/test/apache-ant-1.5.3-1/lib/xml-apis.jar"/>
|
|
||||||
<classpathentry kind="lib" path="/Users/andrewoliver/projects/jakarta/poimerge/jakarta-poi/lib/xalan-2.2.0.jar"/>
|
|
||||||
<classpathentry kind="output" path="build"/>
|
<classpathentry kind="output" path="build"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
8
.project
8
.project
@ -1,10 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>POI</name>
|
<name>POI-Head-1</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
@ -13,5 +18,6 @@
|
|||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
@ -55,9 +55,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Represents a class ID (16 bytes). Unlike other little-endian
|
* <p>Represents a class ID (16 bytes). Unlike other little-endian
|
||||||
* type the {@link ClassID} is not just 16 bytes stored in the wrong
|
* type the {@link ClassID} is not just 16 bytes stored in the wrong
|
||||||
@ -98,15 +95,21 @@ public class ClassID
|
|||||||
*/
|
*/
|
||||||
public ClassID()
|
public ClassID()
|
||||||
{
|
{
|
||||||
bytes = new byte[LENGTH];
|
bytes = new byte[LENGTH];
|
||||||
for (int i = 0; i < LENGTH; i++)
|
for (int i = 0; i < LENGTH; i++)
|
||||||
bytes[i] = 0x00;
|
bytes[i] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final static int LENGTH = 16;
|
/** <p>The number of bytes occupied by this object in the byte
|
||||||
|
* stream.</p> */
|
||||||
|
public static final int LENGTH = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The number of bytes occupied by this object in the byte
|
||||||
|
* stream.
|
||||||
|
*/
|
||||||
public int length()
|
public int length()
|
||||||
{
|
{
|
||||||
return LENGTH;
|
return LENGTH;
|
||||||
@ -117,10 +120,12 @@ public class ClassID
|
|||||||
/**
|
/**
|
||||||
* <p>Gets the bytes making out the class ID. They are returned in
|
* <p>Gets the bytes making out the class ID. They are returned in
|
||||||
* correct order, i.e. big-endian.</p>
|
* correct order, i.e. big-endian.</p>
|
||||||
|
*
|
||||||
|
* @return the bytes making out the class ID.
|
||||||
*/
|
*/
|
||||||
public byte[] getBytes()
|
public byte[] getBytes()
|
||||||
{
|
{
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,9 +158,9 @@ public class ClassID
|
|||||||
bytes[6] = src[7 + offset];
|
bytes[6] = src[7 + offset];
|
||||||
bytes[7] = src[6 + offset];
|
bytes[7] = src[6 + offset];
|
||||||
|
|
||||||
/* Read 8 bytes. */
|
/* Read 8 bytes. */
|
||||||
for (int i = 8; i < 16; i++)
|
for (int i = 8; i < 16; i++)
|
||||||
bytes[i] = src[i + offset];
|
bytes[i] = src[i + offset];
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
@ -170,30 +175,34 @@ public class ClassID
|
|||||||
*
|
*
|
||||||
* @param offset The offset within the <var>dst</var> byte array.
|
* @param offset The offset within the <var>dst</var> byte array.
|
||||||
*
|
*
|
||||||
* @throws ArrayIndexOutOfBoundsException if there is not enough
|
* @exception ArrayStoreException if there is not enough room for the class
|
||||||
* room for the class ID in the byte array. There must be at least
|
* ID 16 bytes in the byte array after the <var>offset</var> position.
|
||||||
* 16 bytes in the byte array after the <var>offset</var>
|
|
||||||
* position.
|
|
||||||
*/
|
*/
|
||||||
public void write(final byte[] dst, final int offset)
|
public void write(final byte[] dst, final int offset)
|
||||||
|
throws ArrayStoreException
|
||||||
{
|
{
|
||||||
|
/* Check array size: */
|
||||||
|
if (dst.length < 16)
|
||||||
|
throw new ArrayStoreException
|
||||||
|
("Destination byte[] must have room for at least 16 bytes, " +
|
||||||
|
"but has a length of only " + dst.length + ".");
|
||||||
/* Write double word. */
|
/* Write double word. */
|
||||||
dst[0 + offset] = bytes[3];
|
dst[0 + offset] = bytes[3];
|
||||||
dst[1 + offset] = bytes[2];
|
dst[1 + offset] = bytes[2];
|
||||||
dst[2 + offset] = bytes[1];
|
dst[2 + offset] = bytes[1];
|
||||||
dst[3 + offset] = bytes[0];
|
dst[3 + offset] = bytes[0];
|
||||||
|
|
||||||
/* Write first word. */
|
/* Write first word. */
|
||||||
dst[4 + offset] = bytes[5];
|
dst[4 + offset] = bytes[5];
|
||||||
dst[5 + offset] = bytes[4];
|
dst[5 + offset] = bytes[4];
|
||||||
|
|
||||||
/* Write second word. */
|
/* Write second word. */
|
||||||
dst[6 + offset] = bytes[7];
|
dst[6 + offset] = bytes[7];
|
||||||
dst[7 + offset] = bytes[6];
|
dst[7 + offset] = bytes[6];
|
||||||
|
|
||||||
/* Write 8 bytes. */
|
/* Write 8 bytes. */
|
||||||
for (int i = 8; i < 16; i++)
|
for (int i = 8; i < 16; i++)
|
||||||
dst[i + offset] = bytes[i];
|
dst[i + offset] = bytes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.io.*;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
import java.util.*;
|
|
||||||
import org.apache.poi.hpsf.wellknown.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Convenience class representing a DocumentSummary Information stream in a
|
* <p>Convenience class representing a DocumentSummary Information stream in a
|
||||||
@ -90,12 +88,12 @@ public class DocumentSummaryInformation extends SpecialPropertySet
|
|||||||
* does not contain a document summary information stream.
|
* does not contain a document summary information stream.
|
||||||
*/
|
*/
|
||||||
public DocumentSummaryInformation(final PropertySet ps)
|
public DocumentSummaryInformation(final PropertySet ps)
|
||||||
throws UnexpectedPropertySetTypeException
|
throws UnexpectedPropertySetTypeException
|
||||||
{
|
{
|
||||||
super(ps);
|
super(ps);
|
||||||
if (!isDocumentSummaryInformation())
|
if (!isDocumentSummaryInformation())
|
||||||
throw new UnexpectedPropertySetTypeException
|
throw new UnexpectedPropertySetTypeException
|
||||||
("Not a " + getClass().getName());
|
("Not a " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,12 +66,16 @@ package org.apache.poi.hpsf;
|
|||||||
public class HPSFException extends Exception
|
public class HPSFException extends Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The underlying reason for this exception - may be
|
||||||
|
* <code>null</code>.</p>
|
||||||
|
* */
|
||||||
private Throwable reason;
|
private Throwable reason;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Creates a new {@link HPSFException}.</p>
|
* <p>Creates an {@link HPSFException}.</p>
|
||||||
*/
|
*/
|
||||||
public HPSFException()
|
public HPSFException()
|
||||||
{
|
{
|
||||||
@ -81,8 +85,7 @@ public class HPSFException extends Exception
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Creates a new {@link HPSFException} with a message
|
* <p>Creates an {@link HPSFException} with a message string.</p>
|
||||||
* string.</p>
|
|
||||||
*
|
*
|
||||||
* @param msg The message string.
|
* @param msg The message string.
|
||||||
*/
|
*/
|
||||||
@ -108,8 +111,8 @@ public class HPSFException extends Exception
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Creates a new {@link HPSFException} with a message string
|
* <p>Creates an {@link HPSFException} with a message string and a
|
||||||
* and a reason.</p>
|
* reason.</p>
|
||||||
*
|
*
|
||||||
* @param msg The message string.
|
* @param msg The message string.
|
||||||
* @param reason The reason, i.e. a throwable that indirectly
|
* @param reason The reason, i.e. a throwable that indirectly
|
||||||
|
@ -66,6 +66,8 @@ package org.apache.poi.hpsf;
|
|||||||
public class HPSFRuntimeException extends RuntimeException
|
public class HPSFRuntimeException extends RuntimeException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** <p>The underlying reason for this exception - may be
|
||||||
|
* <code>null</code>.</p> */
|
||||||
private Throwable reason;
|
private Throwable reason;
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ package org.apache.poi.hpsf;
|
|||||||
public class IllegalPropertySetDataException extends HPSFRuntimeException
|
public class IllegalPropertySetDataException extends HPSFRuntimeException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*/
|
||||||
public IllegalPropertySetDataException()
|
public IllegalPropertySetDataException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
@ -76,6 +79,11 @@ public class IllegalPropertySetDataException extends HPSFRuntimeException
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
*/
|
||||||
public IllegalPropertySetDataException(final String msg)
|
public IllegalPropertySetDataException(final String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
@ -83,6 +91,11 @@ public class IllegalPropertySetDataException extends HPSFRuntimeException
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public IllegalPropertySetDataException(final Throwable reason)
|
public IllegalPropertySetDataException(final Throwable reason)
|
||||||
{
|
{
|
||||||
super(reason);
|
super(reason);
|
||||||
@ -90,10 +103,16 @@ public class IllegalPropertySetDataException extends HPSFRuntimeException
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public IllegalPropertySetDataException(final String msg,
|
public IllegalPropertySetDataException(final String msg,
|
||||||
final Throwable reason)
|
final Throwable reason)
|
||||||
{
|
{
|
||||||
super(msg,reason);
|
super(msg, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,27 +65,46 @@ package org.apache.poi.hpsf;
|
|||||||
public class MarkUnsupportedException extends HPSFException
|
public class MarkUnsupportedException extends HPSFException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*/
|
||||||
public MarkUnsupportedException()
|
public MarkUnsupportedException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
*/
|
||||||
public MarkUnsupportedException(final String msg)
|
public MarkUnsupportedException(final String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public MarkUnsupportedException(final Throwable reason)
|
public MarkUnsupportedException(final Throwable reason)
|
||||||
{
|
{
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public MarkUnsupportedException(final String msg, final Throwable reason)
|
public MarkUnsupportedException(final String msg, final Throwable reason)
|
||||||
{
|
{
|
||||||
super(msg, reason);
|
super(msg, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -71,26 +71,45 @@ package org.apache.poi.hpsf;
|
|||||||
public class NoPropertySetStreamException extends HPSFException
|
public class NoPropertySetStreamException extends HPSFException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*/
|
||||||
public NoPropertySetStreamException()
|
public NoPropertySetStreamException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
*/
|
||||||
public NoPropertySetStreamException(final String msg)
|
public NoPropertySetStreamException(final String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public NoPropertySetStreamException(final Throwable reason)
|
public NoPropertySetStreamException(final Throwable reason)
|
||||||
{
|
{
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public NoPropertySetStreamException(final String msg,
|
public NoPropertySetStreamException(final String msg,
|
||||||
final Throwable reason)
|
final Throwable reason)
|
||||||
{
|
{
|
||||||
super(msg, reason);
|
super(msg, reason);
|
||||||
}
|
}
|
||||||
|
@ -70,24 +70,43 @@ package org.apache.poi.hpsf;
|
|||||||
public class NoSingleSectionException extends HPSFRuntimeException
|
public class NoSingleSectionException extends HPSFRuntimeException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*/
|
||||||
public NoSingleSectionException()
|
public NoSingleSectionException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
*/
|
||||||
public NoSingleSectionException(final String msg)
|
public NoSingleSectionException(final String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public NoSingleSectionException(final Throwable reason)
|
public NoSingleSectionException(final Throwable reason)
|
||||||
{
|
{
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor</p>
|
||||||
|
*
|
||||||
|
* @param msg The exception's message string
|
||||||
|
* @param reason This exception's underlying reason
|
||||||
|
*/
|
||||||
public NoSingleSectionException(final String msg, final Throwable reason)
|
public NoSingleSectionException(final String msg, final Throwable reason)
|
||||||
{
|
{
|
||||||
super(msg, reason);
|
super(msg, reason);
|
||||||
|
@ -62,7 +62,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,9 +96,10 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
public class Property
|
public class Property
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Codepage 1200 denotes Unicode. */
|
/** <p>Codepage 1200 denotes Unicode.</p> */
|
||||||
private static int CP_UNICODE = 1200;
|
private static final int CP_UNICODE = 1200;
|
||||||
|
|
||||||
|
/** <p>The property's ID.</p> */
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ public class Property
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** <p>The property's type.</p> */
|
||||||
private long type;
|
private long type;
|
||||||
|
|
||||||
|
|
||||||
@ -128,6 +131,7 @@ public class Property
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** <p>The property's value.</p> */
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +160,7 @@ public class Property
|
|||||||
* codepage. It is needed only when reading string values.
|
* codepage. It is needed only when reading string values.
|
||||||
*/
|
*/
|
||||||
public Property(final int id, final byte[] src, final long offset,
|
public Property(final int id, final byte[] src, final long offset,
|
||||||
int length, int codepage)
|
final int length, final int codepage)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
@ -165,7 +169,7 @@ public class Property
|
|||||||
* property IDs and property names.
|
* property IDs and property names.
|
||||||
*/
|
*/
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
{
|
{
|
||||||
value = readDictionary(src, offset, length, codepage);
|
value = readDictionary(src, offset, length, codepage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -174,15 +178,15 @@ public class Property
|
|||||||
type = LittleEndian.getUInt(src, o);
|
type = LittleEndian.getUInt(src, o);
|
||||||
o += LittleEndian.INT_SIZE;
|
o += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
value = TypeReader.read(src, o, length, (int) type);
|
value = TypeReader.read(src, o, length, (int) type);
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
value = "*** null ***";
|
value = "*** null ***";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -199,13 +203,13 @@ public class Property
|
|||||||
* @return The dictonary
|
* @return The dictonary
|
||||||
*/
|
*/
|
||||||
protected Map readDictionary(final byte[] src, final long offset,
|
protected Map readDictionary(final byte[] src, final long offset,
|
||||||
final int length, final int codepage)
|
final int length, final int codepage)
|
||||||
{
|
{
|
||||||
/* Check whether "offset" points into the "src" array". */
|
/* Check whether "offset" points into the "src" array". */
|
||||||
if (offset < 0 || offset > src.length)
|
if (offset < 0 || offset > src.length)
|
||||||
throw new HPSFRuntimeException
|
throw new HPSFRuntimeException
|
||||||
("Illegal offset " + offset + " while HPSF stream contains " +
|
("Illegal offset " + offset + " while HPSF stream contains " +
|
||||||
length + " bytes.");
|
length + " bytes.");
|
||||||
int o = (int) offset;
|
int o = (int) offset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -216,7 +220,7 @@ public class Property
|
|||||||
|
|
||||||
final Map m = new HashMap((int) nrEntries, (float) 1.0);
|
final Map m = new HashMap((int) nrEntries, (float) 1.0);
|
||||||
for (int i = 0; i < nrEntries; i++)
|
for (int i = 0; i < nrEntries; i++)
|
||||||
{
|
{
|
||||||
/* The key. */
|
/* The key. */
|
||||||
final Long id = new Long(LittleEndian.getUInt(src, o));
|
final Long id = new Long(LittleEndian.getUInt(src, o));
|
||||||
o += LittleEndian.INT_SIZE;
|
o += LittleEndian.INT_SIZE;
|
||||||
@ -231,31 +235,44 @@ public class Property
|
|||||||
|
|
||||||
/* Read the bytes or characters depending on whether the
|
/* Read the bytes or characters depending on whether the
|
||||||
* character set is Unicode or not. */
|
* character set is Unicode or not. */
|
||||||
StringBuffer b = new StringBuffer((int) sLength);
|
StringBuffer b = new StringBuffer((int) sLength);
|
||||||
for (int j = 0; j < sLength; j++)
|
for (int j = 0; j < sLength; j++)
|
||||||
if (codepage == CP_UNICODE)
|
if (codepage == CP_UNICODE)
|
||||||
{
|
{
|
||||||
final int i1 = o + (j * 2);
|
final int i1 = o + (j * 2);
|
||||||
final int i2 = i1 + 1;
|
final int i2 = i1 + 1;
|
||||||
b.append((char) ((src[i2] << 8) + src[i1]));
|
b.append((char) ((src[i2] << 8) + src[i1]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
b.append((char) src[o + j]);
|
b.append((char) src[o + j]);
|
||||||
|
|
||||||
/* Strip 0x00 characters from the end of the string: */
|
/* Strip 0x00 characters from the end of the string: */
|
||||||
while (b.charAt(b.length() - 1) == 0x00)
|
while (b.charAt(b.length() - 1) == 0x00)
|
||||||
b.setLength(b.length() - 1);
|
b.setLength(b.length() - 1);
|
||||||
if (codepage == CP_UNICODE)
|
if (codepage == CP_UNICODE)
|
||||||
{
|
{
|
||||||
if (sLength % 2 == 1)
|
if (sLength % 2 == 1)
|
||||||
sLength++;
|
sLength++;
|
||||||
o += (sLength + sLength);
|
o += (sLength + sLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
o += sLength;
|
o += sLength;
|
||||||
m.put(id, b.toString());
|
m.put(id, b.toString());
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Returns the property's size in bytes. This is always a multiple of
|
||||||
|
* 4.</p>
|
||||||
|
*
|
||||||
|
* @return the property's size in bytes
|
||||||
|
*/
|
||||||
|
protected int getSize()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("FIXME: Not yet implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.io.IOException;
|
||||||
import org.apache.poi.hpsf.wellknown.*;
|
import java.util.ArrayList;
|
||||||
import org.apache.poi.poifs.filesystem.*;
|
import java.util.List;
|
||||||
|
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,8 +100,8 @@ public class PropertySet
|
|||||||
/**
|
/**
|
||||||
* <p>The "byteOrder" field must equal this value.</p>
|
* <p>The "byteOrder" field must equal this value.</p>
|
||||||
*/
|
*/
|
||||||
final static byte[] BYTE_ORDER_ASSERTION =
|
static final byte[] BYTE_ORDER_ASSERTION =
|
||||||
new byte[]{(byte) 0xFE, (byte) 0xFF};
|
new byte[] {(byte) 0xFE, (byte) 0xFF};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Specifies this {@link PropertySet}'s byte order. See the
|
* <p>Specifies this {@link PropertySet}'s byte order. See the
|
||||||
@ -124,8 +125,8 @@ public class PropertySet
|
|||||||
/**
|
/**
|
||||||
* <p>The "format" field must equal this value.</p>
|
* <p>The "format" field must equal this value.</p>
|
||||||
*/
|
*/
|
||||||
final static byte[] FORMAT_ASSERTION =
|
static final byte[] FORMAT_ASSERTION =
|
||||||
new byte[]{(byte) 0x00, (byte) 0x00};
|
new byte[]{(byte) 0x00, (byte) 0x00};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Specifies this {@link PropertySet}'s format. See the HPFS
|
* <p>Specifies this {@link PropertySet}'s format. See the HPFS
|
||||||
@ -154,21 +155,31 @@ public class PropertySet
|
|||||||
protected int osVersion;
|
protected int osVersion;
|
||||||
|
|
||||||
|
|
||||||
public final static int OS_WIN16 = 0x0000;
|
/**
|
||||||
public final static int OS_MACINTOSH = 0x0001;
|
* <p>If the OS version field holds this value the property set stream was
|
||||||
public final static int OS_WIN32 = 0x0002;
|
* created on a 16-bit Windows system.</p>
|
||||||
|
*/
|
||||||
|
public static final int OS_WIN16 = 0x0000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>If the OS version field holds this value the property set stream was
|
||||||
|
* created on a Macintosh system.</p>
|
||||||
|
*/
|
||||||
|
public static final int OS_MACINTOSH = 0x0001;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>If the OS version field holds this value the property set stream was
|
||||||
|
* created on a 32-bit Windows system.</p>
|
||||||
|
*/
|
||||||
|
public static final int OS_WIN32 = 0x0002;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Returns the property set stream's low-level "OS version"
|
* <p>Returns the property set stream's low-level "OS version"
|
||||||
* field.</p>
|
* 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.
|
* @return The property set stream's low-level "OS version" field.
|
||||||
*/
|
*/
|
||||||
public long getOSVersion()
|
public int getOSVersion()
|
||||||
{
|
{
|
||||||
return osVersion;
|
return osVersion;
|
||||||
}
|
}
|
||||||
@ -204,13 +215,9 @@ public class PropertySet
|
|||||||
* <p>Returns the number of {@link Section}s in the property
|
* <p>Returns the number of {@link Section}s in the property
|
||||||
* set.</p>
|
* 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.
|
* @return The number of {@link Section}s in the property set.
|
||||||
*/
|
*/
|
||||||
public long getSectionCount()
|
public int getSectionCount()
|
||||||
{
|
{
|
||||||
return sectionCount;
|
return sectionCount;
|
||||||
}
|
}
|
||||||
@ -244,7 +251,7 @@ public class PropertySet
|
|||||||
* writing functionality is implemented.</p>
|
* writing functionality is implemented.</p>
|
||||||
*/
|
*/
|
||||||
protected PropertySet()
|
protected PropertySet()
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -265,19 +272,21 @@ public class PropertySet
|
|||||||
* the {@link InputStream#markSupported} method.
|
* the {@link InputStream#markSupported} method.
|
||||||
* @throws IOException if the {@link InputStream} cannot not be
|
* @throws IOException if the {@link InputStream} cannot not be
|
||||||
* accessed as needed.
|
* accessed as needed.
|
||||||
|
* @exception NoPropertySetStreamException if the input stream does not
|
||||||
|
* contain a property set
|
||||||
*/
|
*/
|
||||||
public PropertySet(final InputStream stream)
|
public PropertySet(final InputStream stream)
|
||||||
throws NoPropertySetStreamException, MarkUnsupportedException,
|
throws NoPropertySetStreamException, MarkUnsupportedException,
|
||||||
IOException
|
IOException
|
||||||
{
|
{
|
||||||
if (isPropertySetStream(stream))
|
if (isPropertySetStream(stream))
|
||||||
{
|
{
|
||||||
final int avail = stream.available();
|
final int avail = stream.available();
|
||||||
final byte[] buffer = new byte[avail];
|
final byte[] buffer = new byte[avail];
|
||||||
stream.read(buffer, 0, buffer.length);
|
stream.read(buffer, 0, buffer.length);
|
||||||
init(buffer, 0, buffer.length);
|
init(buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw new NoPropertySetStreamException();
|
throw new NoPropertySetStreamException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,11 +306,11 @@ public class PropertySet
|
|||||||
* property set stream.
|
* property set stream.
|
||||||
*/
|
*/
|
||||||
public PropertySet(final byte[] stream, final int offset, final int length)
|
public PropertySet(final byte[] stream, final int offset, final int length)
|
||||||
throws NoPropertySetStreamException
|
throws NoPropertySetStreamException
|
||||||
{
|
{
|
||||||
if (isPropertySetStream(stream, offset, length))
|
if (isPropertySetStream(stream, offset, length))
|
||||||
init(stream, offset, length);
|
init(stream, offset, length);
|
||||||
else
|
else
|
||||||
throw new NoPropertySetStreamException();
|
throw new NoPropertySetStreamException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,9 +346,10 @@ public class PropertySet
|
|||||||
* stream, else <code>false</code>.
|
* stream, else <code>false</code>.
|
||||||
* @throws MarkUnsupportedException if the {@link InputStream}
|
* @throws MarkUnsupportedException if the {@link InputStream}
|
||||||
* does not support the {@link InputStream#mark} method.
|
* does not support the {@link InputStream#mark} method.
|
||||||
|
* @exception IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public static boolean isPropertySetStream(final InputStream stream)
|
public static boolean isPropertySetStream(final InputStream stream)
|
||||||
throws MarkUnsupportedException, IOException
|
throws MarkUnsupportedException, IOException
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Read at most this many bytes.
|
* Read at most this many bytes.
|
||||||
@ -353,17 +363,17 @@ public class PropertySet
|
|||||||
*/
|
*/
|
||||||
if (!stream.markSupported())
|
if (!stream.markSupported())
|
||||||
throw new MarkUnsupportedException(stream.getClass().getName());
|
throw new MarkUnsupportedException(stream.getClass().getName());
|
||||||
stream.mark(BUFFER_SIZE);
|
stream.mark(BUFFER_SIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a couple of bytes from the stream.
|
* Read a couple of bytes from the stream.
|
||||||
*/
|
*/
|
||||||
final byte[] buffer = new byte[BUFFER_SIZE];
|
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
final int bytes =
|
final int bytes =
|
||||||
stream.read(buffer, 0,
|
stream.read(buffer, 0,
|
||||||
Math.min(buffer.length, stream.available()));
|
Math.min(buffer.length, stream.available()));
|
||||||
final boolean isPropertySetStream =
|
final boolean isPropertySetStream =
|
||||||
isPropertySetStream(buffer, 0, bytes);
|
isPropertySetStream(buffer, 0, bytes);
|
||||||
stream.reset();
|
stream.reset();
|
||||||
return isPropertySetStream;
|
return isPropertySetStream;
|
||||||
}
|
}
|
||||||
@ -381,34 +391,38 @@ public class PropertySet
|
|||||||
* @return <code>true</code> if the byte array is a property set
|
* @return <code>true</code> if the byte array is a property set
|
||||||
* stream, <code>false</code> if not.
|
* stream, <code>false</code> if not.
|
||||||
*/
|
*/
|
||||||
public static boolean isPropertySetStream(final byte[] src, int offset,
|
public static boolean isPropertySetStream(final byte[] src,
|
||||||
final int length)
|
final int offset,
|
||||||
|
final int length)
|
||||||
{
|
{
|
||||||
|
/* FIXME: Ensure that at most "length" bytes are read. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the header fields of the stream. They must always be
|
* Read the header fields of the stream. They must always be
|
||||||
* there.
|
* there.
|
||||||
*/
|
*/
|
||||||
final int byteOrder = LittleEndian.getUShort(src, offset);
|
int o = offset;
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
final int byteOrder = LittleEndian.getUShort(src, o);
|
||||||
|
o += LittleEndian.SHORT_SIZE;
|
||||||
byte[] temp = new byte[LittleEndian.SHORT_SIZE];
|
byte[] temp = new byte[LittleEndian.SHORT_SIZE];
|
||||||
LittleEndian.putShort(temp,(short)byteOrder);
|
LittleEndian.putShort(temp, (short) byteOrder);
|
||||||
if (!Util.equal(temp, BYTE_ORDER_ASSERTION))
|
if (!Util.equal(temp, BYTE_ORDER_ASSERTION))
|
||||||
return false;
|
return false;
|
||||||
final int format = LittleEndian.getUShort(src, offset);
|
final int format = LittleEndian.getUShort(src, o);
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
o += LittleEndian.SHORT_SIZE;
|
||||||
temp = new byte[LittleEndian.SHORT_SIZE];
|
temp = new byte[LittleEndian.SHORT_SIZE];
|
||||||
LittleEndian.putShort(temp,(short)format);
|
LittleEndian.putShort(temp, (short) format);
|
||||||
if (!Util.equal(temp, FORMAT_ASSERTION))
|
if (!Util.equal(temp, FORMAT_ASSERTION))
|
||||||
return false;
|
return false;
|
||||||
final long osVersion = LittleEndian.getUInt(src, offset);
|
// final long osVersion = LittleEndian.getUInt(src, offset);
|
||||||
offset += LittleEndian.INT_SIZE;
|
o += LittleEndian.INT_SIZE;
|
||||||
final ClassID classID = new ClassID(src, offset);
|
// final ClassID classID = new ClassID(src, offset);
|
||||||
offset += ClassID.LENGTH;
|
o += ClassID.LENGTH;
|
||||||
final long sectionCount = LittleEndian.getUInt(src, offset);
|
final long sectionCount = LittleEndian.getUInt(src, o);
|
||||||
offset += LittleEndian.INT_SIZE;
|
o += LittleEndian.INT_SIZE;
|
||||||
if (sectionCount < 1)
|
if (sectionCount < 1)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -424,24 +438,27 @@ public class PropertySet
|
|||||||
* from the beginning of <var>src</src>
|
* from the beginning of <var>src</src>
|
||||||
* @param length Length of the property set stream.
|
* @param length Length of the property set stream.
|
||||||
*/
|
*/
|
||||||
private void init(final byte[] src, int offset, final int length)
|
private void init(final byte[] src, final int offset, final int length)
|
||||||
{
|
{
|
||||||
|
/* FIXME: Ensure that at most "length" bytes are read. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the stream's header fields.
|
* Read the stream's header fields.
|
||||||
*/
|
*/
|
||||||
byteOrder = LittleEndian.getUShort(src, offset);
|
int o = offset;
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
byteOrder = LittleEndian.getUShort(src, o);
|
||||||
format = LittleEndian.getUShort(src, offset);
|
o += LittleEndian.SHORT_SIZE;
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
format = LittleEndian.getUShort(src, o);
|
||||||
osVersion = (int) LittleEndian.getUInt(src, offset);
|
o += LittleEndian.SHORT_SIZE;
|
||||||
offset += LittleEndian.INT_SIZE;
|
osVersion = (int) LittleEndian.getUInt(src, o);
|
||||||
classID = new ClassID(src, offset);
|
o += LittleEndian.INT_SIZE;
|
||||||
offset += ClassID.LENGTH;
|
classID = new ClassID(src, o);
|
||||||
sectionCount = LittleEndian.getInt(src, offset);
|
o += ClassID.LENGTH;
|
||||||
offset += LittleEndian.INT_SIZE;
|
sectionCount = LittleEndian.getInt(src, o);
|
||||||
if (sectionCount <= 0)
|
o += LittleEndian.INT_SIZE;
|
||||||
throw new HPSFRuntimeException("Section count " + sectionCount +
|
if (sectionCount <= 0)
|
||||||
" must be greater than 0.");
|
throw new HPSFRuntimeException("Section count " + sectionCount +
|
||||||
|
" must be greater than 0.");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the sections, which are following the header. They
|
* Read the sections, which are following the header. They
|
||||||
@ -463,9 +480,9 @@ public class PropertySet
|
|||||||
* "offset" accordingly.
|
* "offset" accordingly.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < sectionCount; i++)
|
for (int i = 0; i < sectionCount; i++)
|
||||||
{
|
{
|
||||||
final Section s = new Section(src, offset);
|
final Section s = new Section(src, o);
|
||||||
offset += ClassID.LENGTH + LittleEndian.INT_SIZE;
|
o += ClassID.LENGTH + LittleEndian.INT_SIZE;
|
||||||
sections.add(s);
|
sections.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,7 +499,7 @@ public class PropertySet
|
|||||||
public boolean isSummaryInformation()
|
public boolean isSummaryInformation()
|
||||||
{
|
{
|
||||||
return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(),
|
return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(),
|
||||||
SectionIDMap.SUMMARY_INFORMATION_ID);
|
SectionIDMap.SUMMARY_INFORMATION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -497,7 +514,7 @@ public class PropertySet
|
|||||||
public boolean isDocumentSummaryInformation()
|
public boolean isDocumentSummaryInformation()
|
||||||
{
|
{
|
||||||
return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(),
|
return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(),
|
||||||
SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID);
|
SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -517,7 +534,7 @@ public class PropertySet
|
|||||||
* more or less than one {@link Section}.
|
* more or less than one {@link Section}.
|
||||||
*/
|
*/
|
||||||
public Property[] getProperties()
|
public Property[] getProperties()
|
||||||
throws NoSingleSectionException
|
throws NoSingleSectionException
|
||||||
{
|
{
|
||||||
return getSingleSection().getProperties();
|
return getSingleSection().getProperties();
|
||||||
}
|
}
|
||||||
@ -556,7 +573,7 @@ public class PropertySet
|
|||||||
* more or less than one {@link Section}.
|
* more or less than one {@link Section}.
|
||||||
*/
|
*/
|
||||||
protected boolean getPropertyBooleanValue(final int id)
|
protected boolean getPropertyBooleanValue(final int id)
|
||||||
throws NoSingleSectionException
|
throws NoSingleSectionException
|
||||||
{
|
{
|
||||||
return getSingleSection().getPropertyBooleanValue(id);
|
return getSingleSection().getPropertyBooleanValue(id);
|
||||||
}
|
}
|
||||||
@ -576,7 +593,7 @@ public class PropertySet
|
|||||||
* more or less than one {@link Section}.
|
* more or less than one {@link Section}.
|
||||||
*/
|
*/
|
||||||
protected int getPropertyIntValue(final int id)
|
protected int getPropertyIntValue(final int id)
|
||||||
throws NoSingleSectionException
|
throws NoSingleSectionException
|
||||||
{
|
{
|
||||||
return getSingleSection().getPropertyIntValue(id);
|
return getSingleSection().getPropertyIntValue(id);
|
||||||
}
|
}
|
||||||
@ -609,16 +626,14 @@ public class PropertySet
|
|||||||
* <p>If the {@link PropertySet} has only a single section this
|
* <p>If the {@link PropertySet} has only a single section this
|
||||||
* method returns it.</p>
|
* method returns it.</p>
|
||||||
*
|
*
|
||||||
*@return The singleSection value
|
* @return The singleSection value
|
||||||
*@throws NoSingleSectionException if the {@link PropertySet} has
|
|
||||||
*more or less than exactly one {@link Section}.
|
|
||||||
*/
|
*/
|
||||||
public Section getSingleSection()
|
public Section getSingleSection()
|
||||||
{
|
{
|
||||||
if (sectionCount != 1)
|
if (sectionCount != 1)
|
||||||
throw new NoSingleSectionException
|
throw new NoSingleSectionException
|
||||||
("Property set contains " + sectionCount + " sections.");
|
("Property set contains " + sectionCount + " sections.");
|
||||||
return ((Section) sections.get(0));
|
return ((Section) sections.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.InputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Factory class to create instances of {@link SummaryInformation},
|
* <p>Factory class to create instances of {@link SummaryInformation},
|
||||||
@ -86,8 +87,8 @@ public class PropertySetFactory
|
|||||||
* @throws IOException if some I/O problem occurs.
|
* @throws IOException if some I/O problem occurs.
|
||||||
*/
|
*/
|
||||||
public static PropertySet create(final InputStream stream)
|
public static PropertySet create(final InputStream stream)
|
||||||
throws NoPropertySetStreamException, MarkUnsupportedException,
|
throws NoPropertySetStreamException, MarkUnsupportedException,
|
||||||
UnexpectedPropertySetTypeException, IOException
|
UnexpectedPropertySetTypeException, IOException
|
||||||
{
|
{
|
||||||
final PropertySet ps = new PropertySet(stream);
|
final PropertySet ps = new PropertySet(stream);
|
||||||
if (ps.isSummaryInformation())
|
if (ps.isSummaryInformation())
|
||||||
|
@ -54,9 +54,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hpsf.wellknown.*;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
|
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Represents a section in a {@link PropertySet}.</p>
|
* <p>Represents a section in a {@link PropertySet}.</p>
|
||||||
@ -75,6 +76,9 @@ public class Section
|
|||||||
*/
|
*/
|
||||||
protected Map dictionary;
|
protected Map dictionary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The section's format ID, {@link #getFormatID}.</p>
|
||||||
|
*/
|
||||||
protected ClassID formatID;
|
protected ClassID formatID;
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +99,9 @@ public class Section
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #getOffset
|
||||||
|
*/
|
||||||
protected long offset;
|
protected long offset;
|
||||||
|
|
||||||
|
|
||||||
@ -110,6 +117,9 @@ public class Section
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #getSize
|
||||||
|
*/
|
||||||
protected int size;
|
protected int size;
|
||||||
|
|
||||||
|
|
||||||
@ -125,6 +135,9 @@ public class Section
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #getPropertyCount
|
||||||
|
*/
|
||||||
protected int propertyCount;
|
protected int propertyCount;
|
||||||
|
|
||||||
|
|
||||||
@ -140,6 +153,9 @@ public class Section
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #getProperties
|
||||||
|
*/
|
||||||
protected Property[] properties;
|
protected Property[] properties;
|
||||||
|
|
||||||
|
|
||||||
@ -159,7 +175,7 @@ public class Section
|
|||||||
* <p>Creates an empty and uninitialized {@link Section}.
|
* <p>Creates an empty and uninitialized {@link Section}.
|
||||||
*/
|
*/
|
||||||
protected Section()
|
protected Section()
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -170,32 +186,34 @@ public class Section
|
|||||||
* @param offset The position in the stream that points to the
|
* @param offset The position in the stream that points to the
|
||||||
* section's format ID.
|
* section's format ID.
|
||||||
*/
|
*/
|
||||||
public Section(final byte[] src, int offset)
|
public Section(final byte[] src, final int offset)
|
||||||
{
|
{
|
||||||
|
int o1 = offset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the format ID.
|
* Read the format ID.
|
||||||
*/
|
*/
|
||||||
formatID = new ClassID(src, offset);
|
formatID = new ClassID(src, o1);
|
||||||
offset += ClassID.LENGTH;
|
o1 += ClassID.LENGTH;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the offset from the stream's start and positions to
|
* Read the offset from the stream's start and positions to
|
||||||
* the section header.
|
* the section header.
|
||||||
*/
|
*/
|
||||||
this.offset = LittleEndian.getUInt(src, offset);
|
this.offset = LittleEndian.getUInt(src, o1);
|
||||||
offset = (int)this.offset;
|
o1 = (int) this.offset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the section length.
|
* Read the section length.
|
||||||
*/
|
*/
|
||||||
size = (int)LittleEndian.getUInt(src, offset);
|
size = (int) LittleEndian.getUInt(src, o1);
|
||||||
offset += LittleEndian.INT_SIZE;
|
o1 += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the number of properties.
|
* Read the number of properties.
|
||||||
*/
|
*/
|
||||||
propertyCount = (int)LittleEndian.getUInt(src, offset);
|
propertyCount = (int) LittleEndian.getUInt(src, o1);
|
||||||
offset += LittleEndian.INT_SIZE;
|
o1 += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the properties. The offset is positioned at the first
|
* Read the properties. The offset is positioned at the first
|
||||||
@ -207,20 +225,19 @@ public class Section
|
|||||||
* other words: Before we can read any strings we have to know
|
* other words: Before we can read any strings we have to know
|
||||||
* whether they are in Unicode or not. Unfortunately property
|
* whether they are in Unicode or not. Unfortunately property
|
||||||
* 1 is not guaranteed to be the first in a section.
|
* 1 is not guaranteed to be the first in a section.
|
||||||
*
|
*
|
||||||
* The algorithm below reads the properties in two passes: The
|
* The algorithm below reads the properties in two passes: The
|
||||||
* first one looks for property ID 1 and extracts the codepage
|
* first one looks for property ID 1 and extracts the codepage
|
||||||
* number. The seconds pass reads the other properties.
|
* number. The seconds pass reads the other properties.
|
||||||
*/
|
*/
|
||||||
properties = new Property[propertyCount];
|
properties = new Property[propertyCount];
|
||||||
Property propertyOne;
|
|
||||||
|
|
||||||
/* Pass 1: Look for the codepage. */
|
/* Pass 1: Look for the codepage. */
|
||||||
int codepage = -1;
|
int codepage = -1;
|
||||||
int pass1Offset = offset;
|
int pass1Offset = o1;
|
||||||
for (int i = 0; i < properties.length; i++)
|
for (int i = 0; i < properties.length; i++)
|
||||||
{
|
{
|
||||||
/* Read the property ID. */
|
/* Read the property ID. */
|
||||||
final int id = (int) LittleEndian.getUInt(src, pass1Offset);
|
final int id = (int) LittleEndian.getUInt(src, pass1Offset);
|
||||||
pass1Offset += LittleEndian.INT_SIZE;
|
pass1Offset += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
@ -229,44 +246,44 @@ public class Section
|
|||||||
pass1Offset += LittleEndian.INT_SIZE;
|
pass1Offset += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
/* Calculate the length of the property. */
|
/* Calculate the length of the property. */
|
||||||
int length;
|
// int length;
|
||||||
if (i == properties.length - 1)
|
// if (i == properties.length - 1)
|
||||||
length = (int) (src.length - this.offset - sOffset);
|
// length = (int) (src.length - this.offset - sOffset);
|
||||||
else
|
// else
|
||||||
length = (int)
|
// length = (int)
|
||||||
LittleEndian.getUInt(src, pass1Offset +
|
// LittleEndian.getUInt(src, pass1Offset +
|
||||||
LittleEndian.INT_SIZE) - sOffset;
|
// LittleEndian.INT_SIZE) - sOffset;
|
||||||
|
|
||||||
if (id == PropertyIDMap.PID_CODEPAGE)
|
if (id == PropertyIDMap.PID_CODEPAGE)
|
||||||
{
|
{
|
||||||
/* Read the codepage if the property ID is 1. */
|
/* Read the codepage if the property ID is 1. */
|
||||||
|
|
||||||
/* Read the property's value type. It must be
|
/* Read the property's value type. It must be
|
||||||
* VT_I2. */
|
* VT_I2. */
|
||||||
int o = (int) (this.offset + sOffset);
|
int o = (int) (this.offset + sOffset);
|
||||||
final long type = LittleEndian.getUInt(src, o);
|
final long type = LittleEndian.getUInt(src, o);
|
||||||
o += LittleEndian.INT_SIZE;
|
o += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
if (type != Variant.VT_I2)
|
if (type != Variant.VT_I2)
|
||||||
throw new HPSFRuntimeException
|
throw new HPSFRuntimeException
|
||||||
("Value type of property ID 1 is not VT_I2 but " +
|
("Value type of property ID 1 is not VT_I2 but " +
|
||||||
type + ".");
|
type + ".");
|
||||||
|
|
||||||
/* Read the codepage number. */
|
/* Read the codepage number. */
|
||||||
codepage = LittleEndian.getUShort(src, o);
|
codepage = LittleEndian.getUShort(src, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass 2: Read all properties, including 1. */
|
/* Pass 2: Read all properties, including 1. */
|
||||||
for (int i = 0; i < properties.length; i++)
|
for (int i = 0; i < properties.length; i++)
|
||||||
{
|
{
|
||||||
/* Read the property ID. */
|
/* Read the property ID. */
|
||||||
final int id = (int) LittleEndian.getUInt(src, offset);
|
final int id = (int) LittleEndian.getUInt(src, o1);
|
||||||
offset += LittleEndian.INT_SIZE;
|
o1 += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
/* Offset from the section. */
|
/* Offset from the section. */
|
||||||
final int sOffset = (int) LittleEndian.getUInt(src, offset);
|
final int sOffset = (int) LittleEndian.getUInt(src, o1);
|
||||||
offset += LittleEndian.INT_SIZE;
|
o1 += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
/* Calculate the length of the property. */
|
/* Calculate the length of the property. */
|
||||||
int length;
|
int length;
|
||||||
@ -274,12 +291,12 @@ public class Section
|
|||||||
length = (int) (src.length - this.offset - sOffset);
|
length = (int) (src.length - this.offset - sOffset);
|
||||||
else
|
else
|
||||||
length = (int)
|
length = (int)
|
||||||
LittleEndian.getUInt(src, offset + LittleEndian.INT_SIZE) -
|
LittleEndian.getUInt(src, o1 + LittleEndian.INT_SIZE) -
|
||||||
sOffset;
|
sOffset;
|
||||||
|
|
||||||
/* Create it. */
|
/* Create it. */
|
||||||
properties[i] = new Property(id, src, this.offset + sOffset,
|
properties[i] = new Property(id, src, this.offset + sOffset,
|
||||||
length, codepage);
|
length, codepage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -325,9 +342,7 @@ public class Section
|
|||||||
*/
|
*/
|
||||||
protected int getPropertyIntValue(final int id)
|
protected int getPropertyIntValue(final int id)
|
||||||
{
|
{
|
||||||
/* FIXME: Find out why the following is a Long instead of an
|
final Integer i = (Integer) getProperty(id);
|
||||||
* Integer! */
|
|
||||||
final Long i = (Long) getProperty(id);
|
|
||||||
if (i != null)
|
if (i != null)
|
||||||
return i.intValue();
|
return i.intValue();
|
||||||
else
|
else
|
||||||
@ -358,6 +373,11 @@ public class Section
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>This member is <code>true</code> if the last call to {@link
|
||||||
|
* #getPropertyIntValue} or {@link #getProperty} tried to access a
|
||||||
|
* property that was not available, else <code>false</code>.</p>
|
||||||
|
*/
|
||||||
private boolean wasNull;
|
private boolean wasNull;
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,8 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Abstract superclass for the convenience classes {@link
|
* <p>Abstract superclass for the convenience classes {@link
|
||||||
@ -90,17 +89,30 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
public abstract class SpecialPropertySet extends PropertySet
|
public abstract class SpecialPropertySet extends PropertySet
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The "real" property set <code>SpecialPropertySet</code>
|
||||||
|
* delegates to.</p>
|
||||||
|
*/
|
||||||
private PropertySet delegate;
|
private PropertySet delegate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SpecialPropertySet(PropertySet ps)
|
/**
|
||||||
|
* <p>Creates a <code>SpecialPropertySet</code>.
|
||||||
|
*
|
||||||
|
* @param ps The property set encapsulated by the
|
||||||
|
* <code>SpecialPropertySet</code>
|
||||||
|
*/
|
||||||
|
public SpecialPropertySet(final PropertySet ps)
|
||||||
{
|
{
|
||||||
delegate = ps;
|
delegate = ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#getByteOrder
|
||||||
|
*/
|
||||||
public int getByteOrder()
|
public int getByteOrder()
|
||||||
{
|
{
|
||||||
return delegate.getByteOrder();
|
return delegate.getByteOrder();
|
||||||
@ -108,6 +120,9 @@ public abstract class SpecialPropertySet extends PropertySet
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#getFormat
|
||||||
|
*/
|
||||||
public int getFormat()
|
public int getFormat()
|
||||||
{
|
{
|
||||||
return delegate.getFormat();
|
return delegate.getFormat();
|
||||||
@ -115,20 +130,19 @@ public abstract class SpecialPropertySet extends PropertySet
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* This is intentionally no javadoc comment.
|
* @see PropertySet#getOSVersion
|
||||||
*
|
|
||||||
* 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()
|
public int getOSVersion()
|
||||||
{
|
{
|
||||||
return delegate.getOSVersion();
|
return delegate.getOSVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#getClassID
|
||||||
|
*/
|
||||||
public ClassID getClassID()
|
public ClassID getClassID()
|
||||||
{
|
{
|
||||||
return delegate.getClassID();
|
return delegate.getClassID();
|
||||||
@ -136,20 +150,19 @@ public abstract class SpecialPropertySet extends PropertySet
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* This is intentionally no javadoc comment.
|
* @see PropertySet#getSectionCount
|
||||||
*
|
|
||||||
* 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()
|
public int getSectionCount()
|
||||||
{
|
{
|
||||||
return delegate.getSectionCount();
|
return delegate.getSectionCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#getSections
|
||||||
|
*/
|
||||||
public List getSections()
|
public List getSections()
|
||||||
{
|
{
|
||||||
return delegate.getSections();
|
return delegate.getSections();
|
||||||
@ -157,6 +170,9 @@ public abstract class SpecialPropertySet extends PropertySet
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#isSummaryInformation
|
||||||
|
*/
|
||||||
public boolean isSummaryInformation()
|
public boolean isSummaryInformation()
|
||||||
{
|
{
|
||||||
return delegate.isSummaryInformation();
|
return delegate.isSummaryInformation();
|
||||||
@ -164,6 +180,9 @@ public abstract class SpecialPropertySet extends PropertySet
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#isDocumentSummaryInformation
|
||||||
|
*/
|
||||||
public boolean isDocumentSummaryInformation()
|
public boolean isDocumentSummaryInformation()
|
||||||
{
|
{
|
||||||
return delegate.isDocumentSummaryInformation();
|
return delegate.isDocumentSummaryInformation();
|
||||||
@ -171,6 +190,9 @@ public abstract class SpecialPropertySet extends PropertySet
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PropertySet#getSingleSection
|
||||||
|
*/
|
||||||
public Section getSingleSection()
|
public Section getSingleSection()
|
||||||
{
|
{
|
||||||
return delegate.getSingleSection();
|
return delegate.getSingleSection();
|
||||||
|
@ -58,9 +58,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.io.*;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
import org.apache.poi.hpsf.wellknown.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Convenience class representing a Summary Information stream in a
|
* <p>Convenience class representing a Summary Information stream in a
|
||||||
@ -96,12 +95,12 @@ public class SummaryInformation extends SpecialPropertySet
|
|||||||
* does not contain a summary information stream.
|
* does not contain a summary information stream.
|
||||||
*/
|
*/
|
||||||
public SummaryInformation(final PropertySet ps)
|
public SummaryInformation(final PropertySet ps)
|
||||||
throws UnexpectedPropertySetTypeException
|
throws UnexpectedPropertySetTypeException
|
||||||
{
|
{
|
||||||
super(ps);
|
super(ps);
|
||||||
if (!isSummaryInformation())
|
if (!isSummaryInformation())
|
||||||
throw new UnexpectedPropertySetTypeException
|
throw new UnexpectedPropertySetTypeException
|
||||||
("Not a " + getClass().getName());
|
("Not a " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ public class Thumbnail
|
|||||||
*
|
*
|
||||||
* @param thumbnailData The thumbnail data
|
* @param thumbnailData The thumbnail data
|
||||||
*/
|
*/
|
||||||
public Thumbnail(byte[] thumbnailData)
|
public Thumbnail(final byte[] thumbnailData)
|
||||||
{
|
{
|
||||||
this.thumbnailData = thumbnailData;
|
this.thumbnailData = thumbnailData;
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ public class Thumbnail
|
|||||||
* @param thumbnail The new thumbnail value
|
* @param thumbnail The new thumbnail value
|
||||||
* @see SummaryInformation#getThumbnail()
|
* @see SummaryInformation#getThumbnail()
|
||||||
*/
|
*/
|
||||||
public void setThumbnail(byte[] thumbnail)
|
public void setThumbnail(final byte[] thumbnail)
|
||||||
{
|
{
|
||||||
this.thumbnailData = thumbnail;
|
this.thumbnailData = thumbnail;
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ public class Thumbnail
|
|||||||
public long getClipboardFormatTag()
|
public long getClipboardFormatTag()
|
||||||
{
|
{
|
||||||
long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(),
|
long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(),
|
||||||
OFFSET_CFTAG);
|
OFFSET_CFTAG);
|
||||||
return clipboardFormatTag;
|
return clipboardFormatTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ public class Thumbnail
|
|||||||
{
|
{
|
||||||
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
|
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
|
||||||
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
|
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
|
||||||
"be CFTAG_WINDOWS.");
|
"be CFTAG_WINDOWS.");
|
||||||
|
|
||||||
return LittleEndian.getUInt(getThumbnail(), OFFSET_CF);
|
return LittleEndian.getUInt(getThumbnail(), OFFSET_CF);
|
||||||
}
|
}
|
||||||
@ -316,20 +316,20 @@ public class Thumbnail
|
|||||||
{
|
{
|
||||||
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
|
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
|
||||||
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
|
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
|
||||||
"be CFTAG_WINDOWS.");
|
"be CFTAG_WINDOWS.");
|
||||||
if (!(getClipboardFormat() == CF_METAFILEPICT))
|
if (!(getClipboardFormat() == CF_METAFILEPICT))
|
||||||
throw new HPSFException("Clipboard Format of Thumbnail must " +
|
throw new HPSFException("Clipboard Format of Thumbnail must " +
|
||||||
"be CF_METAFILEPICT.");
|
"be CF_METAFILEPICT.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] thumbnail = getThumbnail();
|
byte[] thumbnail = getThumbnail();
|
||||||
int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
|
int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
|
||||||
byte[] wmfImage = new byte[wmfImageLength];
|
byte[] wmfImage = new byte[wmfImageLength];
|
||||||
System.arraycopy(thumbnail,
|
System.arraycopy(thumbnail,
|
||||||
OFFSET_WMFDATA,
|
OFFSET_WMFDATA,
|
||||||
wmfImage,
|
wmfImage,
|
||||||
0,
|
0,
|
||||||
wmfImageLength);
|
wmfImageLength);
|
||||||
return wmfImage;
|
return wmfImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,26 +69,50 @@ package org.apache.poi.hpsf;
|
|||||||
public class UnexpectedPropertySetTypeException extends HPSFException
|
public class UnexpectedPropertySetTypeException extends HPSFException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Creates an {@link UnexpectedPropertySetTypeException}.</p>
|
||||||
|
*/
|
||||||
public UnexpectedPropertySetTypeException()
|
public UnexpectedPropertySetTypeException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Creates an {@link UnexpectedPropertySetTypeException} with a message
|
||||||
|
* string.</p>
|
||||||
|
*
|
||||||
|
* @param msg The message string.
|
||||||
|
*/
|
||||||
public UnexpectedPropertySetTypeException(final String msg)
|
public UnexpectedPropertySetTypeException(final String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Creates a new {@link UnexpectedPropertySetTypeException} with a
|
||||||
|
* reason.</p>
|
||||||
|
*
|
||||||
|
* @param reason The reason, i.e. a throwable that indirectly
|
||||||
|
* caused this exception.
|
||||||
|
*/
|
||||||
public UnexpectedPropertySetTypeException(final Throwable reason)
|
public UnexpectedPropertySetTypeException(final Throwable reason)
|
||||||
{
|
{
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Creates an {@link UnexpectedPropertySetTypeException} with a message
|
||||||
|
* string and a reason.</p>
|
||||||
|
*
|
||||||
|
* @param msg The message string.
|
||||||
|
* @param reason The reason, i.e. a throwable that indirectly
|
||||||
|
* caused this exception.
|
||||||
|
*/
|
||||||
public UnexpectedPropertySetTypeException(final String msg,
|
public UnexpectedPropertySetTypeException(final String msg,
|
||||||
final Throwable reason)
|
final Throwable reason)
|
||||||
{
|
{
|
||||||
super(msg, reason);
|
super(msg, reason);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Provides various static utility methods.</p>
|
* <p>Provides various static utility methods.</p>
|
||||||
@ -90,10 +90,10 @@ public class Util
|
|||||||
{
|
{
|
||||||
if (a.length != b.length)
|
if (a.length != b.length)
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0; i < a.length; i++)
|
for (int i = 0; i < a.length; i++)
|
||||||
if (a[i] != b[i])
|
if (a[i] != b[i])
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ public class Util
|
|||||||
* @param dstOffset Offset in the destination byte array.
|
* @param dstOffset Offset in the destination byte array.
|
||||||
*/
|
*/
|
||||||
public static void copy(final byte[] src, final int srcOffset,
|
public static void copy(final byte[] src, final int srcOffset,
|
||||||
final int length, final byte[] dst,
|
final int length, final byte[] dst,
|
||||||
final int dstOffset)
|
final int dstOffset)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
dst[dstOffset + i] = src[srcOffset + i];
|
dst[dstOffset + i] = src[srcOffset + i];
|
||||||
@ -130,7 +130,7 @@ public class Util
|
|||||||
int capacity = 0;
|
int capacity = 0;
|
||||||
for (int i = 0; i < byteArrays.length; i++)
|
for (int i = 0; i < byteArrays.length; i++)
|
||||||
capacity += byteArrays[i].length;
|
capacity += byteArrays[i].length;
|
||||||
final byte[] result = new byte[capacity];
|
final byte[] result = new byte[capacity];
|
||||||
int r = 0;
|
int r = 0;
|
||||||
for (int i = 0; i < byteArrays.length; i++)
|
for (int i = 0; i < byteArrays.length; i++)
|
||||||
for (int j = 0; j < byteArrays[i].length; j++)
|
for (int j = 0; j < byteArrays[i].length; j++)
|
||||||
@ -150,7 +150,7 @@ public class Util
|
|||||||
* @return The new byte array. Its length is number of copied bytes.
|
* @return The new byte array. Its length is number of copied bytes.
|
||||||
*/
|
*/
|
||||||
public static byte[] copy(final byte[] src, final int offset,
|
public static byte[] copy(final byte[] src, final int offset,
|
||||||
final int length)
|
final int length)
|
||||||
{
|
{
|
||||||
final byte[] result = new byte[length];
|
final byte[] result = new byte[length];
|
||||||
copy(src, offset, length, result, 0);
|
copy(src, offset, length, result, 0);
|
||||||
@ -167,7 +167,7 @@ public class Util
|
|||||||
* did you notice that you can tell from the epochs which
|
* did you notice that you can tell from the epochs which
|
||||||
* operating system is the modern one? :-))</p>
|
* operating system is the modern one? :-))</p>
|
||||||
*/
|
*/
|
||||||
public final static long EPOCH_DIFF = 11644473600000L;
|
public static final long EPOCH_DIFF = 11644473600000L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf.wellknown;
|
package org.apache.poi.hpsf.wellknown;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This is a dictionary which maps property ID values to property
|
* <p>This is a dictionary which maps property ID values to property
|
||||||
@ -66,10 +66,10 @@ import java.util.*;
|
|||||||
* should treat them as unmodifiable, copy them and modifiy the
|
* should treat them as unmodifiable, copy them and modifiy the
|
||||||
* copies.</p>
|
* copies.</p>
|
||||||
*
|
*
|
||||||
* <p><strong>FIXME:</strong> Make the singletons
|
* <p><strong>FIXME:</strong> Make the singletons unmodifiable. However,
|
||||||
* unmodifiable. However, since this requires to use a {@link HashMap}
|
* since this requires to use a {@link HashMap} delegate instead of
|
||||||
* delegate instead of extending {@link HashMap} and thus requires a
|
* extending {@link HashMap} and thus requires a lot of stupid typing. I won't
|
||||||
* lot of stupid typing. I won't do that for the time being.</p>
|
* do that for the time being.</p>
|
||||||
*
|
*
|
||||||
* @author Rainer Klute (klute@rainer-klute.de)
|
* @author Rainer Klute (klute@rainer-klute.de)
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
@ -82,24 +82,67 @@ public class PropertyIDMap extends HashMap
|
|||||||
* The following definitions are for property IDs in the first
|
* The following definitions are for property IDs in the first
|
||||||
* (and only) section of the Summary Information property set.
|
* (and only) section of the Summary Information property set.
|
||||||
*/
|
*/
|
||||||
public final static int PID_TITLE = 2;
|
|
||||||
public final static int PID_SUBJECT = 3;
|
/** <p>ID of the property that denotes the document's title</p> */
|
||||||
public final static int PID_AUTHOR = 4;
|
public static final int PID_TITLE = 2;
|
||||||
public final static int PID_KEYWORDS = 5;
|
|
||||||
public final static int PID_COMMENTS = 6;
|
/** <p>ID of the property that denotes the document's subject</p> */
|
||||||
public final static int PID_TEMPLATE = 7;
|
public static final int PID_SUBJECT = 3;
|
||||||
public final static int PID_LASTAUTHOR = 8;
|
|
||||||
public final static int PID_REVNUMBER = 9;
|
/** <p>ID of the property that denotes the document's author</p> */
|
||||||
public final static int PID_EDITTIME = 10;
|
public static final int PID_AUTHOR = 4;
|
||||||
public final static int PID_LASTPRINTED = 11;
|
|
||||||
public final static int PID_CREATE_DTM = 12;
|
/** <p>ID of the property that denotes the document's keywords</p> */
|
||||||
public final static int PID_LASTSAVE_DTM = 13;
|
public static final int PID_KEYWORDS = 5;
|
||||||
public final static int PID_PAGECOUNT = 14;
|
|
||||||
public final static int PID_WORDCOUNT = 15;
|
/** <p>ID of the property that denotes the document's comments</p> */
|
||||||
public final static int PID_CHARCOUNT = 16;
|
public static final int PID_COMMENTS = 6;
|
||||||
public final static int PID_THUMBNAIL = 17;
|
|
||||||
public final static int PID_APPNAME = 18;
|
/** <p>ID of the property that denotes the document's template</p> */
|
||||||
public final static int PID_SECURITY = 19;
|
public static final int PID_TEMPLATE = 7;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the document's last author</p> */
|
||||||
|
public static final int PID_LASTAUTHOR = 8;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the document's revision number</p> */
|
||||||
|
public static final int PID_REVNUMBER = 9;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the document's edit time</p> */
|
||||||
|
public static final int PID_EDITTIME = 10;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the date and time the document was
|
||||||
|
* last printed</p> */
|
||||||
|
public static final int PID_LASTPRINTED = 11;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the date and time the document was
|
||||||
|
* created.</p> */
|
||||||
|
public static final int PID_CREATE_DTM = 12;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the date and time the document was
|
||||||
|
* saved</p> */
|
||||||
|
public static final int PID_LASTSAVE_DTM = 13;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the number of pages in the
|
||||||
|
* document</p> */
|
||||||
|
public static final int PID_PAGECOUNT = 14;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the number of words in the
|
||||||
|
* document</p> */
|
||||||
|
public static final int PID_WORDCOUNT = 15;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the number of characters in the
|
||||||
|
* document</p> */
|
||||||
|
public static final int PID_CHARCOUNT = 16;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the document's thumbnail</p> */
|
||||||
|
public static final int PID_THUMBNAIL = 17;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes the application that created the
|
||||||
|
* document</p> */
|
||||||
|
public static final int PID_APPNAME = 18;
|
||||||
|
|
||||||
|
/** <p>ID of the property that denotes... FIXME</p> */
|
||||||
|
public static final int PID_SECURITY = 19;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -111,66 +154,66 @@ public class PropertyIDMap extends HashMap
|
|||||||
/**
|
/**
|
||||||
* <p>The entry is a dictionary.</p>
|
* <p>The entry is a dictionary.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_DICTIONARY = 0;
|
public static final int PID_DICTIONARY = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>The entry denotes a code page.</p>
|
* <p>The entry denotes a code page.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_CODEPAGE = 1;
|
public static final int PID_CODEPAGE = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>The entry is a string denoting the category the file belongs
|
* <p>The entry is a string denoting the category the file belongs
|
||||||
* to, e.g. review, memo, etc. This is useful to find documents of
|
* to, e.g. review, memo, etc. This is useful to find documents of
|
||||||
* same type.</p>
|
* same type.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_CATEGORY = 2;
|
public static final int PID_CATEGORY = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Target format for power point presentation, e.g. 35mm,
|
* <p>Target format for power point presentation, e.g. 35mm,
|
||||||
* printer, video etc.</p>
|
* printer, video etc.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_PRESFORMAT = 3;
|
public static final int PID_PRESFORMAT = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of bytes.</p>
|
* <p>Number of bytes.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_BYTECOUNT = 4;
|
public static final int PID_BYTECOUNT = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of lines.</p>
|
* <p>Number of lines.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_LINECOUNT = 5;
|
public static final int PID_LINECOUNT = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of paragraphs.</p>
|
* <p>Number of paragraphs.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_PARCOUNT = 6;
|
public static final int PID_PARCOUNT = 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of slides in a power point presentation.</p>
|
* <p>Number of slides in a power point presentation.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_SLIDECOUNT = 7;
|
public static final int PID_SLIDECOUNT = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of slides with notes.</p>
|
* <p>Number of slides with notes.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_NOTECOUNT = 8;
|
public static final int PID_NOTECOUNT = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of hidden slides.</p>
|
* <p>Number of hidden slides.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_HIDDENCOUNT = 9;
|
public static final int PID_HIDDENCOUNT = 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Number of multimedia clips, e.g. sound or video.</p>
|
* <p>Number of multimedia clips, e.g. sound or video.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_MMCLIPCOUNT = 10;
|
public static final int PID_MMCLIPCOUNT = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This entry is set to -1 when scaling of the thumbnail is
|
* <p>This entry is set to -1 when scaling of the thumbnail is
|
||||||
* desired. Otherwise the thumbnail should be cropped.</p>
|
* desired. Otherwise the thumbnail should be cropped.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_SCALE = 11;
|
public static final int PID_SCALE = 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This entry denotes an internally used property. It is a
|
* <p>This entry denotes an internally used property. It is a
|
||||||
@ -179,30 +222,30 @@ public class PropertyIDMap extends HashMap
|
|||||||
* number tells how many document parts are under that
|
* number tells how many document parts are under that
|
||||||
* heading.</p>
|
* heading.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_HEADINGPAIR = 12;
|
public static final int PID_HEADINGPAIR = 12;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This entry contains the names of document parts (word: names
|
* <p>This entry contains the names of document parts (word: names
|
||||||
* of the documents in the master document, excel: sheet names,
|
* of the documents in the master document, excel: sheet names,
|
||||||
* power point: slide titles, binder: document names).</p>
|
* power point: slide titles, binder: document names).</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_DOCPARTS = 13;
|
public static final int PID_DOCPARTS = 13;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This entry contains the name of the project manager.</p>
|
* <p>This entry contains the name of the project manager.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_MANAGER = 14;
|
public static final int PID_MANAGER = 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This entry contains the company name.</p>
|
* <p>This entry contains the company name.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_COMPANY = 15;
|
public static final int PID_COMPANY = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>If this entry is -1 the links are dirty and should be
|
* <p>If this entry is -1 the links are dirty and should be
|
||||||
* re-evaluated.</p>
|
* re-evaluated.</p>
|
||||||
*/
|
*/
|
||||||
public final static int PID_LINKSDIRTY = 16;
|
public static final int PID_LINKSDIRTY = 16;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -224,8 +267,12 @@ public class PropertyIDMap extends HashMap
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Creates a {@link PropertyIDMap}.</p>
|
* <p>Creates a {@link PropertyIDMap}.</p>
|
||||||
|
*
|
||||||
|
* @param initialCapacity The initial capacity as defined for
|
||||||
|
* {@link HashMap}
|
||||||
|
* @param loadFactor The load factor as defined for {@link HashMap}
|
||||||
*/
|
*/
|
||||||
public PropertyIDMap(int initialCapacity, float loadFactor)
|
public PropertyIDMap(final int initialCapacity, final float loadFactor)
|
||||||
{
|
{
|
||||||
super(initialCapacity, loadFactor);
|
super(initialCapacity, loadFactor);
|
||||||
}
|
}
|
||||||
@ -238,12 +285,12 @@ public class PropertyIDMap extends HashMap
|
|||||||
*
|
*
|
||||||
* @param id The ID.
|
* @param id The ID.
|
||||||
* @param idString The ID string.
|
* @param idString The ID string.
|
||||||
* @return As specified by the {@link Map} interface, this method
|
* @return As specified by the {@link java.util.Map} interface, this method
|
||||||
* returns the previous value associated with the specified
|
* returns the previous value associated with the specified
|
||||||
* <var>id</var>, or <code>null</code> if there was no mapping for
|
* <var>id</var>, or <code>null</code> if there was no mapping for
|
||||||
* key.
|
* key.
|
||||||
*/
|
*/
|
||||||
public Object put(int id, String idString)
|
public Object put(final int id, final String idString)
|
||||||
{
|
{
|
||||||
return put(new Integer(id), idString);
|
return put(new Integer(id), idString);
|
||||||
}
|
}
|
||||||
@ -257,7 +304,7 @@ public class PropertyIDMap extends HashMap
|
|||||||
* @param id The ID.
|
* @param id The ID.
|
||||||
* @return The ID string associated with <var>id</var>.
|
* @return The ID string associated with <var>id</var>.
|
||||||
*/
|
*/
|
||||||
public Object get(int id)
|
public Object get(final int id)
|
||||||
{
|
{
|
||||||
return get(new Integer(id));
|
return get(new Integer(id));
|
||||||
}
|
}
|
||||||
@ -265,12 +312,12 @@ public class PropertyIDMap extends HashMap
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Returns the Summary Information properties singleton.</p>
|
* @return the Summary Information properties singleton
|
||||||
*/
|
*/
|
||||||
public static PropertyIDMap getSummaryInformationProperties()
|
public static PropertyIDMap getSummaryInformationProperties()
|
||||||
{
|
{
|
||||||
if (summaryInformationProperties == null)
|
if (summaryInformationProperties == null)
|
||||||
{
|
{
|
||||||
PropertyIDMap m = new PropertyIDMap(18, (float) 1.0);
|
PropertyIDMap m = new PropertyIDMap(18, (float) 1.0);
|
||||||
m.put(PID_TITLE, "PID_TITLE");
|
m.put(PID_TITLE, "PID_TITLE");
|
||||||
m.put(PID_SUBJECT, "PID_SUBJECT");
|
m.put(PID_SUBJECT, "PID_SUBJECT");
|
||||||
@ -306,7 +353,7 @@ public class PropertyIDMap extends HashMap
|
|||||||
public static PropertyIDMap getDocumentSummaryInformationProperties()
|
public static PropertyIDMap getDocumentSummaryInformationProperties()
|
||||||
{
|
{
|
||||||
if (documentSummaryInformationProperties == null)
|
if (documentSummaryInformationProperties == null)
|
||||||
{
|
{
|
||||||
PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
|
PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
|
||||||
m.put(PID_DICTIONARY, "PID_DICTIONARY");
|
m.put(PID_DICTIONARY, "PID_DICTIONARY");
|
||||||
m.put(PID_CODEPAGE, "PID_CODEPAGE");
|
m.put(PID_CODEPAGE, "PID_CODEPAGE");
|
||||||
@ -334,8 +381,10 @@ public class PropertyIDMap extends HashMap
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>For the most basic testing.</p>
|
* <p>For the most basic testing.</p>
|
||||||
|
*
|
||||||
|
* @param args The command-line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String args[])
|
public static void main(final String[] args)
|
||||||
{
|
{
|
||||||
PropertyIDMap s1 = getSummaryInformationProperties();
|
PropertyIDMap s1 = getSummaryInformationProperties();
|
||||||
PropertyIDMap s2 = getDocumentSummaryInformationProperties();
|
PropertyIDMap s2 = getDocumentSummaryInformationProperties();
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf.wellknown;
|
package org.apache.poi.hpsf.wellknown;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Maps section format IDs to {@link PropertyIDMap}s. It is
|
* <p>Maps section format IDs to {@link PropertyIDMap}s. It is
|
||||||
@ -67,7 +67,7 @@ import java.util.*;
|
|||||||
* is well-known and you can query the {@link PropertyIDMap} for PID
|
* is well-known and you can query the {@link PropertyIDMap} for PID
|
||||||
* strings. If you get back <code>null</code> you are on your own.</p>
|
* strings. If you get back <code>null</code> you are on your own.</p>
|
||||||
*
|
*
|
||||||
* <p>This {@link Map} expects the byte arrays of section format IDs
|
* <p>This {@link java.util.Map} expects the byte arrays of section format IDs
|
||||||
* as keys. A key maps to a {@link PropertyIDMap} describing the
|
* as keys. A key maps to a {@link PropertyIDMap} describing the
|
||||||
* property IDs in sections with the specified section format ID.</p>
|
* property IDs in sections with the specified section format ID.</p>
|
||||||
*
|
*
|
||||||
@ -81,12 +81,12 @@ public class SectionIDMap extends HashMap
|
|||||||
/**
|
/**
|
||||||
* <p>The SummaryInformation's section's format ID.</p>
|
* <p>The SummaryInformation's section's format ID.</p>
|
||||||
*/
|
*/
|
||||||
public final static byte[] SUMMARY_INFORMATION_ID = new byte[]
|
public static final byte[] SUMMARY_INFORMATION_ID = new byte[]
|
||||||
{
|
{
|
||||||
(byte) 0xF2, (byte) 0x9F, (byte) 0x85, (byte) 0xE0,
|
(byte) 0xF2, (byte) 0x9F, (byte) 0x85, (byte) 0xE0,
|
||||||
(byte) 0x4F, (byte) 0xF9, (byte) 0x10, (byte) 0x68,
|
(byte) 0x4F, (byte) 0xF9, (byte) 0x10, (byte) 0x68,
|
||||||
(byte) 0xAB, (byte) 0x91, (byte) 0x08, (byte) 0x00,
|
(byte) 0xAB, (byte) 0x91, (byte) 0x08, (byte) 0x00,
|
||||||
(byte) 0x2B, (byte) 0x27, (byte) 0xB3, (byte) 0xD9
|
(byte) 0x2B, (byte) 0x27, (byte) 0xB3, (byte) 0xD9
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,16 +94,23 @@ public class SectionIDMap extends HashMap
|
|||||||
* ID. The second section has a different format ID which is not
|
* ID. The second section has a different format ID which is not
|
||||||
* well-known.</p>
|
* well-known.</p>
|
||||||
*/
|
*/
|
||||||
public final static byte[] DOCUMENT_SUMMARY_INFORMATION_ID = new byte[]
|
public static final byte[] DOCUMENT_SUMMARY_INFORMATION_ID = new byte[]
|
||||||
{
|
{
|
||||||
(byte) 0xD5, (byte) 0xCD, (byte) 0xD5, (byte) 0x02,
|
(byte) 0xD5, (byte) 0xCD, (byte) 0xD5, (byte) 0x02,
|
||||||
(byte) 0x2E, (byte) 0x9C, (byte) 0x10, (byte) 0x1B,
|
(byte) 0x2E, (byte) 0x9C, (byte) 0x10, (byte) 0x1B,
|
||||||
(byte) 0x93, (byte) 0x97, (byte) 0x08, (byte) 0x00,
|
(byte) 0x93, (byte) 0x97, (byte) 0x08, (byte) 0x00,
|
||||||
(byte) 0x2B, (byte) 0x2C, (byte) 0xF9, (byte) 0xAE
|
(byte) 0x2B, (byte) 0x2C, (byte) 0xF9, (byte) 0xAE
|
||||||
};
|
};
|
||||||
|
|
||||||
public final static String UNDEFINED = "[undefined]";
|
/**
|
||||||
|
* <p>A property without a known name is described by this string.</p>
|
||||||
|
*/
|
||||||
|
public static final String UNDEFINED = "[undefined]";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The default section ID map. It maps section format IDs to
|
||||||
|
* {@link PropertyIDMap}s.</p>
|
||||||
|
*/
|
||||||
private static SectionIDMap defaultMap;
|
private static SectionIDMap defaultMap;
|
||||||
|
|
||||||
|
|
||||||
@ -117,12 +124,12 @@ public class SectionIDMap extends HashMap
|
|||||||
public static SectionIDMap getInstance()
|
public static SectionIDMap getInstance()
|
||||||
{
|
{
|
||||||
if (defaultMap == null)
|
if (defaultMap == null)
|
||||||
{
|
{
|
||||||
final SectionIDMap m = new SectionIDMap();
|
final SectionIDMap m = new SectionIDMap();
|
||||||
m.put(SUMMARY_INFORMATION_ID,
|
m.put(SUMMARY_INFORMATION_ID,
|
||||||
PropertyIDMap.getSummaryInformationProperties());
|
PropertyIDMap.getSummaryInformationProperties());
|
||||||
m.put(DOCUMENT_SUMMARY_INFORMATION_ID,
|
m.put(DOCUMENT_SUMMARY_INFORMATION_ID,
|
||||||
PropertyIDMap.getDocumentSummaryInformationProperties());
|
PropertyIDMap.getDocumentSummaryInformationProperties());
|
||||||
defaultMap = m;
|
defaultMap = m;
|
||||||
}
|
}
|
||||||
return defaultMap;
|
return defaultMap;
|
||||||
@ -144,14 +151,14 @@ public class SectionIDMap extends HashMap
|
|||||||
* string "[undefined]" is returned.
|
* string "[undefined]" is returned.
|
||||||
*/
|
*/
|
||||||
public static String getPIDString(final byte[] sectionFormatID,
|
public static String getPIDString(final byte[] sectionFormatID,
|
||||||
final int pid)
|
final int pid)
|
||||||
{
|
{
|
||||||
final PropertyIDMap m =
|
final PropertyIDMap m =
|
||||||
(PropertyIDMap) getInstance().get(sectionFormatID);
|
(PropertyIDMap) getInstance().get(sectionFormatID);
|
||||||
if (m == null)
|
if (m == null)
|
||||||
return UNDEFINED;
|
return UNDEFINED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final String s = (String) m.get(pid);
|
final String s = (String) m.get(pid);
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return UNDEFINED;
|
return UNDEFINED;
|
||||||
@ -164,6 +171,9 @@ public class SectionIDMap extends HashMap
|
|||||||
/**
|
/**
|
||||||
* <p>Returns the {@link PropertyIDMap} for a given section format
|
* <p>Returns the {@link PropertyIDMap} for a given section format
|
||||||
* ID.</p>
|
* ID.</p>
|
||||||
|
*
|
||||||
|
* @param sectionFormatID the section format ID
|
||||||
|
* @return the property ID map
|
||||||
*/
|
*/
|
||||||
public PropertyIDMap get(final byte[] sectionFormatID)
|
public PropertyIDMap get(final byte[] sectionFormatID)
|
||||||
{
|
{
|
||||||
@ -178,6 +188,7 @@ public class SectionIDMap extends HashMap
|
|||||||
*
|
*
|
||||||
* @param sectionFormatID A section format ID as a <tt>byte[]</tt> .
|
* @param sectionFormatID A section format ID as a <tt>byte[]</tt> .
|
||||||
* @deprecated Use {@link #get(byte[])} instead!
|
* @deprecated Use {@link #get(byte[])} instead!
|
||||||
|
* @return the property ID map
|
||||||
*/
|
*/
|
||||||
public Object get(final Object sectionFormatID)
|
public Object get(final Object sectionFormatID)
|
||||||
{
|
{
|
||||||
@ -189,9 +200,13 @@ public class SectionIDMap extends HashMap
|
|||||||
/**
|
/**
|
||||||
* <p>Associates a section format ID with a {@link
|
* <p>Associates a section format ID with a {@link
|
||||||
* PropertyIDMap}.</p>
|
* PropertyIDMap}.</p>
|
||||||
|
*
|
||||||
|
* @param sectionFormatID the section format ID
|
||||||
|
* @param propertyIDMap the property ID map
|
||||||
|
* @return as defined by {@link java.util.Map#put}
|
||||||
*/
|
*/
|
||||||
public Object put(final byte[] sectionFormatID,
|
public Object put(final byte[] sectionFormatID,
|
||||||
final PropertyIDMap propertyIDMap)
|
final PropertyIDMap propertyIDMap)
|
||||||
{
|
{
|
||||||
return super.put(new String(sectionFormatID), propertyIDMap);
|
return super.put(new String(sectionFormatID), propertyIDMap);
|
||||||
}
|
}
|
||||||
@ -200,6 +215,14 @@ public class SectionIDMap extends HashMap
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #put(byte[], PropertyIDMap)} instead!
|
* @deprecated Use {@link #put(byte[], PropertyIDMap)} instead!
|
||||||
|
* @link #put(byte[], PropertyIDMap)
|
||||||
|
*
|
||||||
|
* @param key This parameter remains undocumented since the method is
|
||||||
|
* deprecated.
|
||||||
|
* @param value This parameter remains undocumented since the method is
|
||||||
|
* deprecated.
|
||||||
|
* @return The return value remains undocumented since the method is
|
||||||
|
* deprecated.
|
||||||
*/
|
*/
|
||||||
public Object put(final Object key, final Object value)
|
public Object put(final Object key, final Object value)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user