diff --git a/src/java/org/apache/poi/hpsf/HPSFException.java b/src/java/org/apache/poi/hpsf/HPSFException.java index 118eb274f9..7358f0365a 100644 --- a/src/java/org/apache/poi/hpsf/HPSFException.java +++ b/src/java/org/apache/poi/hpsf/HPSFException.java @@ -55,54 +55,52 @@ package org.apache.poi.hpsf; /** - *

+ *

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.

- * - *@author Rainer Klute (klute@rainer-klute.de) - *@version $Id$ - *@since 2002-02-09 + * @author Rainer Klute (klute@rainer-klute.de) + * @version $Id$ + * @since 2002-02-09 */ -public class HPSFException extends Exception { +public class HPSFException extends Exception +{ private Throwable reason; /** - *

- * - * Creates a new {@link HPSFException}.

+ *

Creates a new {@link HPSFException}.

*/ - public HPSFException() { + public HPSFException() + { super(); } /** - *

+ *

Creates a new {@link HPSFException} with a message + * string.

* - * Creates a new {@link HPSFException} with a message string.

- * - *@param msg Description of the Parameter + * @param msg The message string. */ - public HPSFException(final String msg) { + public HPSFException(final String msg) + { super(msg); } /** - *

+ *

Creates a new {@link HPSFException} with a reason.

* - * Creates a new {@link HPSFException} with a reason.

- * - *@param reason Description of the Parameter + * @param reason The reason, i.e. a throwable that indirectly + * caused this exception. */ - public HPSFException(final Throwable reason) { + public HPSFException(final Throwable reason) + { super(); this.reason = reason; } @@ -110,15 +108,15 @@ public class HPSFException extends Exception { /** - *

+ *

Creates a new {@link HPSFException} with a message string + * and a reason.

* - * Creates a new {@link HPSFException} with a message string and a reason. - *

- * - *@param msg Description of the Parameter - *@param reason Description of the Parameter + * @param msg The message string. + * @param reason The reason, i.e. a throwable that indirectly + * caused this exception. */ - public HPSFException(final String msg, final Throwable reason) { + public HPSFException(final String msg, final Throwable reason) + { super(msg); this.reason = reason; } @@ -126,14 +124,14 @@ public class HPSFException extends Exception { /** - *

+ *

Returns the {@link Throwable} that caused this exception to + * be thrown or null if there was no such {@link + * Throwable}.

* - * Returns the {@link Throwable} that caused this exception to be thrown or - * null if there was no such {@link Throwable}.

- * - *@return The reason value + * @return The reason */ - public Throwable getReason() { + public Throwable getReason() + { return reason; } diff --git a/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java b/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java index d493521e7c..7fb09274fb 100644 --- a/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java +++ b/src/java/org/apache/poi/hpsf/HPSFRuntimeException.java @@ -55,55 +55,53 @@ package org.apache.poi.hpsf; /** - *

+ *

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.

- * - *@author Rainer Klute (klute@rainer-klute.de) - *@version $Id: HPSFRuntimeException.java,v 1.3 2002/05/01 09:31:52 klute Exp - * $ - *@since 2002-02-09 + * @author Rainer Klute (klute@rainer-klute.de) + * @version $Id$ + * @since 2002-02-09 */ -public class HPSFRuntimeException extends RuntimeException { +public class HPSFRuntimeException extends RuntimeException +{ private Throwable reason; /** - *

- * - * Creates a new {@link HPSFRuntimeException}.

+ *

Creates a new {@link HPSFRuntimeException}.

*/ - public HPSFRuntimeException() { + public HPSFRuntimeException() + { super(); } /** - *

+ *

Creates a new {@link HPSFRuntimeException} with a message + * string.

* - * Creates a new {@link HPSFRuntimeException} with a message string.

- * - *@param msg Description of the Parameter + * @param msg The message string. */ - public HPSFRuntimeException(final String msg) { + public HPSFRuntimeException(final String msg) + { super(msg); } /** - *

+ *

Creates a new {@link HPSFRuntimeException} with a + * reason.

* - * Creates a new {@link HPSFRuntimeException} with a reason.

- * - *@param reason Description of the Parameter + * @param reason The reason, i.e. a throwable that indirectly + * caused this exception. */ - public HPSFRuntimeException(final Throwable reason) { + public HPSFRuntimeException(final Throwable reason) + { super(); this.reason = reason; } @@ -111,15 +109,15 @@ public class HPSFRuntimeException extends RuntimeException { /** - *

+ *

Creates a new {@link HPSFRuntimeException} with a message + * string and a reason.

* - * Creates a new {@link HPSFRuntimeException} with a message string and a - * reason.

- * - *@param msg Description of the Parameter - *@param reason Description of the Parameter + * @param msg The message string. + * @param reason The reason, i.e. a throwable that indirectly + * caused this exception. */ - public HPSFRuntimeException(final String msg, final Throwable reason) { + public HPSFRuntimeException(final String msg, final Throwable reason) + { super(msg); this.reason = reason; } @@ -127,14 +125,14 @@ public class HPSFRuntimeException extends RuntimeException { /** - *

+ *

Returns the {@link Throwable} that caused this exception to + * be thrown or null if there was no such {@link + * Throwable}.

* - * Returns the {@link Throwable} that caused this exception to be thrown or - * null if there was no such {@link Throwable}.

- * - *@return The reason value + * @return The reason */ - public Throwable getReason() { + public Throwable getReason() + { return reason; } diff --git a/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java b/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java index 66af96cbd5..25764df390 100644 --- a/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java +++ b/src/java/org/apache/poi/hpsf/IllegalPropertySetDataException.java @@ -55,73 +55,45 @@ package org.apache.poi.hpsf; /** - *

+ *

This exception is thrown when there is an illegal value set in a + * {@link PropertySet}. For example, a {@link Variant#VT_BOOL} must + * have a value of -1 (true) or 0 (false). + * Any other value would trigger this exception. It supports a nested + * "reason" throwable, i.e. an exception that caused this one to be + * thrown.

* - * This exception is thrown when there is an illegal value set in a - * {@link PropertySet}. For example, a {@link Variant#VT_BOOL} must have - * a value of -1 (true) or 0 (false). - * Any other value would trigger this exception. It supports a nested - * "reason" throwable, i.e. an exception that caused this one to be thrown. - *

- * - *@author Drew Varner(Drew.Varner atDomain sc.edu) - *@version $Id$ - *@since 2002-05-26 + * @author Drew Varner(Drew.Varner atDomain sc.edu) + * @version $Id$ + * @since 2002-05-26 */ -public class IllegalPropertySetDataException extends HPSFRuntimeException { +public class IllegalPropertySetDataException extends HPSFRuntimeException +{ - - - /** - *

- * - * Creates a new {@link IllegalPropertySetDataException}.

- */ - public IllegalPropertySetDataException() { + public IllegalPropertySetDataException() + { super(); } - /** - *

- * - * Creates a new {@link IllegalPropertySetDataException} with a message string.

- * - *@param msg Description of the Parameter - */ - public IllegalPropertySetDataException(final String msg) { + public IllegalPropertySetDataException(final String msg) + { super(msg); } - /** - *

- * - * Creates a new {@link IllegalPropertySetDataException} with a reason.

- * - *@param reason Description of the Parameter - */ - public IllegalPropertySetDataException(final Throwable reason) { + public IllegalPropertySetDataException(final Throwable reason) + { super(reason); } - /** - *

- * - * Creates a new {@link IllegalPropertySetDataException} with a message - * string and a reason.

- * - *@param msg Description of the Parameter - *@param reason Description of the Parameter - */ public IllegalPropertySetDataException(final String msg, - final Throwable reason) { + final Throwable reason) + { super(msg,reason); } - } diff --git a/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java b/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java index 42605e6f82..820243075b 100644 --- a/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java +++ b/src/java/org/apache/poi/hpsf/MarkUnsupportedException.java @@ -55,52 +55,36 @@ package org.apache.poi.hpsf; /** - *

+ *

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.

- * - *@author Rainer Klute (klute@rainer-klute.de) - *@version $Id$ - *@since 2002-02-09 + * @author Rainer Klute (klute@rainer-klute.de) + * @version $Id$ + * @since 2002-02-09 */ -public class MarkUnsupportedException extends HPSFException { +public class MarkUnsupportedException extends HPSFException +{ - /** - * Constructor for the MarkUnsupportedException object - */ - public MarkUnsupportedException() { + public MarkUnsupportedException() + { super(); } - /** - * Constructor for the MarkUnsupportedException object - * - *@param msg Description of the Parameter - */ - public MarkUnsupportedException(final String msg) { + public MarkUnsupportedException(final String msg) + { super(msg); } - /** - * Constructor for the MarkUnsupportedException object - * - *@param reason Description of the Parameter - */ - public MarkUnsupportedException(final Throwable reason) { + public MarkUnsupportedException(final Throwable reason) + { super(reason); } - /** - * Constructor for the MarkUnsupportedException object - * - *@param msg Description of the Parameter - *@param reason Description of the Parameter - */ - public MarkUnsupportedException(final String msg, final Throwable reason) { + public MarkUnsupportedException(final String msg, final Throwable reason) + { super(msg, reason); } diff --git a/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java b/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java index 0e3c0f4dc7..1fc2c50ca5 100644 --- a/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java +++ b/src/java/org/apache/poi/hpsf/NoPropertySetStreamException.java @@ -68,44 +68,30 @@ package org.apache.poi.hpsf; *@version $Id$ *@since 2002-02-09 */ -public class NoPropertySetStreamException extends HPSFException { +public class NoPropertySetStreamException extends HPSFException +{ - /** - * Constructor for the NoPropertySetStreamException object - */ - public NoPropertySetStreamException() { + public NoPropertySetStreamException() + { super(); } - /** - * Constructor for the NoPropertySetStreamException object - * - *@param msg Description of the Parameter - */ - public NoPropertySetStreamException(final String msg) { + public NoPropertySetStreamException(final String msg) + { super(msg); } - /** - * Constructor for the NoPropertySetStreamException object - * - *@param reason Description of the Parameter - */ - public NoPropertySetStreamException(final Throwable reason) { + public NoPropertySetStreamException(final Throwable reason) + { super(reason); } - /** - * Constructor for the NoPropertySetStreamException object - * - *@param msg Description of the Parameter - *@param reason Description of the Parameter - */ public NoPropertySetStreamException(final String msg, - final Throwable reason) { + final Throwable reason) + { super(msg, reason); } diff --git a/src/java/org/apache/poi/hpsf/NoSingleSectionException.java b/src/java/org/apache/poi/hpsf/NoSingleSectionException.java index 2153635e8c..da9e2fd8db 100644 --- a/src/java/org/apache/poi/hpsf/NoSingleSectionException.java +++ b/src/java/org/apache/poi/hpsf/NoSingleSectionException.java @@ -55,56 +55,41 @@ package org.apache.poi.hpsf; /** - *

+ *

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) + * @version $Id$ + * @since 2002-02-09 */ -public class NoSingleSectionException extends HPSFRuntimeException { +public class NoSingleSectionException extends HPSFRuntimeException +{ - /** - * Constructor for the NoSingleSectionException object - */ - public NoSingleSectionException() { + public NoSingleSectionException() + { super(); } - /** - * Constructor for the NoSingleSectionException object - * - *@param msg Description of the Parameter - */ - public NoSingleSectionException(final String msg) { + public NoSingleSectionException(final String msg) + { super(msg); } - /** - * Constructor for the NoSingleSectionException object - * - *@param reason Description of the Parameter - */ - public NoSingleSectionException(final Throwable reason) { + public NoSingleSectionException(final Throwable reason) + { super(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) { + public NoSingleSectionException(final String msg, final Throwable reason) + { super(msg, reason); } diff --git a/src/java/org/apache/poi/hpsf/PropertySetFactory.java b/src/java/org/apache/poi/hpsf/PropertySetFactory.java index a18c99ee9e..ebd094a155 100644 --- a/src/java/org/apache/poi/hpsf/PropertySetFactory.java +++ b/src/java/org/apache/poi/hpsf/PropertySetFactory.java @@ -57,50 +57,45 @@ package org.apache.poi.hpsf; import java.io.*; /** - *

+ *

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) + * @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. - *@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 + * @param stream Contains the property set stream's data. + * @return The created {@link PropertySet}. + * @throws NoPropertySetStreamException if the stream does not + * contain a property set. + * @throws MarkUnsupportedException if the stream does not support + * the mark operation. + * @throws UnexpectedPropertySetTypeException if the property + * set's type is unexpected. + * @throws IOException if some I/O problem occurs. */ 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/SpecialPropertySet.java b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java index b8dc152470..f9cddd819a 100644 --- a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java +++ b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java @@ -58,147 +58,107 @@ import java.util.*; import org.apache.poi.util.LittleEndian; /** - *

+ *

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) + * @version $Id$ + * @since 2002-02-09 */ -public abstract class SpecialPropertySet extends PropertySet { +public abstract class SpecialPropertySet extends PropertySet +{ private PropertySet delegate; - /** - * Constructor for the SpecialPropertySet object - * - *@param ps Description of the Parameter - */ - public SpecialPropertySet(PropertySet ps) { + public SpecialPropertySet(PropertySet ps) + { delegate = ps; } - /** - * Gets the byteOrder attribute of the SpecialPropertySet object - * - *@return The byteOrder value - */ - public int getByteOrder() { + public int getByteOrder() + { return delegate.getByteOrder(); } - /** - * Gets the format attribute of the SpecialPropertySet object - * - *@return The format value - */ - public int getFormat() { + public int getFormat() + { return delegate.getFormat(); } - /** - * Gets the oSVersion attribute of the SpecialPropertySet object - * - *@return The oSVersion value - */ - public long getOSVersion() { + public long getOSVersion() + { return delegate.getOSVersion(); } - /** - * Gets the classID attribute of the SpecialPropertySet object - * - *@return The classID value - */ - public ClassID getClassID() { + public ClassID getClassID() + { return delegate.getClassID(); } - /** - * Gets the sectionCount attribute of the SpecialPropertySet object - * - *@return The sectionCount value - */ - public long getSectionCount() { + public long getSectionCount() + { return delegate.getSectionCount(); } - /** - * Gets the sections attribute of the SpecialPropertySet object - * - *@return The sections value - */ - public List getSections() { + public List getSections() + { return delegate.getSections(); } - /** - * Gets the summaryInformation attribute of the SpecialPropertySet object - * - *@return The summaryInformation value - */ - public boolean isSummaryInformation() { + public boolean isSummaryInformation() + { return delegate.isSummaryInformation(); } - /** - * Gets the documentSummaryInformation attribute of the SpecialPropertySet - * object - * - *@return The documentSummaryInformation value - */ - public boolean isDocumentSummaryInformation() { + public boolean isDocumentSummaryInformation() + { return delegate.isDocumentSummaryInformation(); } - /** - * Gets the singleSection attribute of the SpecialPropertySet object - * - *@return The singleSection value - */ - public Section getSingleSection() { + 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 ecdd633bd7..1fc4ef168b 100644 --- a/src/java/org/apache/poi/hpsf/SummaryInformation.java +++ b/src/java/org/apache/poi/hpsf/SummaryInformation.java @@ -63,310 +63,301 @@ import java.util.*; import org.apache.poi.hpsf.wellknown.*; /** - *

+ *

Convenience class representing a Summary Information stream in a + * Microsoft Office document.

* - * 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.

* - * 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) - *@see DocumentSummaryInformation - *@version $Id$ - *@since 2002-02-09 + * @author Rainer Klute (klute@rainer-klute.de) + * @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}.

* - * Creates a {@link SummaryInformation} from a given {@link PropertySet}. - *

- * - *@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. + * @param ps A property set which should be created from a summary + * information stream. + * @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).

- * - *@return The title value + * @return The title or null */ - public String getTitle() { + public String getTitle() + { return (String) getProperty(PropertyIDMap.PID_TITLE); } /** - *

+ *

Returns the stream's subject (or null).

* - * Returns the stream's subject (or null).

- * - *@return The subject value + * @return The subject or null */ - public String getSubject() { + public String getSubject() + { return (String) getProperty(PropertyIDMap.PID_SUBJECT); } /** - *

+ *

Returns the stream's author (or null).

* - * Returns the stream's author (or null).

- * - *@return The author value + * @return The author or null */ - public String getAuthor() { + public String getAuthor() + { return (String) getProperty(PropertyIDMap.PID_AUTHOR); } /** - *

+ *

Returns the stream's keywords (or null).

* - * Returns the stream's keywords (or null).

- * - *@return The keywords value + * @return The keywords or null */ - public String getKeywords() { + public String getKeywords() + { return (String) getProperty(PropertyIDMap.PID_KEYWORDS); } /** - *

+ *

Returns the stream's comments (or null).

* - * Returns the stream's comments (or null).

- * - *@return The comments value + * @return The comments or null */ - public String getComments() { + public String getComments() + { return (String) getProperty(PropertyIDMap.PID_COMMENTS); } /** - *

+ *

Returns the stream's template (or null).

* - * Returns the stream's template (or null).

- * - *@return The template value + * @return The template or null */ - public String getTemplate() { + public String getTemplate() + { return (String) getProperty(PropertyIDMap.PID_TEMPLATE); } /** - *

+ *

Returns the stream's last author (or null).

* - * Returns the stream's last author (or null).

- * - *@return The lastAuthor value + * @return The last author or null */ - public String getLastAuthor() { + public String getLastAuthor() + { return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR); } /** - *

+ *

Returns the stream's revision number (or + * null).

* - * Returns the stream's revision number (or null).

- * - *@return The revNumber value + * @return The revision number or null */ - public String getRevNumber() { + public String getRevNumber() + { return (String) getProperty(PropertyIDMap.PID_REVNUMBER); } /** - *

+ *

Returns the stream's edit time (or null).

* - * Returns the stream's edit time (or null).

- * - *@return The editTime value + * @return The edit time or null */ - public Date getEditTime() { + public Date getEditTime() + { return (Date) getProperty(PropertyIDMap.PID_EDITTIME); } /** - *

+ *

Returns the stream's last printed time (or + * null).

* - * Returns the stream's last printed time (or null).

- * - *@return The lastPrinted value + * @return The last printed time or null */ - public Date getLastPrinted() { + public Date getLastPrinted() + { return (Date) getProperty(PropertyIDMap.PID_LASTPRINTED); } /** - *

+ *

Returns the stream's creation time (or + * null).

* - * Returns the stream's creation time (or null).

- * - *@return The createDateTime value + * @return The creation time or null */ - public Date getCreateDateTime() { + public Date getCreateDateTime() + { return (Date) getProperty(PropertyIDMap.PID_CREATE_DTM); } /** - *

+ *

Returns the stream's last save time (or + * null).

* - * Returns the stream's last save time (or null).

- * - *@return The lastSaveDateTime value + * @return The last save time or null */ - public Date getLastSaveDateTime() { + public Date getLastSaveDateTime() + { return (Date) getProperty(PropertyIDMap.PID_LASTSAVE_DTM); } /** - *

+ *

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 + * @return The page count or null */ - 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 + * @return The word count or null */ - public int getWordCount() { + public int getWordCount() + { return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT); } /** - *

+ *

Returns the stream's character 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 + * @return The character count or null */ - 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!

* - * 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.

* - * 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 + * @return The thumbnail or null */ - 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).

- * - *@return The applicationName value + * @return The application name or null */ - public String getApplicationName() { + public String getApplicationName() + { return (String) getProperty(PropertyIDMap.PID_APPNAME); } /** - *

+ *

Returns a security code which is one of the following + * values:

* - * Returns one of the following values:

- * * - * - *@return The security value + * @return The security code or null */ - public int getSecurity() { + public int getSecurity() + { return getPropertyIntValue(PropertyIDMap.PID_SECURITY); } diff --git a/src/java/org/apache/poi/hpsf/Thumbnail.java b/src/java/org/apache/poi/hpsf/Thumbnail.java index 4455caab3f..0371138500 100644 --- a/src/java/org/apache/poi/hpsf/Thumbnail.java +++ b/src/java/org/apache/poi/hpsf/Thumbnail.java @@ -56,306 +56,280 @@ package org.apache.poi.hpsf; import org.apache.poi.util.LittleEndian; /** - *

+ *

Class to manipulate data in the Clipboard Variant ({@link + * Variant#VT_CF VT_CF}) format.

* - * Class to manipulate data in the Clipboard Variant ({@link Variant#VT_CF - * VT_CF}) format.

- * - *@author Drew Varner (Drew.Varner inOrAround sc.edu) - *@see SummaryInformation#getThumbnail() - *@version $Id$ - *@since 2002-04-29 + * @author Drew Varner (Drew.Varner inOrAround sc.edu) + * @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()}

*/ public static int OFFSET_CFTAG = 4; /** - *

+ *

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()}

* - * 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}.

* - * 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.

+ *

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.

*/ public static int OFFSET_WMFDATA = 20; /** - *

+ *

Clipboard Format Tag - Windows clipboard format

* - * Clipboard Format Tag - Windows clipboard format

+ *

A DWORD indicating a built-in Windows clipboard + * format value

* - * A DWORD indicating a built-in Windows 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_WINDOWS = -1; /** - *

+ *

Clipboard Format Tag - Macintosh clipboard format

* - * Clipboard Format Tag - Macintosh clipboard format

+ *

A DWORD indicating a Macintosh clipboard format + * value

* - * 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

* - * Clipboard Format Tag - Format ID

+ *

A GUID containing a format identifier (FMTID). This is + * rarely used.

* - * 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

* - * Clipboard Format Tag - No Data

+ *

A DWORD indicating No data. This is rarely + * used.

* - * a DWORD indicating No data. 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_NODATA = 0; /** - *

+ *

Clipboard Format - Windows metafile format. This is the + * recommended way to store thumbnails in Property Streams.

* - * 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

+ *

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

* - * Clipboard Format - Bitmap

- * - * Obsolete, See: msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp - *

+ *

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.

*/ private byte[] thumbnailData = null; /** - *

- * - * 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 it 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.

*/ - public Thumbnail() { + public Thumbnail() + { super(); } /** - *

+ *

Creates a Thumbnail instance and initializes + * with the specified image bytes.

* - *

- * - *@param thumbnailData Description of the Parameter + * @param thumbnailData The thumbnail data */ - 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.

* - * Returns the thumbnail as a byte[] in {@link Variant#VT_CF - * VT_CF} format.

- * - *@return The thumbnail value - *@see SummaryInformation#getThumbnail() + * @return The thumbnail value + * @see SummaryInformation#getThumbnail() */ - public byte[] getThumbnail() { + public byte[] getThumbnail() + { return thumbnailData; } /** - *

+ *

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.

- * - *@param thumbnail The new thumbnail value - *@see SummaryInformation#getThumbnail() + * @param thumbnail The new thumbnail value + * @see SummaryInformation#getThumbnail() */ - public void setThumbnail(byte[] thumbnail) { + public void setThumbnail(byte[] thumbnail) + { this.thumbnailData = thumbnail; } /** - *

+ *

Returns an int representing the Clipboard + * Format Tag

* - * Returns an int representing the Clipboard Format Tag

- *

+ *

Possible return values are:

+ * * - * Possible return values are: - * - *

- * - *@return a flag indicating the Clipboard Format Tag + * @return A flag indicating the Clipboard Format Tag */ - public long getClipboardFormatTag() { - long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(), OFFSET_CFTAG); + public long getClipboardFormatTag() + { + long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(), + OFFSET_CFTAG); return clipboardFormatTag; } /** - *

+ *

Returns an int representing the Clipboard + * Format

* - * Returns an int representing the Clipboard Format

+ *

Will throw an exception if the Thumbnail's Clipboard Format + * Tag is not {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS}.

* - * Will throw an exceptionif the Thumbnail's Clipboard Format Tag is not - * {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS}

+ *

Possible return values are:

* - * Possible return values are: - * - *

+ * * - *@return a flag indicating the Clipboard Format - *@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS + * @return a flag indicating the Clipboard Format + * @throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS */ - public long getClipboardFormat() throws HPSFException { - if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) { + public long getClipboardFormat() throws HPSFException + { + if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) throw new HPSFException("Clipboard Format Tag of Thumbnail must " + - "be CFTAG_WINDOWS."); - } + "be CFTAG_WINDOWS."); - long clipboardFormat = LittleEndian.getUInt(getThumbnail(), OFFSET_CF); - return clipboardFormat; + return LittleEndian.getUInt(getThumbnail(), OFFSET_CF); } /** - *

+ *

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.

* - * 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}

- *

+ *

See http://www.wvware.com/caolan/ora-wmf.html + * for more information on the WMF image format.

* - * This byte[] is in the traditional WMF file, not the - * clipboard-specific version with special headers.

- * - * See - * http://www.wvware.com/caolan/ora-wmf.html for more information on - * the WMF image format.

- * - *@return a WMF image of the Thumbnail - *@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS and - * CF_METAFILEPICT + * @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."); - } - if (!(getClipboardFormat() == CF_METAFILEPICT)) { + "be CFTAG_WINDOWS."); + 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 d9c299e7f4..83779fe7a4 100644 --- a/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java +++ b/src/java/org/apache/poi/hpsf/UnexpectedPropertySetTypeException.java @@ -55,57 +55,41 @@ package org.apache.poi.hpsf; /** - *

+ *

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) + * @version $Id$ + * @since 2002-02-09 */ -public class UnexpectedPropertySetTypeException extends HPSFException { +public class UnexpectedPropertySetTypeException extends HPSFException +{ - /** - * Constructor for the UnexpectedPropertySetTypeException object - */ - public UnexpectedPropertySetTypeException() { + public UnexpectedPropertySetTypeException() + { super(); } - /** - * Constructor for the UnexpectedPropertySetTypeException object - * - *@param msg Description of the Parameter - */ - public UnexpectedPropertySetTypeException(final String msg) { + public UnexpectedPropertySetTypeException(final String msg) + { super(msg); } - /** - * Constructor for the UnexpectedPropertySetTypeException object - * - *@param reason Description of the Parameter - */ - public UnexpectedPropertySetTypeException(final Throwable reason) { + 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 4c5e3bf546..1ff9b5a524 100644 --- a/src/java/org/apache/poi/hpsf/Util.java +++ b/src/java/org/apache/poi/hpsf/Util.java @@ -57,111 +57,101 @@ package org.apache.poi.hpsf; import java.util.*; /** - *

+ *

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) + * @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

- * * - * - *@param a Description of the Parameter - *@param b Description of the Parameter - *@return Description of the Return Value + * @param a The first byte array + * @param b The first byte array + * @return true if the byte arrays are equal, else + * false */ - public static boolean equal(final byte[] a, final byte[] b) { - if (a.length != b.length) { + public static boolean equal(final byte[] a, final byte[] b) + { + if (a.length != b.length) return false; - } - for (int i = 0; i < a.length; i++) { - if (a[i] != b[i]) { + for (int i = 0; i < a.length; i++) + if (a[i] != b[i]) return false; - } - } - return true; + return true; } /** - *

+ *

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 + * @param src The source byte array. + * @param srcOffset Offset in the source byte array. + * @param length The number of bytes to copy. + * @param dst The destination byte array. + * @param dstOffset Offset in the destination byte array. */ 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.

* - * Concatenates the contents of several byte arrays into a single one.

- * - *@param byteArrays The byte arrays to be concatened. - *@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]; + 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.

* - * Copies bytes from a source byte array into a new byte array.

- * - *@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. + * @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; @@ -170,31 +160,30 @@ 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.

* - * 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. - *@param low The lower double word of the FILETIME structure. - *@return Description of the Return Value + * @param high The higher double word of the FILETIME structure. + * @param low The lower double word of the FILETIME structure. + * @return The Windows FILETIME as a {@link Date}. */ - 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; @@ -202,4 +191,3 @@ public class Util { } } - diff --git a/src/java/org/apache/poi/hpsf/Variant.java b/src/java/org/apache/poi/hpsf/Variant.java index d0fd5104aa..f49ce4a2e4 100644 --- a/src/java/org/apache/poi/hpsf/Variant.java +++ b/src/java/org/apache/poi/hpsf/Variant.java @@ -55,388 +55,310 @@ package org.apache.poi.hpsf; /** - *

+ *

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) + * @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.

* - * [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.

* - * 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.

+ *

The valid Clipboard Format Tags are:

* - * The valid Clipboard Format Tags are: - * - *

+ *

* - *
typedef struct  tagCLIPDATA {
+     * 
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; }