From: Andrew C. Oliver Convenience class representing a DocumentSummary Information
- * stream in a Microsoft Office document.
*
- * @author Rainer Klute (klute@rainer-klute.de)
- * @author Drew Varner (Drew.Varner closeTo sc.edu)
+ * Convenience class representing a DocumentSummary Information stream in a
+ * Microsoft Office document. Creates a {@link DocumentSummaryInformation} from a given
- * {@link PropertySet}.
*
- * @param ps A property set which should be created from a
- * document summary information stream.
+ * Creates a {@link DocumentSummaryInformation} from a given {@link
+ * PropertySet}. Returns the stream's category (or
+ *
+ * Returns the stream's category (or Returns the stream's presentation format (or
- *
+ *
+ * Returns the stream's presentation format (or Returns the stream's byte count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a byte count.
+ *
+ * Returns the stream's byte count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a byte count. Returns the stream's line count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a line count.
+ *
+ * Returns the stream's line count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a line count. Returns the stream's par count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a par count.
+ *
+ * Returns the stream's par count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a par count. Returns the stream's slide count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a slide count.
+ *
+ * Returns the stream's slide count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a slide count. Returns the stream's note count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a note count.
+ *
+ * Returns the stream's note count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a note count. Returns the stream's hidden count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a hidden count.
+ *
+ * Returns the stream's hidden count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a hidden count. Returns the stream's mmclip count or 0 if the {@link
- * DocumentSummaryInformation} does not contain a mmclip count.
+ *
+ * Returns the stream's mmclip count or 0 if the {@link
+ * DocumentSummaryInformation} does not contain a mmclip count. Returns
+ *
+ * Returns Returns the stream's heading pair (or
+ *
+ * Returns the stream's heading pair (or Returns the stream's doc parts (or
+ *
+ * Returns the stream's doc parts (or Returns the stream's manager (or
+ *
+ * Returns the stream's manager (or Returns the stream's company (or
+ *
+ * Returns the stream's company (or Returns
+ *
+ * Returns
+ *
+ * FIXME: Explain this some more! I (Rainer) don't
+ * understand it. FIXME: Explain this some more! I (Rainer)
- * don't understand it. This exception is the superclass of all other checked exceptions
- * thrown in this package. It supports a nested "reason" throwable,
- * i.e. an exception that caused this one to be thrown.
+ *
+ * This exception is the superclass of all other checked exceptions thrown in
+ * this package. It supports a nested "reason" throwable, i.e. an exception
+ * that caused this one to be thrown. Creates a new {@link HPSFException}.
+ *
+ * Creates a new {@link HPSFException}. Creates a new {@link HPSFException} with a message
- * string.
+ *
+ * Creates a new {@link HPSFException} with a message string. Creates a new {@link HPSFException} with a reason.
+ *
+ * Creates a new {@link HPSFException} with a reason. Creates a new {@link HPSFException} with a message string
- * and a reason.
+ *
+ * Creates a new {@link HPSFException} with a message string and a reason.
+ * Returns the {@link Throwable} that caused this exception to
- * be thrown or
+ *
+ * Returns the {@link Throwable} that caused this exception to be thrown or
+ * This exception is the superclass of all other unchecked
- * exceptions thrown in this package. It supports a nested "reason"
- * throwable, i.e. an exception that caused this one to be thrown.
+ *
+ * This exception is the superclass of all other unchecked exceptions thrown in
+ * this package. It supports a nested "reason" throwable, i.e. an exception
+ * that caused this one to be thrown. Creates a new {@link HPSFRuntimeException}.
+ *
+ * Creates a new {@link HPSFRuntimeException}. Creates a new {@link HPSFRuntimeException} with a message
- * string.
+ *
+ * Creates a new {@link HPSFRuntimeException} with a message string. Creates a new {@link HPSFRuntimeException} with a reason.
+ *
+ * Creates a new {@link HPSFRuntimeException} with a reason. Creates a new {@link HPSFRuntimeException} with a message string
- * and a reason.
+ *
+ * Creates a new {@link HPSFRuntimeException} with a message string and a
+ * reason. Returns the {@link Throwable} that caused this exception to
- * be thrown or
+ *
+ * Returns the {@link Throwable} that caused this exception to be thrown or
+ * This exception is thrown if an {@link java.io.InputStream} does
- * not support the {@link java.io.InputStream#mark} operation.
+ *
+ * This exception is thrown if an {@link java.io.InputStream} does not support
+ * the {@link java.io.InputStream#mark} operation. This exception is thrown if a format error in a property set
- * stream is detected or when the input data do not constitute a
- * property set stream.
+ *
+ * This exception is thrown if a format error in a property set stream is
+ * detected or when the input data do not constitute a property set stream.
*
- * The constructors of this class are analogous to those of its
- * superclass and documented there.null
).null
).null
).null
).true
when scaling of the thumbnail is
- * desired, false
if cropping is desired.true
when scaling of the thumbnail is desired,
+ * false
if cropping is desired.null
)
- * when this method is implemented. Please note that the
- * return type is likely to change!
+ * null
) when
+ * this method is implemented. Please note that the return type is likely
+ * to change!
+ *
+ *@return The headingPair value
*/
- public byte[] getHeadingPair()
- {
- if (true)
+ public byte[] getHeadingPair() {
+ if (true) {
throw new UnsupportedOperationException("FIXME");
+ }
return (byte[]) getProperty(PropertyIDMap.PID_HEADINGPAIR);
}
/**
- * null
)
- * when this method is implemented. Please note that the
- * return type is likely to change!
+ * null
) when this
+ * method is implemented. Please note that the return type is likely to
+ * change!
+ *
+ *@return The docparts value
*/
- public byte[] getDocparts()
- {
- if (true)
+ public byte[] getDocparts() {
+ if (true) {
throw new UnsupportedOperationException("FIXME");
+ }
return (byte[]) getProperty(PropertyIDMap.PID_DOCPARTS);
}
/**
- * null
).null
).null
).null
).true
if the custom links are hampered
- * by excessive noise, for all applications.true
if the custom links are hampered by excessive
+ * noise, for all applications.null
if there was no such {@link
- * Throwable}.null
if there was no such {@link Throwable}.null
if there was no such {@link
- * Throwable}.null
if there was no such {@link Throwable}.
This exception is thrown if one of the {@link PropertySet}'s - * convenience methods that require a single {@link Section} is called - * and the {@link PropertySet} does not contain exactly one {@link - * Section}.
+ *+ * + * This exception is thrown if one of the {@link PropertySet}'s convenience + * methods that require a single {@link Section} is called and the {@link + * PropertySet} does not contain exactly one {@link Section}.
* - *
The constructors of this class are analogous to those of its - * superclass and documented there.
+ * The constructors of this class are analogous to those of its superclass and + * documented there. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id: NoSingleSectionException.java,v 1.3 2002/05/01 09:31:52 klute + * Exp $ + *@since 2002-02-09 */ -public class NoSingleSectionException extends HPSFRuntimeException -{ +public class NoSingleSectionException extends HPSFRuntimeException { - public NoSingleSectionException() - { - super(); + /** + * Constructor for the NoSingleSectionException object + */ + public NoSingleSectionException() { + super(); } - public NoSingleSectionException(final String msg) - { - super(msg); + + /** + * Constructor for the NoSingleSectionException object + * + *@param msg Description of the Parameter + */ + public NoSingleSectionException(final String msg) { + super(msg); } - public NoSingleSectionException(final Throwable reason) - { - super(reason); + + /** + * Constructor for the NoSingleSectionException object + * + *@param reason Description of the Parameter + */ + public NoSingleSectionException(final Throwable reason) { + super(reason); } - public NoSingleSectionException(final String msg, final Throwable reason) - { - super(msg, reason); + + /** + * Constructor for the NoSingleSectionException object + * + *@param msg Description of the Parameter + *@param reason Description of the Parameter + */ + public NoSingleSectionException(final String msg, final Throwable reason) { + super(msg, reason); } } diff --git a/src/java/org/apache/poi/hpsf/Property.java b/src/java/org/apache/poi/hpsf/Property.java index 09d7a77a8d..10e83437bc 100644 --- a/src/java/org/apache/poi/hpsf/Property.java +++ b/src/java/org/apache/poi/hpsf/Property.java @@ -1,121 +1,127 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *A property in a {@link Section} of a {@link PropertySet}.
- * - *The property's ID gives the property a meaning - * in the context of its {@link Section}. Each {@link Section} spans - * its own name space of property IDs.
+ ** - *
The property's type determines how its - * value is interpreted. For example, if the type is - * {@link Variant#VT_LPSTR} (byte string), the value consists of a - * {@link DWord} telling how many bytes the string contains. The bytes - * follow immediately, including any null bytes that terminate the - * string. The type {@link Variant#VT_I4} denotes a four-byte integer - * value, {@link Variant#VT_FILETIME} some date and time (of a - * file).
+ * A property in a {@link Section} of a {@link PropertySet}.* - *
FIXME: Reading of other types than those - * mentioned above and the dictionary property is not yet - * implemented.
+ * The property's ID gives the property a meaning in the + * context of its {@link Section}. Each {@link Section} spans its own name + * space of property IDs.* - * @see Section - * @see Variant + * The property's type determines how its value + * is interpreted. For example, if the type is {@link + * Variant#VT_LPSTR} (byte string), the value consists of a {@link DWord} + * telling how many bytes the string contains. The bytes follow immediately, + * including any null bytes that terminate the string. The type {@link + * Variant#VT_I4} denotes a four-byte integer value, {@link + * Variant#VT_FILETIME} some date and time (of a file).
* - * @author Rainer Klute (klute@rainer-klute.de) - * @author Drew Varner (Drew.Varner InAndAround sc.edu) + * FIXME: Reading of other types than those mentioned above + * and the dictionary property is not yet implemented.
* - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@author Drew Varner (Drew.Varner InAndAround sc.edu) + *@created May 10, 2002 + *@see Section + *@see Variant + *@version $Id$ + *@since 2002-02-09 */ -public class Property -{ +public class Property { private int id; + /** - *Returns the property's ID.
+ *+ * + * Returns the property's ID.
+ * + *@return The iD value */ - public int getID() - { + public int getID() { return id; } - private int type; + private long type; + /** - *Returns the property's type.
+ *+ * + * Returns the property's type.
+ * + *@return The type value */ - public int getType() - { + public long getType() { return type; } @@ -123,44 +129,47 @@ public class Property private Object value; + /** - *Returns the property value's.
+ *+ * + * Returns the property value's.
+ * + *@return The value value */ - public Object getValue() - { + public Object getValue() { return value; } /** - *Creates a {@link Property} instance by reading its bytes - * from the property set stream.
+ ** - * @param id The property's ID. + * Creates a {@link Property} instance by reading its bytes from the + * property set stream.
* - * @param src The bytes the property set stream consists of. - * - * @param offset The property's type/value pair's offset in the - * section. - * - * @param length The property's type/value pair's length in bytes. - * list. + *@param id The property's ID. + *@param src The bytes the property set stream consists of. + *@param offset The property's type/value pair's offset in the section. + *@param length The property's type/value pair's length in bytes. list. */ - public Property(final int id, final byte[] src, final int offset, - int length) - { + public Property(final int id, final byte[] src, final long offset, + int length) { this.id = id; - /* ID 0 is a special case since it specifies a dictionary of - * property IDs and property names. */ - if (id == 0) - { + /* + * ID 0 is a special case since it specifies a dictionary of + * property IDs and property names. + */ + if (id == 0) { value = readDictionary(src, offset, length); return; } - /* FIXME: Support this! */ + /* + * FIXME: Support this! + */ // /* ID 1 is another special case: It denotes the code page of // * byte strings in this section. */ // if (id == 1) @@ -169,89 +178,103 @@ public class Property // return; // } - int o = offset; - type = new DWord(src, o).intValue(); - o += DWord.LENGTH; + int o = (int) offset; + type = LittleEndian.getUInt(src, o); + o += LittleEndian.INT_SIZE; - /* FIXME: Support reading more types! */ - switch (type) - { + /* + * FIXME: Support reading more types! + */ + switch ((int)type) { case Variant.VT_I4: { - /* Read a word. In Java it is represented as an - Integer object. */ - value = new Integer(new DWord(src, o).intValue()); + /* + * Read a word. In Java it is represented as an + * Integer object. + */ + value = new Long(LittleEndian.getUInt(src, o)); break; } case Variant.VT_FILETIME: { - /* Read a FILETIME object. In Java it is represented - as a Date. */ - final int low = new DWord(src, o).intValue(); - o += DWord.LENGTH; - final int high = new DWord(src, o).intValue(); - value = Util.filetimeToDate(high, low); + /* + * Read a FILETIME object. In Java it is represented + * as a Date. + */ + final long low = LittleEndian.getUInt(src, o); + o += LittleEndian.INT_SIZE; + final long high = LittleEndian.getUInt(src, o); + value = Util.filetimeToDate((int)high, (int)low); break; } case Variant.VT_LPSTR: { - /* Read a byte string. In Java it is represented as a - String. The null bytes at the end of the byte - strings must be stripped. */ - final int first = o + DWord.LENGTH; - int last = first + new DWord(src, o).intValue() - 1; - o += DWord.LENGTH; - while (src[last] == 0 && first <= last) + /* + * Read a byte string. In Java it is represented as a + * String. The null bytes at the end of the byte + * strings must be stripped. + */ + final int first = o + LittleEndian.INT_SIZE; + long last = first + LittleEndian.getUInt(src, o) - 1; + o += LittleEndian.INT_SIZE; + while (src[(int)last] == 0 && first <= last) { last--; - value = new String(src, first, last - first + 1); + } + value = new String(src, (int)first, (int)(last - first + 1)); break; } case Variant.VT_CF: { - /* The first four bytes in src, from rc[offset] to - * src[offset + 3] contain the DWord for VT_CF, so - * skip it, we don't need it. */ - - /* Truncate the length of the return array by a DWord - * length (4 bytes). */ - length = length - DWord.LENGTH; + /* + * The first four bytes in src, from rc[offset] to + * src[offset + 3] contain the DWord for VT_CF, so + * skip it, we don't need it. + */ + /* + * Truncate the length of the return array by a DWord + * length (4 bytes). + */ + length = length - LittleEndian.INT_SIZE; final byte[] v = new byte[length]; - for (int i = 0; i < length; i++) - v[i] = src[o + i]; + for (int i = 0; i < length; i++) { + v[i] = src[(int)(o + i)]; + } value = v; break; } case Variant.VT_BOOL: { - /* The first four bytes in src, from src[offset] to - * src[offset + 3] contain the DWord for VT_BOOL, so - * skip it, we don't need it. */ - final int first = o + DWord.LENGTH; - DWord bool = new DWord(src,o); - if (bool.intValue() == -1) - { + /* + * The first four bytes in src, from src[offset] to + * src[offset + 3] contain the DWord for VT_BOOL, so + * skip it, we don't need it. + */ + final int first = o + LittleEndian.INT_SIZE; + long bool = LittleEndian.getUInt(src, o); + if (bool == -1) { value = new Boolean(true); - } - else if (bool.intValue() == 0) - { + } else if (bool == 0) { value = new Boolean(false); - } - else - /* FIXME: Someone might invent a new - * HPSFRuntimeException subclass - * IllegalPropertySetDataException for this and - * similar cases. */ + } else { + /* + * FIXME: Someone might invent a new + * HPSFRuntimeException subclass + * IllegalPropertySetDataException for this and + * similar cases. + */ throw new HPSFRuntimeException - ("Illegal property set data: A boolean must be " + - "either -1 (true) or 0 (false)."); + ("Illegal property set data: A boolean must be " + + "either -1 (true) or 0 (false)."); + } break; } default: { final byte[] v = new byte[length]; - for (int i = 0; i < length; i++) - v[i] = src[offset + i]; + for (int i = 0; i < length; i++) { + v[i] = src[(int)(offset + i)]; + } value = v; break; } @@ -261,41 +284,51 @@ public class Property /** - *Reads a dictionary.
+ ** - * @param src The byte array containing the bytes making out the - * dictionary. + * Reads a dictionary.
* - * @param offset At this offset within src the - * dictionary starts. - * - * @param length The dictionary contains at most this many bytes. + *@param src The byte array containing the bytes making out the + * dictionary. + *@param offset At this offset within src the dictionary + * starts. + *@param length The dictionary contains at most this many bytes. + *@return Description of the Return Value */ - protected Map readDictionary(final byte[] src, final int offset, - final int length) - { - /* FIXME: Check the length! */ - int o = offset; - - /* Read the number of dictionary entries. */ - final int nrEntries = new DWord(src, o).intValue(); - o += DWord.LENGTH; - - final Map m = new HashMap(nrEntries, (float) 1.0); - for (int i = 0; i < nrEntries; i++) - { - /* The key */ - final Integer id = new Integer(new DWord(src, o).intValue()); - o += DWord.LENGTH; - - /* The value (a string) */ - final int sLength = new DWord(src, o).intValue(); - o += DWord.LENGTH; - /* Strip trailing 0x00 bytes. */ - int l = sLength; - while (src[o + l - 1] == 0x00) + protected Map readDictionary(final byte[] src, final long offset, + final int length) { + /* + * FIXME: Check the length! + */ + int o = (int)offset; + + /* + * Read the number of dictionary entries. + */ + final long nrEntries = LittleEndian.getUInt(src, o); + o += LittleEndian.INT_SIZE; + + final Map m = new HashMap((int)nrEntries, (float) 1.0); + for (int i = 0; i < nrEntries; i++) { + /* + * The key + */ + final Long id = new Long(LittleEndian.getUInt(src, o)); + o += LittleEndian.INT_SIZE; + + /* + * The value (a string) + */ + final long sLength = LittleEndian.getUInt(src, o); + o += LittleEndian.INT_SIZE; + /* + * Strip trailing 0x00 bytes. + */ + long l = sLength; + while (src[(int)(o + l - 1)] == 0x00) { l--; - final String s = new String(src, o, l); + } + final String s = new String(src, o, (int)l); o += sLength; m.put(id, s); } @@ -305,16 +338,16 @@ public class Property /** - *Reads a code page.
+ ** - * @param src The byte array containing the bytes making out the - * code page. + * Reads a code page.
* - * @param offset At this offset within src the code - * page starts. + *@param src The byte array containing the bytes making out the code + * page. + *@param offset At this offset within src the code page starts. + *@return Description of the Return Value */ - protected int readCodePage(final byte[] src, final int offset) - { + protected int readCodePage(final byte[] src, final long offset) { throw new UnsupportedOperationException("FIXME"); } diff --git a/src/java/org/apache/poi/hpsf/PropertySet.java b/src/java/org/apache/poi/hpsf/PropertySet.java index 0ac0e37835..80f94cf9f9 100644 --- a/src/java/org/apache/poi/hpsf/PropertySet.java +++ b/src/java/org/apache/poi/hpsf/PropertySet.java @@ -1,57 +1,57 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Represents a property set in the Horrible Property Set Format - * (HPSF). These are usually metadata of a Microsoft Office - * document.
- * - *An application that wants to access these metadata should create - * an instance of this class or one of its subclasses by calling the - * factory method {@link PropertySetFactory#create} and then retrieve - * the information its needs by calling appropriate methods.
+ ** - *
{@link PropertySetFactory#create} does its work by calling one - * of the constructors {@link PropertySet#PropertySet(InputStream)} or - * {@link PropertySet#PropertySet(byte[])}. If the constructor's - * argument is not in the Horrible Property Set Format, i.e. not a - * property set stream, or if any other error occurs, an appropriate - * exception is thrown.
+ * Represents a property set in the Horrible Property Set Format (HPSF). These + * are usually metadata of a Microsoft Office document.* - *
A {@link PropertySet} has a list of {@link Section}s, and each - * {@link Section} has a {@link Property} array. Use {@link - * #getSections} to retrieve the {@link Section}s, then call {@link - * Section#getProperties} for each {@link Section} to get hold of the - * {@link Property} arrays.
+ * An application that wants to access these metadata should create an instance + * of this class or one of its subclasses by calling the factory method {@link + * PropertySetFactory#create} and then retrieve the information its needs by + * calling appropriate methods.* - * Since the vast majority of {@link PropertySet}s contains only a - * single {@link Section}, the convenience method {@link - * #getProperties} returns the properties of a {@link PropertySet}'s - * {@link Section} (throwing a {@link NoSingleSectionException} if the - * {@link PropertySet} contains more (or less) than exactly one {@link - * Section}). + * {@link PropertySetFactory#create} does its work by calling one of the + * constructors {@link PropertySet#PropertySet(InputStream)} or {@link + * PropertySet#PropertySet(byte[])}. If the constructor's argument is not in + * the Horrible Property Set Format, i.e. not a property set stream, or if any + * other error occurs, an appropriate exception is thrown.
* - * @author Rainer Klute (klute@rainer-klute.de) - * @author Drew Varner (Drew.Varner hanginIn sc.edu) + * A {@link PropertySet} has a list of {@link Section}s, and each {@link + * Section} has a {@link Property} array. Use {@link #getSections} to retrieve + * the {@link Section}s, then call {@link Section#getProperties} for each + * {@link Section} to get hold of the {@link Property} arrays.
Since the + * vast majority of {@link PropertySet}s contains only a single {@link + * Section}, the convenience method {@link #getProperties} returns the + * properties of a {@link PropertySet}'s {@link Section} (throwing a {@link + * NoSingleSectionException} if the {@link PropertySet} contains more (or less) + * than exactly one {@link Section}). * - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@author Drew Varner (Drew.Varner hanginIn sc.edu) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class PropertySet -{ - static final byte[] BYTE_ORDER_ASSERTION = - new byte[] {(byte) 0xFF, (byte) 0xFE}; - static final byte[] FORMAT_ASSERTION = - new byte[] {(byte) 0x00, (byte) 0x00}; +public class PropertySet { + final static byte[] BYTE_ORDER_ASSERTION = + new byte[]{(byte) 0xFF, (byte) 0xFE}; + final static byte[] FORMAT_ASSERTION = + new byte[]{(byte) 0x00, (byte) 0x00}; + private Word byteOrder; - private Word byteOrder; // Must equal BYTE_ORDER_ASSERTION + // Must equal BYTE_ORDER_ASSERTION /** - *Returns the property set stream's low-level "byte order" - * field. It is always 0xFFFE.
+ *+ * + * Returns the property set stream's low-level "byte order" field. It is + * always 0xFFFE .
+ * + *@return The byteOrder value */ - public Word getByteOrder() - { + public Word getByteOrder() { return byteOrder; } - private Word format; // Must equal FORMAT_ASSERTION + private Word format; + + + // Must equal FORMAT_ASSERTION /** - *Returns the property set stream's low-level "format" - * field. It is always 0x0000.
+ *+ * + * Returns the property set stream's low-level "format" field. It is always + * 0x0000 .
+ * + *@return The format value */ - public Word getFormat() - { + public Word getFormat() { return format; } @@ -133,12 +139,15 @@ public class PropertySet private DWord osVersion; + /** - *Returns the property set stream's low-level "OS version" - * field.
+ *+ * + * Returns the property set stream's low-level "OS version" field.
+ * + *@return The oSVersion value */ - public DWord getOSVersion() - { + public DWord getOSVersion() { return osVersion; } @@ -146,12 +155,15 @@ public class PropertySet private ClassID classID; + /** - *Returns the property set stream's low-level "class ID" - * field.
+ *+ * + * Returns the property set stream's low-level "class ID" field.
+ * + *@return The classID value */ - public ClassID getClassID() - { + public ClassID getClassID() { return classID; } @@ -159,12 +171,15 @@ public class PropertySet private int sectionCount; + /** - *Returns the number of {@link Section}s in the property - * set.
+ *+ * + * Returns the number of {@link Section}s in the property set.
+ * + *@return The sectionCount value */ - public int getSectionCount() - { + public int getSectionCount() { return sectionCount; } @@ -172,148 +187,161 @@ public class PropertySet private List sections; + /** - *Returns the {@link Section}s in the property set.
+ *+ * + * Returns the {@link Section}s in the property set.
+ * + *@return The sections value */ - public List getSections() - { + public List getSections() { return sections; } /** - *Creates an empty (uninitialized) {@link PropertySet}.
+ ** - *
Please note: For the time being this - * constructor is protected since it is used for internal purposes - * only, but expect it to become public once the property set - * writing functionality is implemented.
+ * Creates an empty (uninitialized) {@link PropertySet}.+ * + * Please note: For the time being this constructor is + * protected since it is used for internal purposes only, but expect it to + * become public once the property set writing functionality is + * implemented.
*/ - protected PropertySet() - {} + protected PropertySet() { } /** - *Creates a {@link PropertySet} instance from an {@link - * InputStream} in the Horrible Property Set Format.
- * - *The constructor reads the first few bytes from the stream - * and determines whether it is really a property set stream. If - * it is, it parses the rest of the stream. If it is not, it - * resets the stream to its beginning in order to let other - * components mess around with the data and throws an - * exception.
+ ** - * @throws NoPropertySetStreamException if the stream is not a - * property set stream. + * Creates a {@link PropertySet} instance from an {@link InputStream} in + * the Horrible Property Set Format.
* - * @throws MarkUnsupportedException if the stream does not support - * the {@link InputStream#markSupported} method. + * The constructor reads the first few bytes from the stream and determines + * whether it is really a property set stream. If it is, it parses the rest + * of the stream. If it is not, it resets the stream to its beginning in + * order to let other components mess around with the data and throws an + * exception.
* - * @throws IOException if the {@link InputStream} cannot not be - * accessed as needed. + *@param stream Description of the Parameter + *@exception NoPropertySetStreamException Description of the Exception + *@exception MarkUnsupportedException Description of the Exception + *@exception IOException Description of the Exception + *@throws NoPropertySetStreamException if the stream is not a property + * set stream. + *@throws MarkUnsupportedException if the stream does not support + * the {@link InputStream#markSupported} method. + *@throws IOException if the {@link InputStream} + * cannot not be accessed as needed. */ public PropertySet(final InputStream stream) - throws NoPropertySetStreamException, MarkUnsupportedException, - IOException - { - if (isPropertySetStream(stream)) - { + throws NoPropertySetStreamException, MarkUnsupportedException, + IOException { + if (isPropertySetStream(stream)) { final int avail = stream.available(); final byte[] buffer = new byte[avail]; stream.read(buffer, 0, buffer.length); init(buffer, 0, buffer.length); - } - else + } else { throw new NoPropertySetStreamException(); + } } /** - *Creates a {@link PropertySet} instance from a byte array - * that represents a stream in the Horrible Property Set - * Format.
- * - * @param stream The byte array holding the stream data. - * - * @param offset The offset in stream where the stream - * data begin. If the stream data begin with the first byte in the - * array, the offset is 0. + ** - * @param length The length of the stream data. + * Creates a {@link PropertySet} instance from a byte array that represents + * a stream in the Horrible Property Set Format.
* - * @throws NoPropertySetStreamException if the byte array is not a - * property set stream. + *@param stream The byte array holding the + * stream data. + *@param offset The offset in stream + * where the stream data begin. If the stream data begin with the first + * byte in the array, the offset is 0. + *@param length The length of the stream data. + *@exception NoPropertySetStreamException Description of the Exception + *@throws NoPropertySetStreamException if the byte array is not a + * property set stream. */ public PropertySet(final byte[] stream, final int offset, final int length) - throws NoPropertySetStreamException - { - if (isPropertySetStream(stream, offset, length)) + throws NoPropertySetStreamException { + if (isPropertySetStream(stream, offset, length)) { init(stream, offset, length); - else + } else { throw new NoPropertySetStreamException(); + } } /** - *Creates a {@link PropertySet} instance from a byte array - * that represents a stream in the Horrible Property Set - * Format.
+ ** - * @param stream The byte array holding the stream data. The - * complete byte array contents is the stream data. + * Creates a {@link PropertySet} instance from a byte array that represents + * a stream in the Horrible Property Set Format.
* - * @throws NoPropertySetStreamException if the byte array is not a - * property set stream. + *@param stream The byte array holding the + * stream data. The complete byte array contents is the stream data. + *@exception NoPropertySetStreamException Description of the Exception + *@throws NoPropertySetStreamException if the byte array is not a + * property set stream. */ public PropertySet(final byte[] stream) - throws NoPropertySetStreamException - { + throws NoPropertySetStreamException { this(stream, 0, stream.length); } /** - *Checks whether an {@link InputStream} is in the Horrible - * Property Set Format.
- * - * @param stream The {@link InputStream} to check. In order to - * perform the check, the method reads the first bytes from the - * stream. After reading, the stream is reset to the position it - * had before reading. The {@link InputStream} must support the - * {@link InputStream#mark} method. + *
*
- * @return true
if the stream is a property set
- * stream, else false
.
+ * Checks whether an {@link InputStream} is in the Horrible Property Set
+ * Format.
true
if the stream is a
+ * property set stream, else false
.
+ *@exception IOException Description of the Exception
+ *@throws MarkUnsupportedException if the {@link InputStream} does not
+ * support the {@link InputStream#mark} method.
*/
public static boolean isPropertySetStream(final InputStream stream)
- throws MarkUnsupportedException, IOException
- {
- /* Read at most this many bytes. */
+ throws MarkUnsupportedException, IOException {
+ /*
+ * Read at most this many bytes.
+ */
final int BUFFER_SIZE = 50;
- /* Mark the current position in the stream so that we can
- * reset to this position if the stream does not contain a
- * property set. */
- if (!stream.markSupported())
+ /*
+ * Mark the current position in the stream so that we can
+ * reset to this position if the stream does not contain a
+ * property set.
+ */
+ if (!stream.markSupported()) {
throw new MarkUnsupportedException(stream.getClass().getName());
+ }
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 int bytes =
- stream.read(buffer, 0,
- Math.min(buffer.length, stream.available()));
+ stream.read(buffer, 0,
+ Math.min(buffer.length, stream.available()));
final boolean isPropertySetStream =
- isPropertySetStream(buffer, 0, bytes);
+ isPropertySetStream(buffer, 0, bytes);
stream.reset();
return isPropertySetStream;
}
@@ -321,54 +349,63 @@ public class PropertySet
/**
- * Checks whether a byte array is in the Horrible Property Set - * Format.
- * - * @param src The byte array to check. + ** - * @param offset The offset in the byte array. + * Checks whether a byte array is in the Horrible Property Set Format.
* - * @param length The significant number of bytes in the byte - * array. Only this number of bytes will be checked. - * - * @returntrue
if the byte array is a property set
- * stream, false
if not.
+ *@param src The byte array to check.
+ *@param offset The offset in the byte array.
+ *@param length The significant number of bytes in the byte array. Only
+ * this number of bytes will be checked.
+ *@return true
if the byte array is a property set
+ * stream, false
if not.
*/
public static boolean isPropertySetStream(final byte[] src, int offset,
- final int length)
- {
- /* Read the header fields of the stream. They must always be
- * there. */
+ final int length) {
+ /*
+ * Read the header fields of the stream. They must always be
+ * there.
+ */
final Word byteOrder = new Word(src, offset);
offset += Word.LENGTH;
- if (!Util.equal(byteOrder.getBytes(), BYTE_ORDER_ASSERTION))
+ if (!Util.equal(byteOrder.getBytes(), BYTE_ORDER_ASSERTION)) {
return false;
+ }
final Word format = new Word(src, offset);
offset += Word.LENGTH;
- if (!Util.equal(format.getBytes(), FORMAT_ASSERTION))
+ if (!Util.equal(format.getBytes(), FORMAT_ASSERTION)) {
return false;
+ }
final DWord osVersion = new DWord(src, offset);
offset += DWord.LENGTH;
final ClassID classID = new ClassID(src, offset);
offset += ClassID.LENGTH;
final DWord sectionCount = new DWord(src, offset);
offset += DWord.LENGTH;
- if (sectionCount.intValue() < 1)
+ if (sectionCount.intValue() < 1) {
return false;
+ }
return true;
}
/**
- * Initializes this {@link PropertySet} instance from a byte - * array. The method assumes that it has been checked already that - * the byte array indeed represents a property set stream. It does - * no more checks on its own.
+ *+ * + * Initializes this {@link PropertySet} instance from a byte array. The + * method assumes that it has been checked already that the byte array + * indeed represents a property set stream. It does no more checks on its + * own.
+ * + *@param src Description of the Parameter + *@param offset Description of the Parameter + *@param length Description of the Parameter */ - private void init(final byte[] src, int offset, final int length) - { - /* Read the stream's header fields. */ + private void init(final byte[] src, int offset, final int length) { + /* + * Read the stream's header fields. + */ byteOrder = new Word(src, offset); offset += Word.LENGTH; format = new Word(src, offset); @@ -380,21 +417,26 @@ public class PropertySet sectionCount = new DWord(src, offset).intValue(); offset += DWord.LENGTH; - /* Read the sections, which are following the header. They - * start with an array of section descriptions. Each one - * consists of a format ID telling what the section contains - * and an offset telling how many bytes from the start of the - * stream the section begins. */ - /* Most property sets have only one section. The Document - * Summary Information stream has 2. Everything else is a rare - * exception and is no longer fostered by Microsoft. */ + /* + * Read the sections, which are following the header. They + * start with an array of section descriptions. Each one + * consists of a format ID telling what the section contains + * and an offset telling how many bytes from the start of the + * stream the section begins. + */ + /* + * Most property sets have only one section. The Document + * Summary Information stream has 2. Everything else is a rare + * exception and is no longer fostered by Microsoft. + */ sections = new ArrayList(2); - /* Loop over the section descriptor array. Each descriptor - * consists of a ClassID and a DWord, and we have to increment - * "offset" accordingly. */ - for (int i = 0; i < sectionCount; i++) - { + /* + * Loop over the section descriptor array. Each descriptor + * consists of a ClassID and a DWord, and we have to increment + * "offset" accordingly. + */ + for (int i = 0; i < sectionCount; i++) { final Section s = new Section(src, offset); offset += ClassID.LENGTH + DWord.LENGTH; sections.add(s); @@ -404,141 +446,155 @@ public class PropertySet /** - *Checks whether this {@link PropertySet} represents a Summary - * Information.
+ *+ * + * Checks whether this {@link PropertySet} represents a Summary + * Information.
+ * + *@return The summaryInformation value */ - public boolean isSummaryInformation() - { + public boolean isSummaryInformation() { return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(), - SectionIDMap.SUMMARY_INFORMATION_ID); + SectionIDMap.SUMMARY_INFORMATION_ID); } /** - *Checks whether this {@link PropertySet} is a Document - * Summary Information.
+ *+ * + * Checks whether this {@link PropertySet} is a Document Summary + * Information.
+ * + *@return The documentSummaryInformation value */ - public boolean isDocumentSummaryInformation() - { + public boolean isDocumentSummaryInformation() { return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(), - SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID); + SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID); } /** - *Convenience method returning the {@link Property} array - * contained in this property set. It is a shortcut for getting - * the {@link PropertySet}'s {@link Section}s list and then - * getting the {@link Property} array from the first {@link - * Section}. However, it can only be used if the {@link - * PropertySet} contains exactly one {@link Section}, so check - * {@link #getSectionCount} first!
- * - * @return The properties of the only {@link Section} of this - * {@link PropertySet}. - * - * @throws NoSingleSectionException if the {@link PropertySet} has - * more or less than one {@link Section}. + *+ * + * Convenience method returning the {@link Property} array contained in + * this property set. It is a shortcut for getting the {@link + * PropertySet}'s {@link Section}s list and then getting the {@link + * Property} array from the first {@link Section}. However, it can only be + * used if the {@link PropertySet} contains exactly one {@link Section}, so + * check {@link #getSectionCount} first!
+ * + *@return The properties of the only {@link + * Section} of this {@link PropertySet}. + *@throws NoSingleSectionException if the {@link PropertySet} has more or + * less than one {@link Section}. */ public Property[] getProperties() - throws NoSingleSectionException - { + throws NoSingleSectionException { return getSingleSection().getProperties(); } /** - *Convenience method returning the value of the property with
- * the specified ID. If the property is not available,
- * null
is returned and a subsequent call to {@link
- * #wasNull} will return true
.
*
- * @throws NoSingleSectionException if the {@link PropertySet} has
- * more or less than one {@link Section}.
+ * Convenience method returning the value of the property with the
+ * specified ID. If the property is not available, null
is
+ * returned and a subsequent call to {@link #wasNull} will return true
+ * .
Convenience method returning the value of a boolean property
- * with the specified ID. If the property is not available,
- * false
is returned. A subsequent call to {@link
- * #wasNull} will return true
to let the caller
- * distinguish that case from a real property value of
- * false
.
+ *
+ * Convenience method returning the value of a boolean property with the
+ * specified ID. If the property is not available, false
is
+ * returned. A subsequent call to {@link #wasNull} will return true
+ * to let the caller distinguish that case from a real property value of
+ * false
.
Convenience method returning the value of the numeric
- * property with the specified ID. If the property is not
- * available, 0 is returned. A subsequent call to {@link #wasNull}
- * will return true
to let the caller distinguish
- * that case from a real property value of 0.
+ *
+ * Convenience method returning the value of the numeric property with the
+ * specified ID. If the property is not available, 0 is returned. A
+ * subsequent call to {@link #wasNull} will return true
to let
+ * the caller distinguish that case from a real property value of 0.
Checks whether the property which the last call to {@link - * #getPropertyIntValue} or {@link #getProperty} tried to access - * was available or not. This information might be important for - * callers of {@link #getPropertyIntValue} since the latter - * returns 0 if the property does not exist. Using {@link - * #wasNull}, the caller can distiguish this case from a - * property's real value of 0.
- * - * @returntrue
if the last call to {@link
- * #getPropertyIntValue} or {@link #getProperty} tried to access a
- * property that was not available, else false
.
- *
- * @throws NoSingleSectionException if the {@link PropertySet} has
- * more than one {@link Section}.
+ * + * + * Checks whether the property which the last call to {@link + * #getPropertyIntValue} or {@link #getProperty} tried to access was + * available or not. This information might be important for callers of + * {@link #getPropertyIntValue} since the latter returns 0 if the property + * does not exist. Using {@link #wasNull}, the caller can distiguish this + * case from a property's real value of 0.
+ * + *@returntrue
if the last call to
+ * {@link #getPropertyIntValue} or {@link #getProperty} tried to access
+ * a property that was not available, else false
.
+ *@throws NoSingleSectionException if the {@link PropertySet} has more
+ * than one {@link Section}.
*/
- public boolean wasNull() throws NoSingleSectionException
- {
+ public boolean wasNull() throws NoSingleSectionException {
return getSingleSection().wasNull();
}
/**
- * If the {@link PropertySet} has only a single section this - * method returns it.
+ *+ * + * If the {@link PropertySet} has only a single section this method returns + * it.
* - * @throws NoSingleSectionException if the {@link PropertySet} has - * more or less than exactly one {@link Section}. + *@return The singleSection value + *@throws NoSingleSectionException if the {@link PropertySet} has more or + * less than exactly one {@link Section}. */ - public Section getSingleSection() - { - if (sectionCount != 1) + public Section getSingleSection() { + if (sectionCount != 1) { throw new NoSingleSectionException - ("Property set contains " + sectionCount + " sections."); + ("Property set contains " + sectionCount + " sections."); + } return ((Section) sections.get(0)); } diff --git a/src/java/org/apache/poi/hpsf/PropertySetFactory.java b/src/java/org/apache/poi/hpsf/PropertySetFactory.java index 10da676f6d..e6d9a518ee 100644 --- a/src/java/org/apache/poi/hpsf/PropertySetFactory.java +++ b/src/java/org/apache/poi/hpsf/PropertySetFactory.java @@ -1,93 +1,107 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Factory class to create instances of {@link SummaryInformation}, - * {@link DocumentSummaryInformation} and {@link PropertySet}.
+ *+ * + * Factory class to create instances of {@link SummaryInformation}, {@link + * DocumentSummaryInformation} and {@link PropertySet}.
* - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class PropertySetFactory -{ +public class PropertySetFactory { /** - *Creates the most specific {@link PropertySet} from an {@link - * InputStream}. This is preferrably a {@link - * DocumentSummaryInformation} or a {@link SummaryInformation}. If - * the specified {@link InputStream} does not contain a property - * set stream, an exception is thrown and the {@link InputStream} - * is repositioned at its beginning.
+ *+ * + * Creates the most specific {@link PropertySet} from an {@link + * InputStream}. This is preferrably a {@link DocumentSummaryInformation} + * or a {@link SummaryInformation}. If the specified {@link InputStream} + * does not contain a property set stream, an exception is thrown and the + * {@link InputStream} is repositioned at its beginning.
* - * @param stream Contains the property set stream's data. + *@param stream Contains the property set + * stream's data. + *@return Description of the Return + * Value + *@exception NoPropertySetStreamException Description of the + * Exception + *@exception MarkUnsupportedException Description of the + * Exception + *@exception UnexpectedPropertySetTypeException Description of the + * Exception + *@exception IOException Description of the + * Exception */ public static PropertySet create(final InputStream stream) - throws NoPropertySetStreamException, MarkUnsupportedException, - UnexpectedPropertySetTypeException, IOException - { + throws NoPropertySetStreamException, MarkUnsupportedException, + UnexpectedPropertySetTypeException, IOException { final PropertySet ps = new PropertySet(stream); - if (ps.isSummaryInformation()) + if (ps.isSummaryInformation()) { return new SummaryInformation(ps); - else if (ps.isDocumentSummaryInformation()) + } else if (ps.isDocumentSummaryInformation()) { return new DocumentSummaryInformation(ps); - else + } else { return ps; + } } } diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java index 03072bfd05..d24a040f50 100644 --- a/src/java/org/apache/poi/hpsf/Section.java +++ b/src/java/org/apache/poi/hpsf/Section.java @@ -1,103 +1,111 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Represents a section in a {@link PropertySet}.
+ ** - * @author Rainer Klute (klute@rainer-klute.de) - * @author Drew Varner (Drew.Varner allUpIn sc.edu) + * Represents a section in a {@link PropertySet}.
* - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@author Drew Varner (Drew.Varner allUpIn sc.edu) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class Section -{ +public class Section { /** - *Maps property IDs to section-private PID strings. These - * strings can be found in the property with ID 0.
+ *+ * + * Maps property IDs to section-private PID strings. These strings can be + * found in the property with ID 0.
*/ protected Map dictionary; - - private ClassID formatID; + /** - *Returns the format ID. The format ID is the "type" of the - * section.
+ *+ * + * Returns the format ID. The format ID is the "type" of the section.
+ * + *@return The formatID value */ - public ClassID getFormatID() - { + public ClassID getFormatID() { return formatID; } - private int offset; + private long offset; + /** - *Returns the offset of the section in the stream.
+ *+ * + * Returns the offset of the section in the stream.
+ * + *@return The offset value */ - public int getOffset() - { + public int getOffset() { return offset; } @@ -105,11 +113,15 @@ public class Section private int size; + /** - *Returns the section's size in bytes.
+ *+ * + * Returns the section's size in bytes.
+ * + *@return The size value */ - public int getSize() - { + public int getSize() { return size; } @@ -117,11 +129,15 @@ public class Section private int propertyCount; + /** - *Returns the number of properties in this section.
+ *+ * + * Returns the number of properties in this section.
+ * + *@return The propertyCount value */ - public int getPropertyCount() - { + public int getPropertyCount() { return propertyCount; } @@ -129,86 +145,113 @@ public class Section private Property[] properties; + /** - *Returns this section's properties.
+ *+ * + * Returns this section's properties.
+ * + *@return The properties value */ - public Property[] getProperties() - { + public Property[] getProperties() { return properties; } /** - *Creates a {@link Section} instance from a byte array.
+ ** - * @param src Contains the complete property set stream. + * Creates a {@link Section} instance from a byte array.
* - * @param offset The position in the stream that points to the - * section's format ID. + *@param src Contains the complete property set stream. + *@param offset The position in the stream that points to the section's + * format ID. */ - public Section(final byte[] src, int offset) - { - /* Read the format ID. */ + public Section(final byte[] src, int offset) { + /* + * Read the format ID. + */ formatID = new ClassID(src, offset); offset += ClassID.LENGTH; - /* Read the offset from the stream's start and positions to - * the section header. */ - this.offset = new DWord(src, offset).intValue(); - offset = this.offset; - - /* Read the section length. */ - size = new DWord(src, offset).intValue(); - offset += DWord.LENGTH; - - /* Read the number of properties. */ - propertyCount = new DWord(src, offset).intValue(); - offset += DWord.LENGTH; - - /* Read the properties. The offset is positioned at the first - * entry of the property list. */ + /* + * Read the offset from the stream's start and positions to + * the section header. + */ + this.offset = LittleEndian.getUInt(src, offset); + offset = (int)this.offset; + + /* + * Read the section length. + */ + size = (int)LittleEndian.getUInt(src, offset); + offset += LittleEndian.INT_SIZE; + + /* + * Read the number of properties. + */ + propertyCount = (int)LittleEndian.getUInt(src, offset); + offset += LittleEndian.INT_SIZE; + + /* + * Read the properties. The offset is positioned at the first + * entry of the property list. + */ properties = new Property[propertyCount]; - for (int i = 0; i < properties.length; i++) - { - final int id = new DWord(src, offset).intValue(); - offset += DWord.LENGTH; - - /* Offset from the section. */ - final int sOffset = new DWord(src, offset).intValue(); - offset += DWord.LENGTH; - - /* Calculate the length of the property. */ + for (int i = 0; i < properties.length; i++) { + final int id = (int)LittleEndian.getUInt(src, offset); + offset += LittleEndian.INT_SIZE; + + /* + * Offset from the section. + */ + final int sOffset = (int)LittleEndian.getUInt(src, offset); + offset += LittleEndian.INT_SIZE; + + /* + * Calculate the length of the property. + */ int length; - if (i == properties.length - 1) - length = src.length - this.offset - sOffset; - else - length = - new DWord(src, offset + DWord.LENGTH).intValue() - sOffset; - - /* Create it. */ + if (i == properties.length - 1) { + length = (int)(src.length - this.offset - sOffset); + } else { + length = (int) + LittleEndian.getUInt(src, offset + LittleEndian.INT_SIZE) - sOffset; + } + + /* + * Create it. + */ properties[i] = - new Property(id, src, this.offset + sOffset, length); + new Property(id, src, this.offset + sOffset, length); } - /* Extract the dictionary (if available). */ + /* + * Extract the dictionary (if available). + */ dictionary = (Map) getProperty(0); } /** - *Returns the value of the property with the specified ID. If
- * the property is not available, null
is returned
- * and a subsequent call to {@link #wasNull} will return
- * true
.
+ *
+ * Returns the value of the property with the specified ID. If the property
+ * is not available, null
is returned and a subsequent call to
+ * {@link #wasNull} will return true
.
Returns the value of the numeric property with the specified
- * ID. If the property is not available, 0 is returned. A
- * subsequent call to {@link #wasNull} will return
- * true
to let the caller distinguish that case from
- * a real property value of 0.
+ *
+ * Returns the value of the numeric property with the specified ID. If the
+ * property is not available, 0 is returned. A subsequent call to {@link
+ * #wasNull} will return true
to let the caller distinguish
+ * that case from a real property value of 0.
Returns the value of the boolean property with the specified
- * ID. If the property is not available, false
is
- * returned. A subsequent call to {@link #wasNull} will return
- * true
to let the caller distinguish that case from
- * a real property value of false
.
+ *
+ * Returns the value of the boolean property with the specified ID. If the
+ * property is not available, false
is returned. A subsequent
+ * call to {@link #wasNull} will return true
to let the caller
+ * distinguish that case from a real property value of false
.
+ *
Checks whether the property which the last call to {@link - * #getPropertyIntValue} or {@link #getProperty} tried to access - * was available or not. This information might be important for - * callers of {@link #getPropertyIntValue} since the latter - * returns 0 if the property does not exist. Using {@link - * #wasNull} the caller can distiguish this case from a property's - * real value of 0.
+ *+ * + * Checks whether the property which the last call to {@link + * #getPropertyIntValue} or {@link #getProperty} tried to access was + * available or not. This information might be important for callers of + * {@link #getPropertyIntValue} since the latter returns 0 if the property + * does not exist. Using {@link #wasNull} the caller can distiguish this + * case from a property's real value of 0.
* - * @returntrue
if the last call to {@link
- * #getPropertyIntValue} or {@link #getProperty} tried to access a
- * property that was not available, else false
.
+ *@return true
if the last call to {@link
+ * #getPropertyIntValue} or {@link #getProperty} tried to access a
+ * property that was not available, else false
.
*/
- public boolean wasNull()
- {
+ public boolean wasNull() {
return wasNull;
}
/**
- * Returns the PID string associated with a property ID. The ID - * is first looked up in the {@link Section}'s private - * dictionary. If it is not found there, the method calls {@link - * SectionIDMap#getPIDString}.
+ *+ * + * Returns the PID string associated with a property ID. The ID is first + * looked up in the {@link Section}'s private dictionary. If it is not + * found there, the method calls {@link SectionIDMap#getPIDString}.
+ * + *@param pid Description of the Parameter + *@return The pIDString value */ - public String getPIDString(final int pid) - { + public String getPIDString(final int pid) { String s = null; - if (dictionary != null) + if (dictionary != null) { s = (String) dictionary.get(new Integer(pid)); - if (s == null) - s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid); - if (s == null) + } + if (s == null) { + s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid); + } + if (s == null) { s = SectionIDMap.UNDEFINED; + } return s; } diff --git a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java index 0d92e6fdba..9b8a7cd365 100644 --- a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java +++ b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java @@ -1,164 +1,205 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Abstract superclass for the convenience classes {@link - * SummaryInformation} and {@link DocumentSummaryInformation}.
+ *+ * + * Abstract superclass for the convenience classes {@link SummaryInformation} + * and {@link DocumentSummaryInformation}.
* - *
The motivation behind this class is quite nasty if you look - * behind the scenes, but it serves the application programmer well by - * providing him with the easy-to-use {@link SummaryInformation} and - * {@link DocumentSummaryInformation} classes. When parsing the data a - * property set stream consists of (possibly coming from an {@link - * java.io.InputStream}) we want to read and process each byte only - * once. Since we don't know in advance which kind of property set we - * have, we can expect only the most general {@link - * PropertySet}. Creating a special subclass should be as easy as - * calling the special subclass' constructor and pass the general - * {@link PropertySet} in. To make things easy internally, the special - * class just holds a reference to the general {@link PropertySet} and - * delegates all method calls to it.
+ * The motivation behind this class is quite nasty if you look behind the + * scenes, but it serves the application programmer well by providing him with + * the easy-to-use {@link SummaryInformation} and {@link + * DocumentSummaryInformation} classes. When parsing the data a property set + * stream consists of (possibly coming from an {@link java.io.InputStream}) we + * want to read and process each byte only once. Since we don't know in advance + * which kind of property set we have, we can expect only the most general + * {@link PropertySet}. Creating a special subclass should be as easy as + * calling the special subclass' constructor and pass the general {@link + * PropertySet} in. To make things easy internally, the special class just + * holds a reference to the general {@link PropertySet} and delegates all + * method calls to it.* - *
A cleaner implementation would have been like this: The {@link - * PropertySetFactory} parses the stream data into some internal - * object first. Then it finds out whether the stream is a {@link - * SummaryInformation}, a {@link DocumentSummaryInformation} or a - * general {@link PropertySet}. However, the current implementation - * went the other way round historically: the convenience classes came - * only late to my mind.
+ * A cleaner implementation would have been like this: The {@link + * PropertySetFactory} parses the stream data into some internal object first. + * Then it finds out whether the stream is a {@link SummaryInformation}, a + * {@link DocumentSummaryInformation} or a general {@link PropertySet}. + * However, the current implementation went the other way round historically: + * the convenience classes came only late to my mind. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public abstract class SpecialPropertySet extends PropertySet -{ +public abstract class SpecialPropertySet extends PropertySet { private PropertySet delegate; - public SpecialPropertySet(PropertySet ps) - { + /** + * Constructor for the SpecialPropertySet object + * + *@param ps Description of the Parameter + */ + public SpecialPropertySet(PropertySet ps) { delegate = ps; } - public Word getByteOrder() - { + /** + * Gets the byteOrder attribute of the SpecialPropertySet object + * + *@return The byteOrder value + */ + public Word getByteOrder() { return delegate.getByteOrder(); } - public Word getFormat() - { + /** + * Gets the format attribute of the SpecialPropertySet object + * + *@return The format value + */ + public Word getFormat() { return delegate.getFormat(); } - public DWord getOSVersion() - { + /** + * Gets the oSVersion attribute of the SpecialPropertySet object + * + *@return The oSVersion value + */ + public DWord getOSVersion() { return delegate.getOSVersion(); } - public ClassID getClassID() - { + /** + * Gets the classID attribute of the SpecialPropertySet object + * + *@return The classID value + */ + public ClassID getClassID() { return delegate.getClassID(); } - public int getSectionCount() - { + /** + * Gets the sectionCount attribute of the SpecialPropertySet object + * + *@return The sectionCount value + */ + public int getSectionCount() { return delegate.getSectionCount(); } - public List getSections() - { + /** + * Gets the sections attribute of the SpecialPropertySet object + * + *@return The sections value + */ + public List getSections() { return delegate.getSections(); } - public boolean isSummaryInformation() - { + /** + * Gets the summaryInformation attribute of the SpecialPropertySet object + * + *@return The summaryInformation value + */ + public boolean isSummaryInformation() { return delegate.isSummaryInformation(); } - public boolean isDocumentSummaryInformation() - { + /** + * Gets the documentSummaryInformation attribute of the SpecialPropertySet + * object + * + *@return The documentSummaryInformation value + */ + public boolean isDocumentSummaryInformation() { return delegate.isDocumentSummaryInformation(); } - public Section getSingleSection() - { + /** + * Gets the singleSection attribute of the SpecialPropertySet object + * + *@return The singleSection value + */ + public Section getSingleSection() { return delegate.getSingleSection(); } diff --git a/src/java/org/apache/poi/hpsf/SummaryInformation.java b/src/java/org/apache/poi/hpsf/SummaryInformation.java index 78402fbe51..64e04f53e2 100644 --- a/src/java/org/apache/poi/hpsf/SummaryInformation.java +++ b/src/java/org/apache/poi/hpsf/SummaryInformation.java @@ -1,61 +1,61 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Convenience class representing a Summary Information stream in a - * Microsoft Office document.
+ ** - *
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp - * for documentation from That Redmond Company. + * Convenience class representing a Summary Information stream in a Microsoft + * Office document.
* - * @see DocumentSummaryInformation + * See + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp + * for documentation from That Redmond Company. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@see DocumentSummaryInformation + *@version $Id$ + *@since 2002-02-09 */ -public class SummaryInformation extends SpecialPropertySet -{ +public class SummaryInformation extends SpecialPropertySet { /** - *
Creates a {@link SummaryInformation} from a given {@link - * PropertySet}.
+ ** - * @param ps A property set which should be created from a summary - * information stream. + * Creates a {@link SummaryInformation} from a given {@link PropertySet}. + *
* - * @throws UnexpectedPropertySetTypeException if ps - * does not contain a summary information stream. + *@param ps A property set which + * should be created from a summary information stream. + *@exception UnexpectedPropertySetTypeException Description of the + * Exception + *@throws UnexpectedPropertySetTypeException if ps does not + * contain a summary information stream. */ public SummaryInformation(final PropertySet ps) - throws UnexpectedPropertySetTypeException - { + throws UnexpectedPropertySetTypeException { super(ps); - if (!isSummaryInformation()) + if (!isSummaryInformation()) { throw new UnexpectedPropertySetTypeException - ("Not a " + getClass().getName()); + ("Not a " + getClass().getName()); + } } /** - *Returns the stream's title (or null
).
+ *
+ * Returns the stream's title (or null
).
Returns the stream's subject (or null
).
+ *
+ * Returns the stream's subject (or null
).
Returns the stream's author (or null
).
+ *
+ * Returns the stream's author (or null
).
Returns the stream's keywords (or null
).
+ *
+ * Returns the stream's keywords (or null
).
Returns the stream's comments (or null
).
+ *
+ * Returns the stream's comments (or null
).
Returns the stream's template (or null
).
+ *
+ * Returns the stream's template (or null
).
Returns the stream's last author (or null
).
+ *
+ * Returns the stream's last author (or null
).
Returns the stream's revision number (or
- * null
).
-
+ *
+ * Returns the stream's revision number (or null
).
Returns the stream's edit time (or null
).
+ *
+ * Returns the stream's edit time (or null
).
Returns the stream's last printed time (or
- * null
).
+ *
+ * Returns the stream's last printed time (or null
).
Returns the stream's creation time (or
- * null
).
+ *
+ * Returns the stream's creation time (or null
).
Returns the stream's last save time (or
- * null
).
+ *
+ * Returns the stream's last save time (or null
).
Returns the stream's page count or 0 if the {@link - * SummaryInformation} does not contain a page count.
+ *+ * + * Returns the stream's page count or 0 if the {@link SummaryInformation} + * does not contain a page count.
+ * + *@return The pageCount value */ - public int getPageCount() - { + public int getPageCount() { return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT); } /** - *Returns the stream's word count or 0 if the {@link - * SummaryInformation} does not contain a word count.
+ *+ * + * Returns the stream's word count or 0 if the {@link SummaryInformation} + * does not contain a word count.
+ * + *@return The wordCount value */ - public int getWordCount() - { + public int getWordCount() { return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT); } /** - *Returns the stream's char count or 0 if the {@link - * SummaryInformation} does not contain a char count.
+ *+ * + * Returns the stream's char count or 0 if the {@link SummaryInformation} + * does not contain a char count.
+ * + *@return The charCount value */ - public int getCharCount() - { + public int getCharCount() { return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT); } /** - *Returns the stream's thumbnail (or null
)
- * when this method is implemented. Please note that the
- * return type is likely to change!
- *
- *
FIXME / Hint to developers: Drew Varner - * <Drew.Varner -at- sc.edu> said that this is an image in WMF - * or Clipboard (BMP?) format. He also provided two links that - * might be helpful: http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch - * and http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp. - * However, we won't do any conversion into any image type but - * instead just return a byte array.
+ *
+ *
+ * Returns the stream's thumbnail (or null
) when this
+ * method is implemented. Please note that the return type is likely to
+ * change!
+ * + * FIXME / Hint to developers: Drew Varner <Drew.Varner + * -at- sc.edu> said that this is an image in WMF or Clipboard (BMP?) + * format. He also provided two links that might be helpful: http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch + * and http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp + * . However, we won't do any conversion into any image type but + * instead just return a byte array.
+ * + *@return The thumbnail value */ - public byte[] getThumbnail() - { + public byte[] getThumbnail() { return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL); } /** - *Returns the stream's application name (or
- * null
).
+ *
+ * Returns the stream's application name (or null
).
Returns one of the following values:
+ *+ * + * Returns one of the following values:
+ ** - *
* - *
0 if the {@link SummaryInformation} does not contain a - * security field or if there is no security on the document. Use - * {@link #wasNull} to distinguish between the two cases!
* - *
1 if the document is password protected
* - *
2 if the document is read-only recommended
* - *
4 if the document is read-only enforced
8 if the document is locked for annotations
Class to manipulate data in the Clipboard Variant - * ({@link Variant#VT_CF VT_CF}) format.
+ ** - * @see SummaryInformation#getThumbnail() + * Class to manipulate data in the Clipboard Variant ({@link Variant#VT_CF + * VT_CF}) format.
* - * @author Drew Varner (Drew.Varner inOrAround sc.edu) - * @version $Id$ - * @since 2002-04-29 + *@author Drew Varner (Drew.Varner inOrAround sc.edu) + *@created May 10, 2002 + *@see SummaryInformation#getThumbnail() + *@version $Id$ + *@since 2002-04-29 */ -public class Thumbnail -{ - - +public class Thumbnail { /** - *Offset in bytes where the Clipboard Format Tag
- * starts in the byte[]
returned by
- * {@link SummaryInformation#getThumbnail()}
+ *
+ * Offset in bytes where the Clipboard Format Tag starts in the byte[]
+ * returned by {@link SummaryInformation#getThumbnail()}
Offset in bytes where the Clipboard Format
- * starts in the byte[]
returned by
- * {@link SummaryInformation#getThumbnail()}
+ *
+ * Offset in bytes where the Clipboard Format starts in the byte[]
+ * returned by {@link SummaryInformation#getThumbnail()}
* - *
This is only valid if the Clipboard Format Tag - * is {@link #CFTAG_WINDOWS}
+ * This is only valid if the Clipboard Format Tag is {@link #CFTAG_WINDOWS} + * */ public static int OFFSET_CF = 8; - - /** - *Offset in bytes where the Windows Metafile
- * (WMF) image data starts in the byte[]
- * returned by {@link SummaryInformation#getThumbnail()}
There is only WMF data at this point in the
- * byte[]
if the Clipboard Format Tag is
- * {@link #CFTAG_WINDOWS} and the Clipboard Format is
- * {@link #CF_METAFILEPICT}.
Note: The byte[]
that starts at
- * OFFSET_WMFDATA
and ends at
- * getThumbnail().length - 1
forms a
- * complete WMF image. It can be saved to disk with a
- * .wmf
file type and read using a WMF-capable
- * image viewer.
+ *
+ * Offset in bytes where the Windows Metafile (WMF) image data starts in
+ * the byte[]
returned by {@link
+ * SummaryInformation#getThumbnail()}
+ *
+ * There is only WMF data at this point in the byte[]
if the
+ * Clipboard Format Tag is {@link #CFTAG_WINDOWS} and the Clipboard Format
+ * is {@link #CF_METAFILEPICT}.
+ *
+ * Note: The byte[]
that starts at OFFSET_WMFDATA
+ * and ends at getThumbnail().length - 1
forms a complete WMF
+ * image. It can be saved to disk with a .wmf
file type and
+ * read using a WMF-capable image viewer.
Clipboard Format Tag - Windows clipboard format
- *A DWORD
indicating a built-in Windows clipboard
- * format value
See: - * - * http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + *
+ * + * Clipboard Format Tag - Windows clipboard format
+ *
+ * A DWORD
indicating a built-in Windows clipboard format
+ * value
+ * + * See: http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + * */ public static int CFTAG_WINDOWS = -1; - - /** - *
Clipboard Format Tag - Macintosh clipboard format
- *A DWORD
indicating a Macintosh clipboard format value
+ * + * Clipboard Format Tag - Macintosh clipboard format
+ *
+ * A DWORD
indicating a Macintosh clipboard format value
* - *
See: - * - * http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + * See: http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + * */ public static int CFTAG_MACINTOSH = -2; - - /** - *
Clipboard Format Tag - Format ID
- *A GUID containing a format identifier (FMTID). This is rarely used.
+ *+ * + * Clipboard Format Tag - Format ID
+ * + * A GUID containing a format identifier (FMTID). This is rarely used.
+ ** - *
See: - * - * http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + * See: http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + * */ public static int CFTAG_FMTID = -3; - - /** - *
Clipboard Format Tag - No Data
- *a DWORD
indicating No data. This is rarely used.
+ * + * Clipboard Format Tag - No Data
* - *
See:
- *
- * http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp
+ * a DWORD
indicating No data. This is rarely used.
+ * + * See: http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp + * */ public static int CFTAG_NODATA = 0; - - /** - *
Clipboard Format - Windows metafile format. - * This is the recommended way to store thumbnails - * in Property Streams.
- *Note: this is not the same - * format used in regular WMF images. The clipboard - * version of this format has an extra clipboard-specific - * header
+ *+ * + * Clipboard Format - Windows metafile format. This is the recommended way + * to store thumbnails in Property Streams.
+ * + * Note: this is not the same format used in regular WMF + * images. The clipboard version of this format has an extra + * clipboard-specific header
*/ public static int CF_METAFILEPICT = 3; - - /** - *Clipboard Format - Device Independent Bitmap
+ *+ * + * Clipboard Format - Device Independent Bitmap
*/ public static int CF_DIB = 8; - - /** - *Clipboard Format - Enhanced Windows metafile format
+ *+ * + * Clipboard Format - Enhanced Windows metafile format
*/ public static int CF_ENHMETAFILE = 14; - - /** - *Clipboard Format - Bitmap
- *Obsolete, See: - * - * msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp - * - *
+ *+ * + * Clipboard Format - Bitmap
+ * + * Obsolete, See: msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp + *
*/ public static int CF_BITMAP = 2; - - /** - * A byte[]
to hold a thumbnail image in
- * ({@link Variant#VT_CF VT_CF}) format.
+ *
+ * A byte[]
to hold a thumbnail image in ({@link Variant#VT_CF
+ * VT_CF}) format.
Default Constructor. If you use then one you'll have to add
- * the thumbnail byte[]
from {@link
- * SummaryInformation#getThumbnail()} to do any useful
- * manipulations, otherwise you'll get a
- * NullPointerException
.
+ *
+ * Default Constructor. If you use then one you'll have to add the
+ * thumbnail byte[]
from {@link
+ * SummaryInformation#getThumbnail()} to do any useful manipulations,
+ * otherwise you'll get a NullPointerException
.
+ * + *
+ * + *@param thumbnailData Description of the Parameter */ - public Thumbnail(byte[] thumbnailData) - { + public Thumbnail(byte[] thumbnailData) { this.thumbnailData = thumbnailData; } /** - *Returns the thumbnail as a byte[]
in
- * {@link Variant#VT_CF VT_CF} format.
*
- * @see SummaryInformation#getThumbnail()
+ * Returns the thumbnail as a byte[]
in {@link Variant#VT_CF
+ * VT_CF} format.
Sets the Thumbnail's underlying byte[]
in
- * {@link Variant#VT_CF VT_CF} format.
+ *
+ * Sets the Thumbnail's underlying byte[]
in {@link
+ * Variant#VT_CF VT_CF} format.
Returns an int
representing the Clipboard
- * Format Tag
Possible return values are: - *
+ *
+ * Returns an int
representing the Clipboard Format Tag
+ * + * Possible return values are: + *
Returns an int
representing the Clipboard
- * Format
Will throw an exceptionif the Thumbnail's Clipboard - * Format Tag is not - * {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS} - *
+ ** - *
Possible return values are: - *
int
representing the Clipboard Format * - * @return a flag indicating the Clipboard Format + * Will throw an exceptionif the Thumbnail's Clipboard Format Tag is not + * {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS}
* - * @throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS + * Possible return values are: + *
Returns the Thumbnail as a byte[]
- * of WMF data if the Thumbnail's Clipboard Format Tag
- * is {@link #CFTAG_WINDOWS CFTAG_WINDOWS}
- * and its Clipboard Format is
- * {@link #CF_METAFILEPICT CF_METAFILEPICT}
* - *
This byte[]
is in the traditional WMF file,
- * not the clipboard-specific version with special headers.
byte[]
of WMF data if the
+ * Thumbnail's Clipboard Format Tag is {@link #CFTAG_WINDOWS CFTAG_WINDOWS}
+ * and its Clipboard Format is {@link #CF_METAFILEPICT CF_METAFILEPICT}
+ * * - *
See - * http://www.wvware.com/caolan/ora-wmf.html - * for more information on the WMF image format.
+ * Thisbyte[]
is in the traditional WMF file, not the
+ * clipboard-specific version with special headers. * - * @throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS - * and CF_METAFILEPICT + * See + * http://www.wvware.com/caolan/ora-wmf.html for more information on + * the WMF image format.
* - * @return a WMF image of the Thumbnail + *@return a WMF image of the Thumbnail + *@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS and + * CF_METAFILEPICT */ - public byte[] getThumbnailAsWMF() throws HPSFException - { - if ( !(getClipboardFormatTag() == CFTAG_WINDOWS) ) - { + public byte[] getThumbnailAsWMF() throws HPSFException { + if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) { 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 " + - "be CF_METAFILEPICT."); - } - else - { + "be CF_METAFILEPICT."); + } else { byte[] thumbnail = getThumbnail(); int wmfImageLength = thumbnail.length - OFFSET_WMFDATA; byte[] wmfImage = new byte[wmfImageLength]; System.arraycopy(thumbnail, - OFFSET_WMFDATA, - wmfImage, - 0, - wmfImageLength); + OFFSET_WMFDATA, + wmfImage, + 0, + wmfImageLength); return wmfImage; } } diff --git a/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java b/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java index d9da7d8f42..c80633b45a 100644 --- a/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java +++ b/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java @@ -1,92 +1,113 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *This exception is thrown if a certain type of property set is - * expected (e.g. a Document Summary Information) but the provided - * property set is not of that type.
+ *+ * + * This exception is thrown if a certain type of property set is expected (e.g. + * a Document Summary Information) but the provided property set is not of that + * type.
* - *
The constructors of this class are analogous to those of its - * superclass and documented there.
+ * The constructors of this class are analogous to those of its superclass and + * documented there. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id: UnexpectedPropertySetTypeException.java,v 1.3 2002/05/01 + * 09:31:52 klute Exp $ + *@since 2002-02-09 */ -public class UnexpectedPropertySetTypeException extends HPSFException -{ +public class UnexpectedPropertySetTypeException extends HPSFException { - public UnexpectedPropertySetTypeException() - { + /** + * Constructor for the UnexpectedPropertySetTypeException object + */ + public UnexpectedPropertySetTypeException() { super(); } - public UnexpectedPropertySetTypeException(final String msg) - { + + /** + * Constructor for the UnexpectedPropertySetTypeException object + * + *@param msg Description of the Parameter + */ + public UnexpectedPropertySetTypeException(final String msg) { super(msg); } - public UnexpectedPropertySetTypeException(final Throwable reason) - { + + /** + * Constructor for the UnexpectedPropertySetTypeException object + * + *@param reason Description of the Parameter + */ + public UnexpectedPropertySetTypeException(final Throwable reason) { super(reason); } + + /** + * Constructor for the UnexpectedPropertySetTypeException object + * + *@param msg Description of the Parameter + *@param reason Description of the Parameter + */ public UnexpectedPropertySetTypeException(final String msg, - final Throwable reason) - { + final Throwable reason) { super(msg, reason); } diff --git a/src/java/org/apache/poi/hpsf/Util.java b/src/java/org/apache/poi/hpsf/Util.java index 7ea6911cff..5cb56e9635 100644 --- a/src/java/org/apache/poi/hpsf/Util.java +++ b/src/java/org/apache/poi/hpsf/Util.java @@ -1,148 +1,168 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Provides various static utility methods.
+ *+ * + * Provides various static utility methods.
* - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class Util -{ +public class Util { /** - *Checks whether two byte arrays a and b - * are equal. They are equal
+ *+ * + * Checks whether two byte arrays a and b are equal. + * They are equal
+ *+ * + * if they have the same length and
+ * + * if for each i with i >= 0 and + * i < a.length holds a [ + * i ] == b [i ].
if they have the same length and
if for each i with - * i >= 0 and - * i < a.length holds - * a[i] == b[i].
Copies a part of a byte array into another byte array.
+ *+ * + * Copies a part of a byte array into another byte array.
+ * + *@param src Description of the Parameter + *@param srcOffset Description of the Parameter + *@param length Description of the Parameter + *@param dst Description of the Parameter + *@param dstOffset Description of the Parameter */ public static void copy(final byte[] src, final int srcOffset, - final int length, - final byte[] dst, final int dstOffset) - { - for (int i = 0; i < length; i++) + final int length, + final byte[] dst, final int dstOffset) { + for (int i = 0; i < length; i++) { dst[dstOffset + i] = src[srcOffset + i]; + } } /** - *Concatenates the contents of several byte arrays into a - * single one.
+ ** - * @param byteArrays The byte arrays to be concatened. + * Concatenates the contents of several byte arrays into a single one.
* - * @return A new byte array containing the concatenated byte - * arrays. + *@param byteArrays The byte arrays to be concatened. + *@return A new byte array containing the concatenated byte + * arrays. */ - public static byte[] cat(final byte[][] byteArrays) - { + public static byte[] cat(final byte[][] byteArrays) { int capacity = 0; - for (int i = 0; i < byteArrays.length; i++) + for (int i = 0; i < byteArrays.length; i++) { capacity += byteArrays[i].length; + } final byte[] result = new byte[capacity]; int r = 0; - for (int i = 0; i < byteArrays.length; i++) - for (int j = 0; j < byteArrays[i].length; j++) + for (int i = 0; i < byteArrays.length; i++) { + for (int j = 0; j < byteArrays[i].length; j++) { result[r++] = byteArrays[i][j]; + } + } return result; } /** - *Copies bytes from a source byte array into a new byte - * array.
- * - * @param src Copy from this byte array. + ** - * @param offset Start copying here. + * Copies bytes from a source byte array into a new byte array.
* - * @param length Copy this many bytes. - * - * @return The new byte array. Its length is number of copied bytes. + *@param src Copy from this byte array. + *@param offset Start copying here. + *@param length Copy this many bytes. + *@return The new byte array. Its length is number of copied bytes. */ public static byte[] copy(final byte[] src, final int offset, - final int length) - { + final int length) { final byte[] result = new byte[length]; copy(src, offset, length, result, 0); return result; @@ -151,29 +171,31 @@ public class Util /** - *The difference between the Windows epoch (1601-01-01 - * 00:00:00) and the Unix epoch (1970-01-01 00:00:00) in - * milliseconds: 11644473600000L. (Use your favorite spreadsheet - * program to verify the correctness of this value. By the way, - * did you notice that you can tell from the epochs which - * operating system is the modern one? :-))
+ *+ * + * The difference between the Windows epoch (1601-01-01 00:00:00) and the + * Unix epoch (1970-01-01 00:00:00) in milliseconds: 11644473600000L. (Use + * your favorite spreadsheet program to verify the correctness of this + * value. By the way, did you notice that you can tell from the epochs + * which operating system is the modern one? :-))
*/ public final static long EPOCH_DIFF = 11644473600000L; + /** - *Converts a Windows FILETIME into a {@link Date}. The Windows - * FILETIME structure holds a date and time associated with a - * file. The structure identifies a 64-bit integer specifying the - * number of 100-nanosecond intervals which have passed since - * January 1, 1601. This 64-bit value is split into the two double - * word stored in the structure.
+ ** - * @param high The higher double word of the FILETIME structure. + * Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME + * structure holds a date and time associated with a file. The structure + * identifies a 64-bit integer specifying the number of 100-nanosecond + * intervals which have passed since January 1, 1601. This 64-bit value is + * split into the two double word stored in the structure.
* - * @param low The lower double word of the FILETIME structure. + *@param high The higher double word of the FILETIME structure. + *@param low The lower double word of the FILETIME structure. + *@return Description of the Return Value */ - public static Date filetimeToDate(final int high, final int low) - { + public static Date filetimeToDate(final int high, final int low) { final long filetime = ((long) high) << 32 | ((long) low); final long ms_since_16010101 = filetime / (1000 * 10); final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF; diff --git a/src/java/org/apache/poi/hpsf/Variant.java b/src/java/org/apache/poi/hpsf/Variant.java index 29de83917d..2866117296 100644 --- a/src/java/org/apache/poi/hpsf/Variant.java +++ b/src/java/org/apache/poi/hpsf/Variant.java @@ -1,362 +1,443 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *The Variant types as defined by Microsoft's COM. I - * found this information in http://www.marin.clara.net/COM/variant_type_definitions.htm.
+ *+ * + * The Variant types as defined by Microsoft's COM. I found this + * information in + * http://www.marin.clara.net/COM/variant_type_definitions.htm .
* - *
In the variant types descriptions the following shortcuts are - * used: [V] - may appear in a VARIANT, - * [T] - may appear in a TYPEDESC, - * [P] - may appear in an OLE property set, - * [S] - may appear in a Safe Array.
+ * In the variant types descriptions the following shortcuts are used: + * [V] - may appear in a VARIANT, [T] - may appear in + * a TYPEDESC, [P] - may appear in an OLE property set, + * [S] - may appear in a Safe Array. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class Variant -{ +public class Variant { /** - *[V][P] Nothing.
+ *+ * + * [V][P] Nothing.
*/ public final static int VT_EMPTY = 0; /** - *[V][P] SQL style Null.
+ *+ * + * [V][P] SQL style Null.
*/ public final static int VT_NULL = 1; /** - *[V][T][P][S] 2 byte signed int.
+ *+ * + * [V][T][P][S] 2 byte signed int.
*/ public final static int VT_I2 = 2; /** - *[V][T][P][S] 4 byte signed int.
+ *+ * + * [V][T][P][S] 4 byte signed int.
*/ public final static int VT_I4 = 3; /** - *[V][T][P][S] 4 byte real.
+ *+ * + * [V][T][P][S] 4 byte real.
*/ public final static int VT_R4 = 4; /** - *[V][T][P][S] 8 byte real.
+ *+ * + * [V][T][P][S] 8 byte real.
*/ public final static int VT_R8 = 5; /** - *[V][T][P][S] currency. How long is this? How is it to be - * interpreted?
+ *+ * + * [V][T][P][S] currency. How long + * is this? How is it to be interpreted?
*/ public final static int VT_CY = 6; /** - *[V][T][P][S] date. How long is this? How is it to be - * interpreted?
+ *+ * + * [V][T][P][S] date. How long is + * this? How is it to be interpreted?
*/ public final static int VT_DATE = 7; /** - *[V][T][P][S] OLE Automation string. How long is this? How is it - * to be interpreted?
+ *+ * + * [V][T][P][S] OLE Automation string. How long is this? How is it to be interpreted?
*/ public final static int VT_BSTR = 8; /** - *[V][T][P][S] IDispatch *. How long is this? How is it to be - * interpreted?
+ *+ * + * [V][T][P][S] IDispatch *. How + * long is this? How is it to be interpreted?
*/ public final static int VT_DISPATCH = 9; /** - *[V][T][S] SCODE. How long is this? How is it to be - * interpreted?
+ *+ * + * [V][T][S] SCODE. How long is + * this? How is it to be interpreted?
*/ public final static int VT_ERROR = 10; /** - *[V][T][P][S] True=-1, False=0.
+ *+ * + * [V][T][P][S] True=-1, False=0.
*/ public final static int VT_BOOL = 11; /** - *[V][T][P][S] VARIANT *. How long is this? How is it to be - * interpreted?
+ *+ * + * [V][T][P][S] VARIANT *. How long + * is this? How is it to be interpreted?
*/ public final static int VT_VARIANT = 12; /** - *[V][T][S] IUnknown *. How long is this? How is it to be - * interpreted?
+ *+ * + * [V][T][S] IUnknown *. How long + * is this? How is it to be interpreted?
*/ public final static int VT_UNKNOWN = 13; /** - *[V][T][S] 16 byte fixed point.
+ *+ * + * [V][T][S] 16 byte fixed point.
*/ public final static int VT_DECIMAL = 14; /** - *[T] signed char.
+ *+ * + * [T] signed char.
*/ public final static int VT_I1 = 16; /** - *[V][T][P][S] unsigned char.
+ *+ * + * [V][T][P][S] unsigned char.
*/ public final static int VT_UI1 = 17; /** - *[T][P] unsigned short.
+ *+ * + * [T][P] unsigned short.
*/ public final static int VT_UI2 = 18; /** - *[T][P] unsigned int.
+ *+ * + * [T][P] unsigned int.
*/ public final static int VT_UI4 = 19; /** - *[T][P] signed 64-bit int.
+ *+ * + * [T][P] signed 64-bit int.
*/ public final static int VT_I8 = 20; /** - *[T][P] unsigned 64-bit int.
+ *+ * + * [T][P] unsigned 64-bit int.
*/ public final static int VT_UI8 = 21; /** - *[T] signed machine int.
+ *+ * + * [T] signed machine int.
*/ public final static int VT_INT = 22; /** - *[T] unsigned machine int.
+ *+ * + * [T] unsigned machine int.
*/ public final static int VT_UINT = 23; /** - *[T] C style void.
+ *+ * + * [T] C style void.
*/ public final static int VT_VOID = 24; /** - *[T] Standard return type. How long is this? How is it to be - * interpreted?
+ *+ * + * [T] Standard return type. How + * long is this? How is it to be interpreted?
*/ public final static int VT_HRESULT = 25; /** - *[T] pointer type. How long is this? How is it to be - * interpreted?
*/ + *+ * + * [T] pointer type. How long is + * this? How is it to be interpreted?
+ */ public final static int VT_PTR = 26; /** - *[T] (use VT_ARRAY in VARIANT).
*/ + *+ * + * [T] (use VT_ARRAY in VARIANT).
+ */ public final static int VT_SAFEARRAY = 27; /** - *[T] C style array. How long is this? How is it to be - * interpreted?
+ *+ * + * [T] C style array. How long is + * this? How is it to be interpreted?
*/ public final static int VT_CARRAY = 28; /** - *[T] user defined type. How long is this? How is it to be - * interpreted?
+ *+ * + * [T] user defined type. How long + * is this? How is it to be interpreted?
*/ public final static int VT_USERDEFINED = 29; /** - *[T][P] null terminated string.
+ *+ * + * [T][P] null terminated string.
*/ public final static int VT_LPSTR = 30; /** - *[T][P] wide (Unicode) null terminated string.
+ *+ * + * [T][P] wide (Unicode) null terminated string.
*/ public final static int VT_LPWSTR = 31; /** - *[P] FILETIME. The FILETIME structure holds a date and time - * associated with a file. The structure identifies a 64-bit - * integer specifying the number of 100-nanosecond intervals which - * have passed since January 1, 1601. This 64-bit value is split - * into the two dwords stored in the structure.
+ *+ * + * [P] FILETIME. The FILETIME structure holds a date and time associated + * with a file. The structure identifies a 64-bit integer specifying the + * number of 100-nanosecond intervals which have passed since January 1, + * 1601. This 64-bit value is split into the two dwords stored in the + * structure.
*/ public final static int VT_FILETIME = 64; /** - *[P] Length prefixed bytes.
+ *+ * + * [P] Length prefixed bytes.
*/ public final static int VT_BLOB = 65; /** - *[P] Name of the stream follows.
+ *+ * + * [P] Name of the stream follows.
*/ public final static int VT_STREAM = 66; /** - *[P] Name of the storage follows.
+ *+ * + * [P] Name of the storage follows.
*/ public final static int VT_STORAGE = 67; /** - *[P] Stream contains an object. How long is this? How is it to be - * interpreted?
+ *+ * + * [P] Stream contains an object. + * How long is this? How is it to be interpreted?
*/ public final static int VT_STREAMED_OBJECT = 68; /** - *[P] Storage contains an object. How long is this? How is it to be - * interpreted?
+ *+ * + * [P] Storage contains an object. + * How long is this? How is it to be interpreted?
*/ public final static int VT_STORED_OBJECT = 69; /** - *[P] Blob contains an object. How long is this? How is it to be - * interpreted?
+ *+ * + * [P] Blob contains an object. How + * long is this? How is it to be interpreted?
*/ public final static int VT_BLOB_OBJECT = 70; /** - *[P] Clipboard format. How long is this? How is it to be - * interpreted?
+ *+ * + * [P] Clipboard format. How long + * is this? How is it to be interpreted?
*/ public final static int VT_CF = 71; /** - *[P] A Class ID.
- *It consists of a 32 bit unsigned integer indicating the size - * of the structure, a 32 bit signed integer indicating (Clipboard - * Format Tag) indicating the type of data that it contains, and - * then a byte array containing the data.
+ *+ * + * [P] A Class ID.
* - *
The valid Clipboard Format Tags are: - *
* - *
- *
typedef struct tagCLIPDATA { + * The valid Clipboard Format Tags are: + *
+ * + *
typedef struct tagCLIPDATA { * // cbSize is the size of the buffer pointed to * // by pClipData, plus sizeof(ulClipFmt) * ULONG cbSize; * long ulClipFmt; * BYTE* pClipData; - * } CLIPDATA;- * See - * - * msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp - * - * + * } CLIPDATA; See msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp + * */ public final static int VT_CLSID = 72; /** - *
[P] simple counted array. How long is this? How is it to be - * interpreted?
+ *+ * + * [P] simple counted array. How + * long is this? How is it to be interpreted?
*/ public final static int VT_VECTOR = 0x1000; /** - *[V] SAFEARRAY*. How long is this? How is it to be - * interpreted?
+ *+ * + * [V] SAFEARRAY*. How long is + * this? How is it to be interpreted?
*/ public final static int VT_ARRAY = 0x2000; /** - *[V] void* for local use. How long is this? How is it to be - * interpreted?
+ *+ * + * [V] void* for local use. How + * long is this? How is it to be interpreted?
*/ public final static int VT_BYREF = 0x4000; + /** + * Description of the Field + */ public final static int VT_RESERVED = 0x8000; + /** + * Description of the Field + */ public final static int VT_ILLEGAL = 0xFFFF; + /** + * Description of the Field + */ public final static int VT_ILLEGALMASKED = 0xFFF; + /** + * Description of the Field + */ public final static int VT_TYPEMASK = 0xFFF; } diff --git a/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java b/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java index 4c0ca18934..217a635734 100644 --- a/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java +++ b/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java @@ -1,230 +1,346 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *This is a dictionary mapping property IDs to property ID - * strings.
+ *+ * + * This is a dictionary mapping property IDs to property ID strings.
* - *
The methods {@link #getSummaryInformationProperties} and {@link - * #getDocumentSummaryInformationProperties} return singleton {@link - * PropertyIDMap}s. An application that wants to extend these maps - * should treat them as unmodifiable, copy them and modifiy the - * copies.
+ * The methods {@link #getSummaryInformationProperties} and {@link + * #getDocumentSummaryInformationProperties} return singleton {@link + * PropertyIDMap}s. An application that wants to extend these maps should treat + * them as unmodifiable, copy them and modifiy the copies.* - *
FIXME: Make the singletons - * unmodifiable. However, since this requires use a {@link HashMap} - * delegate instead of extending {@link HashMap} and would require a - * lot of stupid typing, I won't do it for the time being.
+ * FIXME: Make the singletons unmodifiable. However, since + * this requires use a {@link HashMap} delegate instead of extending {@link + * HashMap} and would require a lot of stupid typing, I won't do it for the + * time being. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class PropertyIDMap extends HashMap -{ - - /* The following definitions are for the Summary Information. */ - public static final int PID_TITLE = 2; - public static final int PID_SUBJECT = 3; - public static final int PID_AUTHOR = 4; - public static final int PID_KEYWORDS = 5; - public static final int PID_COMMENTS = 6; - public static final int PID_TEMPLATE = 7; - public static final int PID_LASTAUTHOR = 8; - public static final int PID_REVNUMBER = 9; - public static final int PID_EDITTIME = 10; - public static final int PID_LASTPRINTED = 11; - public static final int PID_CREATE_DTM = 12; - public static final int PID_LASTSAVE_DTM = 13; - public static final int PID_PAGECOUNT = 14; - public static final int PID_WORDCOUNT = 15; - public static final int PID_CHARCOUNT = 16; - public static final int PID_THUMBNAIL = 17; - public static final int PID_APPNAME = 18; - public static final int PID_SECURITY = 19; - - /* The following definitions are for the Document Summary Information. */ - public static final int PID_CATEGORY = 2; - public static final int PID_PRESFORMAT = 3; - public static final int PID_BYTECOUNT = 4; - public static final int PID_LINECOUNT = 5; - public static final int PID_PARCOUNT = 6; - public static final int PID_SLIDECOUNT = 7; - public static final int PID_NOTECOUNT = 8; - public static final int PID_HIDDENCOUNT = 9; - public static final int PID_MMCLIPCOUNT = 10; - public static final int PID_SCALE = 11; - public static final int PID_HEADINGPAIR = 12; - public static final int PID_DOCPARTS = 13; - public static final int PID_MANAGER = 14; - public static final int PID_COMPANY = 15; - public static final int PID_LINKSDIRTY = 16; +public class PropertyIDMap extends HashMap { + + /* + * The following definitions are for the Summary Information. + */ + /** + * Description of the Field + */ + public final static int PID_TITLE = 2; + /** + * Description of the Field + */ + public final static int PID_SUBJECT = 3; + /** + * Description of the Field + */ + public final static int PID_AUTHOR = 4; + /** + * Description of the Field + */ + public final static int PID_KEYWORDS = 5; + /** + * Description of the Field + */ + public final static int PID_COMMENTS = 6; + /** + * Description of the Field + */ + public final static int PID_TEMPLATE = 7; + /** + * Description of the Field + */ + public final static int PID_LASTAUTHOR = 8; + /** + * Description of the Field + */ + public final static int PID_REVNUMBER = 9; + /** + * Description of the Field + */ + public final static int PID_EDITTIME = 10; + /** + * Description of the Field + */ + public final static int PID_LASTPRINTED = 11; + /** + * Description of the Field + */ + public final static int PID_CREATE_DTM = 12; + /** + * Description of the Field + */ + public final static int PID_LASTSAVE_DTM = 13; + /** + * Description of the Field + */ + public final static int PID_PAGECOUNT = 14; + /** + * Description of the Field + */ + public final static int PID_WORDCOUNT = 15; + /** + * Description of the Field + */ + public final static int PID_CHARCOUNT = 16; + /** + * Description of the Field + */ + public final static int PID_THUMBNAIL = 17; + /** + * Description of the Field + */ + public final static int PID_APPNAME = 18; + /** + * Description of the Field + */ + public final static int PID_SECURITY = 19; + + /* + * The following definitions are for the Document Summary Information. + */ + /** + * Description of the Field + */ + public final static int PID_CATEGORY = 2; + /** + * Description of the Field + */ + public final static int PID_PRESFORMAT = 3; + /** + * Description of the Field + */ + public final static int PID_BYTECOUNT = 4; + /** + * Description of the Field + */ + public final static int PID_LINECOUNT = 5; + /** + * Description of the Field + */ + public final static int PID_PARCOUNT = 6; + /** + * Description of the Field + */ + public final static int PID_SLIDECOUNT = 7; + /** + * Description of the Field + */ + public final static int PID_NOTECOUNT = 8; + /** + * Description of the Field + */ + public final static int PID_HIDDENCOUNT = 9; + /** + * Description of the Field + */ + public final static int PID_MMCLIPCOUNT = 10; + /** + * Description of the Field + */ + public final static int PID_SCALE = 11; + /** + * Description of the Field + */ + public final static int PID_HEADINGPAIR = 12; + /** + * Description of the Field + */ + public final static int PID_DOCPARTS = 13; + /** + * Description of the Field + */ + public final static int PID_MANAGER = 14; + /** + * Description of the Field + */ + public final static int PID_COMPANY = 15; + /** + * Description of the Field + */ + public final static int PID_LINKSDIRTY = 16; private static PropertyIDMap summaryInformationProperties; private static PropertyIDMap documentSummaryInformationProperties; - public PropertyIDMap(int initialCapacity, float loadFactor) - { - super(initialCapacity, loadFactor); + /** + * Constructor for the PropertyIDMap object + * + *@param initialCapacity Description of the Parameter + *@param loadFactor Description of the Parameter + */ + public PropertyIDMap(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); } /** - *Puts a ID string for an ID into the {@link - * PropertyIDMap}.
+ ** - * @param id The ID. + * Puts a ID string for an ID into the {@link PropertyIDMap}.
* - * @param idString The ID string. + *@param id The ID. + *@param idString The ID string. + *@return Description of the Return Value */ - public Object put(int id, String idString) - { - return put(new Integer(id), idString); + public Object put(int id, String idString) { + return put(new Integer(id), idString); } /** - *Gets the ID string for an ID from the {@link - * PropertyIDMap}.
+ *+ * + * Gets the ID string for an ID from the {@link PropertyIDMap}.
* - * @param id The ID. + *@param id The ID. + *@return Description of the Return Value */ - public Object get(int id) - { - return get(new Integer(id)); + public Object get(int id) { + return get(new Integer(id)); } /** - *Returns the Summary Information properties singleton.
- */ - public static PropertyIDMap getSummaryInformationProperties() - { - if (summaryInformationProperties == null) - { - PropertyIDMap m = new PropertyIDMap(17, (float) 1.0); - m.put(PID_TITLE, "PID_TITLE"); - m.put(PID_SUBJECT, "PID_SUBJECT"); - m.put(PID_AUTHOR, "PID_AUTHOR"); - m.put(PID_KEYWORDS, "PID_KEYWORDS"); - m.put(PID_COMMENTS, "PID_COMMENTS"); - m.put(PID_TEMPLATE, "PID_TEMPLATE"); - m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR"); - m.put(PID_REVNUMBER, "PID_REVNUMBER"); - m.put(PID_EDITTIME, "PID_EDITTIME"); - m.put(PID_LASTPRINTED, "PID_LASTPRINTED"); - m.put(PID_CREATE_DTM, "PID_CREATE_DTM"); - m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM"); - m.put(PID_PAGECOUNT, "PID_PAGECOUNT"); - m.put(PID_WORDCOUNT, "PID_WORDCOUNT"); - m.put(PID_CHARCOUNT, "PID_CHARCOUNT"); - m.put(PID_THUMBNAIL, "PID_THUMBNAIL"); - m.put(PID_APPNAME, "PID_APPNAME"); - m.put(PID_SECURITY, "PID_SECURITY"); - summaryInformationProperties = m; - } - return summaryInformationProperties; + *+ * + * Returns the Summary Information properties singleton.
+ * + *@return The summaryInformationProperties value + */ + public static PropertyIDMap getSummaryInformationProperties() { + if (summaryInformationProperties == null) { + PropertyIDMap m = new PropertyIDMap(17, (float) 1.0); + m.put(PID_TITLE, "PID_TITLE"); + m.put(PID_SUBJECT, "PID_SUBJECT"); + m.put(PID_AUTHOR, "PID_AUTHOR"); + m.put(PID_KEYWORDS, "PID_KEYWORDS"); + m.put(PID_COMMENTS, "PID_COMMENTS"); + m.put(PID_TEMPLATE, "PID_TEMPLATE"); + m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR"); + m.put(PID_REVNUMBER, "PID_REVNUMBER"); + m.put(PID_EDITTIME, "PID_EDITTIME"); + m.put(PID_LASTPRINTED, "PID_LASTPRINTED"); + m.put(PID_CREATE_DTM, "PID_CREATE_DTM"); + m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM"); + m.put(PID_PAGECOUNT, "PID_PAGECOUNT"); + m.put(PID_WORDCOUNT, "PID_WORDCOUNT"); + m.put(PID_CHARCOUNT, "PID_CHARCOUNT"); + m.put(PID_THUMBNAIL, "PID_THUMBNAIL"); + m.put(PID_APPNAME, "PID_APPNAME"); + m.put(PID_SECURITY, "PID_SECURITY"); + summaryInformationProperties = m; + } + return summaryInformationProperties; } /** - *Returns the Summary Information properties singleton.
- */ - public static PropertyIDMap getDocumentSummaryInformationProperties() - { - if (documentSummaryInformationProperties == null) - { - PropertyIDMap m = new PropertyIDMap(17, (float) 1.0); - m.put(PID_CATEGORY, "PID_CATEGORY"); - m.put(PID_PRESFORMAT, "PID_PRESFORMAT"); - m.put(PID_BYTECOUNT, "PID_BYTECOUNT"); - m.put(PID_LINECOUNT, "PID_LINECOUNT"); - m.put(PID_PARCOUNT, "PID_PARCOUNT"); - m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT"); - m.put(PID_NOTECOUNT, "PID_NOTECOUNT"); - m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT"); - m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT"); - m.put(PID_SCALE, "PID_SCALE"); - m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR"); - m.put(PID_DOCPARTS, "PID_DOCPARTS"); - m.put(PID_MANAGER, "PID_MANAGER"); - m.put(PID_COMPANY, "PID_COMPANY"); - m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY"); - documentSummaryInformationProperties = m; - } - return documentSummaryInformationProperties; - + *+ * + * Returns the Summary Information properties singleton.
+ * + *@return The documentSummaryInformationProperties value + */ + public static PropertyIDMap getDocumentSummaryInformationProperties() { + if (documentSummaryInformationProperties == null) { + PropertyIDMap m = new PropertyIDMap(17, (float) 1.0); + m.put(PID_CATEGORY, "PID_CATEGORY"); + m.put(PID_PRESFORMAT, "PID_PRESFORMAT"); + m.put(PID_BYTECOUNT, "PID_BYTECOUNT"); + m.put(PID_LINECOUNT, "PID_LINECOUNT"); + m.put(PID_PARCOUNT, "PID_PARCOUNT"); + m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT"); + m.put(PID_NOTECOUNT, "PID_NOTECOUNT"); + m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT"); + m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT"); + m.put(PID_SCALE, "PID_SCALE"); + m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR"); + m.put(PID_DOCPARTS, "PID_DOCPARTS"); + m.put(PID_MANAGER, "PID_MANAGER"); + m.put(PID_COMPANY, "PID_COMPANY"); + m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY"); + documentSummaryInformationProperties = m; + } + return documentSummaryInformationProperties; } - public static void main(String args[]) - { - PropertyIDMap s1 = getSummaryInformationProperties(); - PropertyIDMap s2 = getDocumentSummaryInformationProperties(); - System.out.println("s1: " + s1); - System.out.println("s2: " + s2); + /** + * Description of the Method + * + *@param args Description of the Parameter + */ + public static void main(String args[]) { + PropertyIDMap s1 = getSummaryInformationProperties(); + PropertyIDMap s2 = getDocumentSummaryInformationProperties(); + System.out.println("s1: " + s1); + System.out.println("s2: " + s2); } } diff --git a/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java b/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java index ae90f9071d..13579c8caf 100644 --- a/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java +++ b/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java @@ -1,124 +1,130 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 +/* + * ==================================================================== + * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Maps section format IDs to {@link PropertyIDMap}s. It is - * initialized with two well-known section format IDs: those of the - * \005SummaryInformation stream and the - * \005DocumentSummaryInformation stream.
+ *+ * + * Maps section format IDs to {@link PropertyIDMap}s. It is initialized with + * two well-known section format IDs: those of the \005SummaryInformation + * stream and the \005DocumentSummaryInformation stream.
* - *
If you have a section format ID you can use it as a key to query
- * this map. If you get a {@link PropertyIDMap} returned your section
- * is well-known and you can query the {@link PropertyIDMap} for PID
- * strings. If you get back null
you are on your own.
null
you are on your own. * - *
This {@link Map} expects the byte arrays of section format IDs - * as keys. A key maps to a {@link PropertyIDMap} describing the - * property IDs in sections with the specified section format ID.
+ * This {@link Map} expects the byte arrays of section format IDs as keys. A + * key maps to a {@link PropertyIDMap} describing the property IDs in sections + * with the specified section format ID. * - * @author Rainer Klute (klute@rainer-klute.de) - * @version $Id$ - * @since 2002-02-09 + *@author Rainer Klute (klute@rainer-klute.de) + *@created May 10, 2002 + *@version $Id$ + *@since 2002-02-09 */ -public class SectionIDMap extends HashMap -{ +public class SectionIDMap extends HashMap { /** - *The SummaryInformation's section's format ID.
+ *+ * + * The SummaryInformation's section's format ID.
*/ public final static byte[] SUMMARY_INFORMATION_ID = - new byte[]{(byte) 0xF2, (byte) 0x9F, (byte) 0x85, (byte) 0xE0, - (byte) 0x4F, (byte) 0xF9, (byte) 0x10, (byte) 0x68, - (byte) 0xAB, (byte) 0x91, (byte) 0x08, (byte) 0x00, - (byte) 0x2B, (byte) 0x27, (byte) 0xB3, (byte) 0xD9}; + new byte[]{(byte) 0xF2, (byte) 0x9F, (byte) 0x85, (byte) 0xE0, + (byte) 0x4F, (byte) 0xF9, (byte) 0x10, (byte) 0x68, + (byte) 0xAB, (byte) 0x91, (byte) 0x08, (byte) 0x00, + (byte) 0x2B, (byte) 0x27, (byte) 0xB3, (byte) 0xD9}; /** - *The DocumentSummaryInformation's first section's format - * ID. The second section has a different format ID which is not - * well-known.
+ *+ * + * The DocumentSummaryInformation's first section's format ID. The second + * section has a different format ID which is not well-known.
*/ public final static byte[] DOCUMENT_SUMMARY_INFORMATION_ID = - new byte[]{(byte) 0xD5, (byte) 0xCD, (byte) 0xD5, (byte) 0x02, - (byte) 0x2E, (byte) 0x9C, (byte) 0x10, (byte) 0x1B, - (byte) 0x93, (byte) 0x97, (byte) 0x08, (byte) 0x00, - (byte) 0x2B, (byte) 0x2C, (byte) 0xF9, (byte) 0xAE}; + new byte[]{(byte) 0xD5, (byte) 0xCD, (byte) 0xD5, (byte) 0x02, + (byte) 0x2E, (byte) 0x9C, (byte) 0x10, (byte) 0x1B, + (byte) 0x93, (byte) 0x97, (byte) 0x08, (byte) 0x00, + (byte) 0x2B, (byte) 0x2C, (byte) 0xF9, (byte) 0xAE}; + /** + * Description of the Field + */ public final static String UNDEFINED = "[undefined]"; - - private static SectionIDMap defaultMap; /** - *Returns the singleton instance of the default {@link - * SectionIDMap}.
+ *+ * + * Returns the singleton instance of the default {@link SectionIDMap}.
+ * + *@return The instance value */ - public static SectionIDMap getInstance() - { - if (defaultMap == null) - { + public static SectionIDMap getInstance() { + if (defaultMap == null) { final SectionIDMap m = new SectionIDMap(); m.put(SUMMARY_INFORMATION_ID, - PropertyIDMap.getSummaryInformationProperties()); + PropertyIDMap.getSummaryInformationProperties()); m.put(DOCUMENT_SUMMARY_INFORMATION_ID, - PropertyIDMap.getDocumentSummaryInformationProperties()); + PropertyIDMap.getDocumentSummaryInformationProperties()); defaultMap = m; } return defaultMap; @@ -127,32 +133,31 @@ public class SectionIDMap extends HashMap /** - *Returns the property ID string that is associated with a - * given property ID in a section format ID's namespace.
+ ** - * @param sectionFormatID Each section format ID has its own name - * space of property ID strings and thus must be specified. + * Returns the property ID string that is associated with a given property + * ID in a section format ID's namespace.
* - * @param pid The property ID - * - * @return The well-known property ID string associated with the - * property ID pid in the name space spanned by - * sectionFormatID. If the - * pid/sectionFormatID combination is not - * well-known, the string "[undefined]" is returned. + *@param sectionFormatID Each section format ID has its own name space of + * property ID strings and thus must be specified. + *@param pid The property ID + *@return The well-known property ID string associated with + * the property ID pid in the name space spanned by + * sectionFormatID . If the pid /sectionFormatID + * combination is not well-known, the string "[undefined]" is + * returned. */ public static String getPIDString(final byte[] sectionFormatID, - final int pid) - { + final int pid) { final PropertyIDMap m = - (PropertyIDMap) getInstance().get(sectionFormatID); - if (m == null) + (PropertyIDMap) getInstance().get(sectionFormatID); + if (m == null) { return UNDEFINED; - else - { + } else { final String s = (String) m.get(pid); - if (s == null) + if (s == null) { return UNDEFINED; + } return s; } } @@ -160,49 +165,57 @@ public class SectionIDMap extends HashMap /** - *Returns the {@link PropertyIDMap} for a given section format - * ID.
+ *+ * + * Returns the {@link PropertyIDMap} for a given section format ID.
+ * + *@param sectionFormatID Description of the Parameter + *@return Description of the Return Value */ - public PropertyIDMap get(final byte[] sectionFormatID) - { + public PropertyIDMap get(final byte[] sectionFormatID) { return (PropertyIDMap) super.get(new String(sectionFormatID)); } /** - *Returns the {@link PropertyIDMap} for a given section format - * ID.
+ ** - * @param sectionFormatID A section format ID as a - * byte[]. + * Returns the {@link PropertyIDMap} for a given section format ID.
* - * @deprecated Use {@link #get(byte[])} instead! + *@param sectionFormatID A section format ID as a byte[] . + *@return Description of the Return Value + *@deprecated Use {@link #get(byte[])} instead! */ - public Object get(final Object sectionFormatID) - { + public Object get(final Object sectionFormatID) { return get((byte[]) sectionFormatID); } /** - *Associates a section format ID with a {@link - * PropertyIDMap}.
+ *+ * + * Associates a section format ID with a {@link PropertyIDMap}.
+ * + *@param sectionFormatID Description of the Parameter + *@param propertyIDMap Description of the Parameter + *@return Description of the Return Value */ public Object put(final byte[] sectionFormatID, - final PropertyIDMap propertyIDMap) - { + final PropertyIDMap propertyIDMap) { return super.put(new String(sectionFormatID), propertyIDMap); } /** - * @deprecated Use {@link #put(byte[], PropertyIDMap)} instead! + *@param key Description of the Parameter + *@param value Description of the Parameter + *@return Description of the Return Value + *@deprecated Use {@link #put(byte[], PropertyIDMap)} instead! */ - public Object put(final Object key, final Object value) - { + public Object put(final Object key, final Object value) { return put((byte[]) key, (PropertyIDMap) value); }