Formatting fixed.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2003-02-01 13:28:28 +00:00
parent 747b6a0feb
commit 832c01ed6d
13 changed files with 690 additions and 953 deletions

View File

@ -55,54 +55,52 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>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.</p>
*
* 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.</p>
*
*@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;
/**
* <p>
*
* Creates a new {@link HPSFException}.</p>
* <p>Creates a new {@link HPSFException}.</p>
*/
public HPSFException() {
public HPSFException()
{
super();
}
/**
* <p>
* <p>Creates a new {@link HPSFException} with a message
* string.</p>
*
* Creates a new {@link HPSFException} with a message string.</p>
*
*@param msg Description of the Parameter
* @param msg The message string.
*/
public HPSFException(final String msg) {
public HPSFException(final String msg)
{
super(msg);
}
/**
* <p>
* <p>Creates a new {@link HPSFException} with a reason.</p>
*
* Creates a new {@link HPSFException} with a reason.</p>
*
*@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 {
/**
* <p>
* <p>Creates a new {@link HPSFException} with a message string
* and a reason.</p>
*
* Creates a new {@link HPSFException} with a message string and a reason.
* </p>
*
*@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 {
/**
* <p>
* <p>Returns the {@link Throwable} that caused this exception to
* be thrown or <code>null</code> if there was no such {@link
* Throwable}.</p>
*
* Returns the {@link Throwable} that caused this exception to be thrown or
* <code>null</code> if there was no such {@link Throwable}.</p>
*
*@return The reason value
* @return The reason
*/
public Throwable getReason() {
public Throwable getReason()
{
return reason;
}

View File

@ -55,55 +55,53 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>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.</p>
*
* 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.</p>
*
*@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;
/**
* <p>
*
* Creates a new {@link HPSFRuntimeException}.</p>
* <p>Creates a new {@link HPSFRuntimeException}.</p>
*/
public HPSFRuntimeException() {
public HPSFRuntimeException()
{
super();
}
/**
* <p>
* <p>Creates a new {@link HPSFRuntimeException} with a message
* string.</p>
*
* Creates a new {@link HPSFRuntimeException} with a message string.</p>
*
*@param msg Description of the Parameter
* @param msg The message string.
*/
public HPSFRuntimeException(final String msg) {
public HPSFRuntimeException(final String msg)
{
super(msg);
}
/**
* <p>
* <p>Creates a new {@link HPSFRuntimeException} with a
* reason.</p>
*
* Creates a new {@link HPSFRuntimeException} with a reason.</p>
*
*@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 {
/**
* <p>
* <p>Creates a new {@link HPSFRuntimeException} with a message
* string and a reason.</p>
*
* Creates a new {@link HPSFRuntimeException} with a message string and a
* reason.</p>
*
*@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 {
/**
* <p>
* <p>Returns the {@link Throwable} that caused this exception to
* be thrown or <code>null</code> if there was no such {@link
* Throwable}.</p>
*
* Returns the {@link Throwable} that caused this exception to be thrown or
* <code>null</code> if there was no such {@link Throwable}.</p>
*
*@return The reason value
* @return The reason
*/
public Throwable getReason() {
public Throwable getReason()
{
return reason;
}

View File

@ -55,73 +55,45 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>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 <code>-1 (true)</code> or <code>0 (false)</code>.
* Any other value would trigger this exception. It supports a nested
* "reason" throwable, i.e. an exception that caused this one to be
* thrown.</p>
*
* 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 <code>-1 (true)</code> or <code>0 (false)</code>.
* Any other value would trigger this exception. It supports a nested
* "reason" throwable, i.e. an exception that caused this one to be thrown.
* </p>
*
*@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
{
/**
* <p>
*
* Creates a new {@link IllegalPropertySetDataException}.</p>
*/
public IllegalPropertySetDataException() {
public IllegalPropertySetDataException()
{
super();
}
/**
* <p>
*
* Creates a new {@link IllegalPropertySetDataException} with a message string.</p>
*
*@param msg Description of the Parameter
*/
public IllegalPropertySetDataException(final String msg) {
public IllegalPropertySetDataException(final String msg)
{
super(msg);
}
/**
* <p>
*
* Creates a new {@link IllegalPropertySetDataException} with a reason.</p>
*
*@param reason Description of the Parameter
*/
public IllegalPropertySetDataException(final Throwable reason) {
public IllegalPropertySetDataException(final Throwable reason)
{
super(reason);
}
/**
* <p>
*
* Creates a new {@link IllegalPropertySetDataException} with a message
* string and a reason.</p>
*
*@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);
}
}

View File

@ -55,52 +55,36 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>This exception is thrown if an {@link java.io.InputStream} does
* not support the {@link java.io.InputStream#mark} operation.</p>
*
* This exception is thrown if an {@link java.io.InputStream} does not support
* the {@link java.io.InputStream#mark} operation.</p>
*
*@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);
}

View File

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

View File

@ -55,56 +55,41 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>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}.</p>
*
* 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}.</p> <p>
* <p>The constructors of this class are analogous to those of its
* superclass and documented there.</p>
*
* The constructors of this class are analogous to those of its superclass and
* documented there.</p>
*
*@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);
}

View File

@ -57,50 +57,45 @@ package org.apache.poi.hpsf;
import java.io.*;
/**
* <p>
* <p>Factory class to create instances of {@link SummaryInformation},
* {@link DocumentSummaryInformation} and {@link PropertySet}.</p>
*
* Factory class to create instances of {@link SummaryInformation}, {@link
* DocumentSummaryInformation} and {@link PropertySet}.</p>
*
*@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
{
/**
* <p>
* <p>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.</p>
*
* 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.</p>
*
*@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 <code>mark</code> 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;
}
}
}

View File

@ -58,147 +58,107 @@ import java.util.*;
import org.apache.poi.util.LittleEndian;
/**
* <p>
* <p>Abstract superclass for the convenience classes {@link
* SummaryInformation} and {@link DocumentSummaryInformation}.</p>
*
* Abstract superclass for the convenience classes {@link SummaryInformation}
* and {@link DocumentSummaryInformation}.</p> <p>
* <p>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.</p>
*
* 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.</p> <p>
* <p>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.</p>
*
* 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.</p>
*
*@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();
}

View File

@ -63,310 +63,301 @@ import java.util.*;
import org.apache.poi.hpsf.wellknown.*;
/**
* <p>
* <p>Convenience class representing a Summary Information stream in a
* Microsoft Office document.</p>
*
* Convenience class representing a Summary Information stream in a Microsoft
* Office document.</p> <p>
* <p>See <a
* href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp</a>
* for documentation from That Redmond Company.</p>
*
* See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp">
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp
* </a> 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
{
/**
* <p>
* <p>Creates a {@link SummaryInformation} from a given {@link
* PropertySet}.</p>
*
* Creates a {@link SummaryInformation} from a given {@link PropertySet}.
* </p>
*
*@param ps A property set which
* should be created from a summary information stream.
*@exception UnexpectedPropertySetTypeException Description of the
* Exception
*@throws UnexpectedPropertySetTypeException if <var>ps</var> does not
* contain a summary information stream.
* @param ps A property set which should be created from a summary
* information stream.
* @throws UnexpectedPropertySetTypeException if <var>ps</var>
* 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());
}
/**
* <p>
* <p>Returns the stream's title (or <code>null</code>).</p>
*
* Returns the stream's title (or <code>null</code>).</p>
*
*@return The title value
* @return The title or <code>null</code>
*/
public String getTitle() {
public String getTitle()
{
return (String) getProperty(PropertyIDMap.PID_TITLE);
}
/**
* <p>
* <p>Returns the stream's subject (or <code>null</code>).</p>
*
* Returns the stream's subject (or <code>null</code>).</p>
*
*@return The subject value
* @return The subject or <code>null</code>
*/
public String getSubject() {
public String getSubject()
{
return (String) getProperty(PropertyIDMap.PID_SUBJECT);
}
/**
* <p>
* <p>Returns the stream's author (or <code>null</code>).</p>
*
* Returns the stream's author (or <code>null</code>).</p>
*
*@return The author value
* @return The author or <code>null</code>
*/
public String getAuthor() {
public String getAuthor()
{
return (String) getProperty(PropertyIDMap.PID_AUTHOR);
}
/**
* <p>
* <p>Returns the stream's keywords (or <code>null</code>).</p>
*
* Returns the stream's keywords (or <code>null</code>).</p>
*
*@return The keywords value
* @return The keywords or <code>null</code>
*/
public String getKeywords() {
public String getKeywords()
{
return (String) getProperty(PropertyIDMap.PID_KEYWORDS);
}
/**
* <p>
* <p>Returns the stream's comments (or <code>null</code>).</p>
*
* Returns the stream's comments (or <code>null</code>).</p>
*
*@return The comments value
* @return The comments or <code>null</code>
*/
public String getComments() {
public String getComments()
{
return (String) getProperty(PropertyIDMap.PID_COMMENTS);
}
/**
* <p>
* <p>Returns the stream's template (or <code>null</code>).</p>
*
* Returns the stream's template (or <code>null</code>).</p>
*
*@return The template value
* @return The template or <code>null</code>
*/
public String getTemplate() {
public String getTemplate()
{
return (String) getProperty(PropertyIDMap.PID_TEMPLATE);
}
/**
* <p>
* <p>Returns the stream's last author (or <code>null</code>).</p>
*
* Returns the stream's last author (or <code>null</code>).</p>
*
*@return The lastAuthor value
* @return The last author or <code>null</code>
*/
public String getLastAuthor() {
public String getLastAuthor()
{
return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR);
}
/**
* <p>
* <p>Returns the stream's revision number (or
* <code>null</code>). </p>
*
* Returns the stream's revision number (or <code>null</code>). </p>
*
*@return The revNumber value
* @return The revision number or <code>null</code>
*/
public String getRevNumber() {
public String getRevNumber()
{
return (String) getProperty(PropertyIDMap.PID_REVNUMBER);
}
/**
* <p>
* <p>Returns the stream's edit time (or <code>null</code>).</p>
*
* Returns the stream's edit time (or <code>null</code>).</p>
*
*@return The editTime value
* @return The edit time or <code>null</code>
*/
public Date getEditTime() {
public Date getEditTime()
{
return (Date) getProperty(PropertyIDMap.PID_EDITTIME);
}
/**
* <p>
* <p>Returns the stream's last printed time (or
* <code>null</code>).</p>
*
* Returns the stream's last printed time (or <code>null</code>).</p>
*
*@return The lastPrinted value
* @return The last printed time or <code>null</code>
*/
public Date getLastPrinted() {
public Date getLastPrinted()
{
return (Date) getProperty(PropertyIDMap.PID_LASTPRINTED);
}
/**
* <p>
* <p>Returns the stream's creation time (or
* <code>null</code>).</p>
*
* Returns the stream's creation time (or <code>null</code>).</p>
*
*@return The createDateTime value
* @return The creation time or <code>null</code>
*/
public Date getCreateDateTime() {
public Date getCreateDateTime()
{
return (Date) getProperty(PropertyIDMap.PID_CREATE_DTM);
}
/**
* <p>
* <p>Returns the stream's last save time (or
* <code>null</code>).</p>
*
* Returns the stream's last save time (or <code>null</code>).</p>
*
*@return The lastSaveDateTime value
* @return The last save time or <code>null</code>
*/
public Date getLastSaveDateTime() {
public Date getLastSaveDateTime()
{
return (Date) getProperty(PropertyIDMap.PID_LASTSAVE_DTM);
}
/**
* <p>
* <p>Returns the stream's page count or 0 if the {@link
* SummaryInformation} does not contain a page count.</p>
*
* Returns the stream's page count or 0 if the {@link SummaryInformation}
* does not contain a page count.</p>
*
*@return The pageCount value
* @return The page count or <code>null</code>
*/
public int getPageCount() {
public int getPageCount()
{
return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT);
}
/**
* <p>
* <p>Returns the stream's word count or 0 if the {@link
* SummaryInformation} does not contain a word count.</p>
*
* Returns the stream's word count or 0 if the {@link SummaryInformation}
* does not contain a word count.</p>
*
*@return The wordCount value
* @return The word count or <code>null</code>
*/
public int getWordCount() {
public int getWordCount()
{
return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT);
}
/**
* <p>
* <p>Returns the stream's character count or 0 if the {@link
* SummaryInformation} does not contain a char count.</p>
*
* Returns the stream's char count or 0 if the {@link SummaryInformation}
* does not contain a char count.</p>
*
*@return The charCount value
* @return The character count or <code>null</code>
*/
public int getCharCount() {
public int getCharCount()
{
return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);
}
/**
* <p>
* <p>Returns the stream's thumbnail (or <code>null</code>)
* <strong>when this method is implemented. Please note that the
* return type is likely to change!</strong></p>
*
* Returns the stream's thumbnail (or <code>null</code>) <strong>when this
* method is implemented. Please note that the return type is likely to
* change!</strong> <p>
* <p><strong>FIXME / Hint to developers:</strong> Drew Varner
* &lt;Drew.Varner -at- sc.edu&gt; said that this is an image in
* WMF or Clipboard (BMP?) format. He also provided two links that
* might be helpful: <a
* href="http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch"
* target="_blank">http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch
* </a> and <a
* href="http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp"
* target="_blank">http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp
* </a>. However, we won't do any conversion into any image type
* but instead just return a byte array.</p>
*
* <strong>FIXME / Hint to developers:</strong> Drew Varner &lt;Drew.Varner
* -at- sc.edu&gt; said that this is an image in WMF or Clipboard (BMP?)
* format. He also provided two links that might be helpful: <a
* href="http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch"
* target="_blank">http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch
* </a> and <a href="http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp"
* target="_blank">http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp
* </a>. However, we won't do any conversion into any image type but
* instead just return a byte array.</p>
*
*@return The thumbnail value
* @return The thumbnail or <code>null</code>
*/
public byte[] getThumbnail() {
public byte[] getThumbnail()
{
return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL);
}
/**
* <p>
* <p>Returns the stream's application name (or
* <code>null</code>).</p>
*
* Returns the stream's application name (or <code>null</code>).</p>
*
*@return The applicationName value
* @return The application name or <code>null</code>
*/
public String getApplicationName() {
public String getApplicationName()
{
return (String) getProperty(PropertyIDMap.PID_APPNAME);
}
/**
* <p>
* <p>Returns a security code which is one of the following
* values:</p>
*
* Returns one of the following values:</p>
* <ul>
* <li> <p>
* <ul>
* <li>
* <p>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!</p>
* </li>
*
* 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!</p> </li>
* <li> <p>
* <li>
* <p>1 if the document is password protected</p>
* </li>
*
* 1 if the document is password protected</p> </li>
* <li> <p>
* <li>
* <p>2 if the document is read-only recommended</p>
* </li>
*
* 2 if the document is read-only recommended</p> </li>
* <li> <p>
* <li>
* <p>4 if the document is read-only enforced</p>
* </li>
*
* 4 if the document is read-only enforced</p> </li>
* <li> <p>
* <li>
* <p>8 if the document is locked for annotations</p>
* </li>
*
* 8 if the document is locked for annotations</p> </li>
* </ul>
* </ul>
*
*
*@return The security value
* @return The security code or <code>null</code>
*/
public int getSecurity() {
public int getSecurity()
{
return getPropertyIntValue(PropertyIDMap.PID_SECURITY);
}

View File

@ -56,306 +56,280 @@ package org.apache.poi.hpsf;
import org.apache.poi.util.LittleEndian;
/**
* <p>
* <p>Class to manipulate data in the Clipboard Variant ({@link
* Variant#VT_CF VT_CF}) format.</p>
*
* Class to manipulate data in the Clipboard Variant ({@link Variant#VT_CF
* VT_CF}) format.</p>
*
*@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
{
/**
* <p>
*
* Offset in bytes where the Clipboard Format Tag starts in the <code>byte[]</code>
* returned by {@link SummaryInformation#getThumbnail()}</p>
* <p>Offset in bytes where the Clipboard Format Tag starts in the
* <code>byte[]</code> returned by {@link
* SummaryInformation#getThumbnail()}</p>
*/
public static int OFFSET_CFTAG = 4;
/**
* <p>
* <p>Offset in bytes where the Clipboard Format starts in the
* <code>byte[]</code> returned by {@link
* SummaryInformation#getThumbnail()}</p>
*
* Offset in bytes where the Clipboard Format starts in the <code>byte[]</code>
* returned by {@link SummaryInformation#getThumbnail()}</p> <p>
*
* This is only valid if the Clipboard Format Tag is {@link #CFTAG_WINDOWS}
* </p>
* <p>This is only valid if the Clipboard Format Tag is {@link
* #CFTAG_WINDOWS}</p>
*/
public static int OFFSET_CF = 8;
/**
* <p>
* <p>Offset in bytes where the Windows Metafile (WMF) image data
* starts in the <code>byte[]</code> returned by {@link
* SummaryInformation#getThumbnail()}</p>
*
* Offset in bytes where the Windows Metafile (WMF) image data starts in
* the <code>byte[]</code> returned by {@link
* SummaryInformation#getThumbnail()}</p> <p>
* <p>There is only WMF data at this point in the
* <code>byte[]</code> if the Clipboard Format Tag is {@link
* #CFTAG_WINDOWS} and the Clipboard Format is {@link
* #CF_METAFILEPICT}.</p>
*
* There is only WMF data at this point in the <code>byte[]</code> if the
* Clipboard Format Tag is {@link #CFTAG_WINDOWS} and the Clipboard Format
* is {@link #CF_METAFILEPICT}.</p> <p>
*
* Note: The <code>byte[]</code> that starts at <code>OFFSET_WMFDATA</code>
* and ends at <code>getThumbnail().length - 1</code> forms a complete WMF
* image. It can be saved to disk with a <code>.wmf</code> file type and
* read using a WMF-capable image viewer.</p>
* <p>Note: The <code>byte[]</code> that starts at
* <code>OFFSET_WMFDATA</code> and ends at
* <code>getThumbnail().length - 1</code> forms a complete WMF
* image. It can be saved to disk with a <code>.wmf</code> file
* type and read using a WMF-capable image viewer.</p>
*/
public static int OFFSET_WMFDATA = 20;
/**
* <p>
* <p>Clipboard Format Tag - Windows clipboard format</p>
*
* Clipboard Format Tag - Windows clipboard format</p> <p>
* <p>A <code>DWORD</code> indicating a built-in Windows clipboard
* format value</p>
*
* A <code>DWORD</code> indicating a built-in Windows clipboard format
* value</p> <p>
*
* See: <a href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank"> http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp
* </a>
* <p>See: <a
* href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank">http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp</a>.</p>
*/
public static int CFTAG_WINDOWS = -1;
/**
* <p>
* <p>Clipboard Format Tag - Macintosh clipboard format</p>
*
* Clipboard Format Tag - Macintosh clipboard format</p> <p>
* <p>A <code>DWORD</code> indicating a Macintosh clipboard format
* value</p>
*
* A <code>DWORD</code> indicating a Macintosh clipboard format value</p>
* <p>
*
* See: <a href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank"> http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp
* </a>
* <p>See: <a
* href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank">http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp</a>.</p>
*/
public static int CFTAG_MACINTOSH = -2;
/**
* <p>
* <p>Clipboard Format Tag - Format ID</p>
*
* Clipboard Format Tag - Format ID</p> <p>
* <p>A GUID containing a format identifier (FMTID). This is
* rarely used.</p>
*
* A GUID containing a format identifier (FMTID). This is rarely used.</p>
* <p>
*
* See: <a href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank"> http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp
* </a>
* <p>See: <a
* href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank">http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp</a>.</p>
*/
public static int CFTAG_FMTID = -3;
/**
* <p>
* <p>Clipboard Format Tag - No Data</p>
*
* Clipboard Format Tag - No Data</p> <p>
* <p>A <code>DWORD</code> indicating No data. This is rarely
* used.</p>
*
* a <code>DWORD</code> indicating No data. This is rarely used.</p> <p>
*
* See: <a href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank"> http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp
* </a>
* <p>See: <a
* href="http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp"
* target="_blank">
* http://msdn.microsoft.com/library/en-us/dnolegen/html/msdn_propset.asp</a>.</p>
*/
public static int CFTAG_NODATA = 0;
/**
* <p>
* <p>Clipboard Format - Windows metafile format. This is the
* recommended way to store thumbnails in Property Streams.</p>
*
* Clipboard Format - Windows metafile format. This is the recommended way
* to store thumbnails in Property Streams.</p> <p>
*
* <strong>Note:</strong> this is not the same format used in regular WMF
* images. The clipboard version of this format has an extra
* clipboard-specific header</p>
* <p><strong>Note:</strong> This is not the same format used in
* regular WMF images. The clipboard version of this format has an
* extra clipboard-specific header.</p>
*/
public static int CF_METAFILEPICT = 3;
/**
* <p>
*
* Clipboard Format - Device Independent Bitmap</p>
* <p>Clipboard Format - Device Independent Bitmap</p>
*/
public static int CF_DIB = 8;
/**
* <p>
*
* Clipboard Format - Enhanced Windows metafile format</p>
* <p>Clipboard Format - Enhanced Windows metafile format</p>
*/
public static int CF_ENHMETAFILE = 14;
/**
* <p>
* <p>Clipboard Format - Bitmap</p>
*
* Clipboard Format - Bitmap</p> <p>
*
* Obsolete, See: <a href="msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp
* target="_blank"> msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp
* </a> </p>
* <p>Obsolete, see <a
* href="msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp
* target="_blank">msdn.microsoft.com/library/en-us/dnw98bk/html/clipboardoperations.asp</a>.</p>
*/
public static int CF_BITMAP = 2;
/**
* <p>
*
* A <code>byte[]</code> to hold a thumbnail image in ({@link Variant#VT_CF
* VT_CF}) format. </p>
* <p>A <code>byte[]</code> to hold a thumbnail image in ({@link
* Variant#VT_CF VT_CF}) format.</p>
*/
private byte[] thumbnailData = null;
/**
* <p>
*
* Default Constructor. If you use then one you'll have to add the
* thumbnail <code>byte[]</code> from {@link
* SummaryInformation#getThumbnail()} to do any useful manipulations,
* otherwise you'll get a <code>NullPointerException</code>.</p>
* <p>Default Constructor. If you use it then one you'll have to add
* the thumbnail <code>byte[]</code> from {@link
* SummaryInformation#getThumbnail()} to do any useful
* manipulations, otherwise you'll get a
* <code>NullPointerException</code>.</p>
*/
public Thumbnail() {
public Thumbnail()
{
super();
}
/**
* <p>
* <p>Creates a <code>Thumbnail</code> instance and initializes
* with the specified image bytes.</p>
*
* </p>
*
*@param thumbnailData Description of the Parameter
* @param thumbnailData The thumbnail data
*/
public Thumbnail(byte[] thumbnailData) {
public Thumbnail(byte[] thumbnailData)
{
this.thumbnailData = thumbnailData;
}
/**
* <p>
* <p>Returns the thumbnail as a <code>byte[]</code> in {@link
* Variant#VT_CF VT_CF} format.</p>
*
* Returns the thumbnail as a <code>byte[]</code> in {@link Variant#VT_CF
* VT_CF} format.</p>
*
*@return The thumbnail value
*@see SummaryInformation#getThumbnail()
* @return The thumbnail value
* @see SummaryInformation#getThumbnail()
*/
public byte[] getThumbnail() {
public byte[] getThumbnail()
{
return thumbnailData;
}
/**
* <p>
* <p>Sets the Thumbnail's underlying <code>byte[]</code> in
* {@link Variant#VT_CF VT_CF} format.</p>
*
* Sets the Thumbnail's underlying <code>byte[]</code> in {@link
* Variant#VT_CF VT_CF} format.</p>
*
*@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;
}
/**
* <p>
* <p>Returns an <code>int</code> representing the Clipboard
* Format Tag</p>
*
* Returns an <code>int</code> representing the Clipboard Format Tag</p>
* <p>
* <p>Possible return values are:</p>
* <ul>
* <li>{@link #CFTAG_WINDOWS CFTAG_WINDOWS}</li>
* <li>{@link #CFTAG_MACINTOSH CFTAG_MACINTOSH}</li>
* <li>{@link #CFTAG_FMTID CFTAG_FMTID}</li>
* <li>{@link #CFTAG_NODATA CFTAG_NODATA}</li>
* </ul>
*
* Possible return values are:
* <ul>
* <li> {@link #CFTAG_WINDOWS CFTAG_WINDOWS}</li>
* <li> {@link #CFTAG_MACINTOSH CFTAG_MACINTOSH}</li>
* <li> {@link #CFTAG_FMTID CFTAG_FMTID}</li>
* <li> {@link #CFTAG_NODATA CFTAG_NODATA}</li>
* </ul>
* </p>
*
*@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;
}
/**
* <p>
* <p>Returns an <code>int</code> representing the Clipboard
* Format</p>
*
* Returns an <code>int</code> representing the Clipboard Format</p> <p>
* <p>Will throw an exception if the Thumbnail's Clipboard Format
* Tag is not {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS}.</p>
*
* Will throw an exceptionif the Thumbnail's Clipboard Format Tag is not
* {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS} </p> <p>
* <p>Possible return values are:</p>
*
* Possible return values are:
* <ul>
* <li> {@link #CF_METAFILEPICT CF_METAFILEPICT}</li>
* <li> {@link #CF_DIB CF_DIB}</li>
* <li> {@link #CF_ENHMETAFILE CF_ENHMETAFILE}</li>
* <li> {@link #CF_BITMAP CF_BITMAP}</li>
* </ul>
* </p>
* <ul>
* <li>{@link #CF_METAFILEPICT CF_METAFILEPICT}</li>
* <li>{@link #CF_DIB CF_DIB}</li>
* <li>{@link #CF_ENHMETAFILE CF_ENHMETAFILE}</li>
* <li>{@link #CF_BITMAP CF_BITMAP}</li>
* </ul>
*
*@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);
}
/**
* <p>
* <p>Returns the Thumbnail as a <code>byte[]</code> 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}</p> <p>This
* <code>byte[]</code> is in the traditional WMF file, not the
* clipboard-specific version with special headers.</p>
*
* Returns the Thumbnail as a <code>byte[]</code> 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}</p>
* <p>
* <p>See <a href="http://www.wvware.com/caolan/ora-wmf.html"
* target="_blank">http://www.wvware.com/caolan/ora-wmf.html</a>
* for more information on the WMF image format.</p>
*
* This <code>byte[]</code> is in the traditional WMF file, not the
* clipboard-specific version with special headers.</p> <p>
*
* See <a href="http://www.wvware.com/caolan/ora-wmf.html" target="_blank">
* http://www.wvware.com/caolan/ora-wmf.html</a> for more information on
* the WMF image format.</p>
*
*@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;
}
}

View File

@ -55,57 +55,41 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>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.</p>
*
* 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.</p> <p>
* <p>The constructors of this class are analogous to those of its
* superclass and documented there.</p>
*
* The constructors of this class are analogous to those of its superclass and
* documented there.</p>
*
*@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);
}

View File

@ -57,111 +57,101 @@ package org.apache.poi.hpsf;
import java.util.*;
/**
* <p>
* <p>Provides various static utility methods.</p>
*
* Provides various static utility methods.</p>
*
*@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
{
/**
* <p>
* <p>Checks whether two byte arrays <var>a</var> and <var>b</var>
* are equal. They are equal</p>
*
* Checks whether two byte arrays <var>a</var> and <var>b</var> are equal.
* They are equal</p>
* <ul>
* <li> <p>
* <ul>
*
* if they have the same length and</p> </li>
* <li> <p>
* <li><p>if they have the same length and</p></li>
*
* if for each <var>i</var> with <var>i</var> &nbsp;&gt;=&nbsp;0 and
* <var>i</var> &nbsp;&lt;&nbsp;<var>a.length</var> holds <var>a</var> [
* <var>i</var> ]&nbsp;==&nbsp;<var>b</var> [<var>i</var> ].</p> </li>
* <li><p>if for each <var>i</var> with
* <var>i</var>&nbsp;&gt;=&nbsp;0 and
* <var>i</var>&nbsp;&lt;&nbsp;<var>a.length</var> holds
* <var>a</var>[<var>i</var>]&nbsp;==&nbsp;<var>b</var>[<var>i</var>].</p></li>
*
* </ul>
* </ul>
*
*
*@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 <code>true</code> if the byte arrays are equal, else
* <code>false</code>
*/
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;
}
/**
* <p>
* <p>Copies a part of a byte array into another byte array.</p>
*
* Copies a part of a byte array into another byte array.</p>
*
*@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];
}
}
/**
* <p>
* <p>Concatenates the contents of several byte arrays into a
* single one.</p>
*
* Concatenates the contents of several byte arrays into a single one.</p>
*
*@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;
}
/**
* <p>
* <p>Copies bytes from a source byte array into a new byte
* array.</p>
*
* Copies bytes from a source byte array into a new byte array.</p>
*
*@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 {
/**
* <p>
*
* 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? :-))</p>
* <p>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? :-))</p>
*/
public final static long EPOCH_DIFF = 11644473600000L;
/**
* <p>
* <p>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.</p>
*
* 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.</p>
*
*@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 {
}
}

View File

@ -55,388 +55,310 @@
package org.apache.poi.hpsf;
/**
* <p>
* <p>The <em>Variant</em> types as defined by Microsoft's COM. I
* found this information in <a
* href="http://www.marin.clara.net/COM/variant_type_definitions.htm">
* http://www.marin.clara.net/COM/variant_type_definitions.htm</a>.</p>
*
* The <em>Variant</em> types as defined by Microsoft's COM. I found this
* information in <a href="http://www.marin.clara.net/COM/variant_type_definitions.htm">
* http://www.marin.clara.net/COM/variant_type_definitions.htm</a> .</p> <p>
* <p>In the variant types descriptions the following shortcuts are
* used: <strong> [V]</strong> - may appear in a VARIANT,
* <strong>[T]</strong> - may appear in a TYPEDESC,
* <strong>[P]</strong> - may appear in an OLE property set,
* <strong>[S]</strong> - may appear in a Safe Array.</p>
*
* In the variant types descriptions the following shortcuts are used: <strong>
* [V]</strong> - may appear in a VARIANT, <strong>[T]</strong> - may appear in
* a TYPEDESC, <strong>[P]</strong> - may appear in an OLE property set,
* <strong>[S]</strong> - may appear in a Safe Array.</p>
*
*@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
{
/**
* <p>
*
* [V][P] Nothing.</p>
* <p>[V][P] Nothing.</p>
*/
public final static int VT_EMPTY = 0;
/**
* <p>
*
* [V][P] SQL style Null.</p>
* <p>[V][P] SQL style Null.</p>
*/
public final static int VT_NULL = 1;
/**
* <p>
*
* [V][T][P][S] 2 byte signed int.</p>
* <p>[V][T][P][S] 2 byte signed int.</p>
*/
public final static int VT_I2 = 2;
/**
* <p>
*
* [V][T][P][S] 4 byte signed int.</p>
* <p>[V][T][P][S] 4 byte signed int.</p>
*/
public final static int VT_I4 = 3;
/**
* <p>
*
* [V][T][P][S] 4 byte real.</p>
* <p>[V][T][P][S] 4 byte real.</p>
*/
public final static int VT_R4 = 4;
/**
* <p>
*
* [V][T][P][S] 8 byte real.</p>
* <p>[V][T][P][S] 8 byte real.</p>
*/
public final static int VT_R8 = 5;
/**
* <p>
*
* [V][T][P][S] currency. <span style="background-color: #ffff00">How long
* is this? How is it to be interpreted?</span> </p>
* <p>[V][T][P][S] currency. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_CY = 6;
/**
* <p>
*
* [V][T][P][S] date. <span style="background-color: #ffff00">How long is
* this? How is it to be interpreted?</span> </p>
* <p>[V][T][P][S] date. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_DATE = 7;
/**
* <p>
*
* [V][T][P][S] OLE Automation string. <span style="background-color:
* #ffff00">How long is this? How is it to be interpreted?</span> </p>
* <p>[V][T][P][S] OLE Automation string. <span
* style="background-color: #ffff00">How long is this? How is it
* to be interpreted?</span></p>
*/
public final static int VT_BSTR = 8;
/**
* <p>
*
* [V][T][P][S] IDispatch *. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span> </p>
* <p>[V][T][P][S] IDispatch *. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_DISPATCH = 9;
/**
* <p>
*
* [V][T][S] SCODE. <span style="background-color: #ffff00">How long is
* this? How is it to be interpreted?</span> </p>
* <p>[V][T][S] SCODE. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span></p>
*/
public final static int VT_ERROR = 10;
/**
* <p>
*
* [V][T][P][S] True=-1, False=0.</p>
* <p>[V][T][P][S] True=-1, False=0.</p>
*/
public final static int VT_BOOL = 11;
/**
* <p>
*
* [V][T][P][S] VARIANT *. <span style="background-color: #ffff00">How long
* is this? How is it to be interpreted?</span> </p>
* <p>[V][T][P][S] VARIANT *. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_VARIANT = 12;
/**
* <p>
*
* [V][T][S] IUnknown *. <span style="background-color: #ffff00">How long
* is this? How is it to be interpreted?</span> </p>
* <p>[V][T][S] IUnknown *. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_UNKNOWN = 13;
/**
* <p>
*
* [V][T][S] 16 byte fixed point.</p>
* <p>[V][T][S] 16 byte fixed point.</p>
*/
public final static int VT_DECIMAL = 14;
/**
* <p>
*
* [T] signed char.</p>
* <p>[T] signed char.</p>
*/
public final static int VT_I1 = 16;
/**
* <p>
*
* [V][T][P][S] unsigned char.</p>
* <p>[V][T][P][S] unsigned char.</p>
*/
public final static int VT_UI1 = 17;
/**
* <p>
*
* [T][P] unsigned short.</p>
* <p>[T][P] unsigned short.</p>
*/
public final static int VT_UI2 = 18;
/**
* <p>
*
* [T][P] unsigned int.</p>
* <p>[T][P] unsigned int.</p>
*/
public final static int VT_UI4 = 19;
/**
* <p>
*
* [T][P] signed 64-bit int.</p>
* <p>[T][P] signed 64-bit int.</p>
*/
public final static int VT_I8 = 20;
/**
* <p>
*
* [T][P] unsigned 64-bit int.</p>
* <p>[T][P] unsigned 64-bit int.</p>
*/
public final static int VT_UI8 = 21;
/**
* <p>
*
* [T] signed machine int.</p>
* <p>[T] signed machine int.</p>
*/
public final static int VT_INT = 22;
/**
* <p>
*
* [T] unsigned machine int.</p>
* <p>[T] unsigned machine int.</p>
*/
public final static int VT_UINT = 23;
/**
* <p>
*
* [T] C style void.</p>
* <p>[T] C style void.</p>
*/
public final static int VT_VOID = 24;
/**
* <p>
*
* [T] Standard return type. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span> </p>
* <p>[T] Standard return type. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_HRESULT = 25;
/**
* <p>
*
* [T] pointer type. <span style="background-color: #ffff00">How long is
* this? How is it to be interpreted?</span> </p>
* <p>[T] pointer type. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_PTR = 26;
/**
* <p>
*
* [T] (use VT_ARRAY in VARIANT).</p>
* <p>[T] (use VT_ARRAY in VARIANT).</p>
*/
public final static int VT_SAFEARRAY = 27;
/**
* <p>
*
* [T] C style array. <span style="background-color: #ffff00">How long is
* this? How is it to be interpreted?</span> </p>
* <p>[T] C style array. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_CARRAY = 28;
/**
* <p>
*
* [T] user defined type. <span style="background-color: #ffff00">How long
* is this? How is it to be interpreted?</span> </p>
* <p>[T] user defined type. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_USERDEFINED = 29;
/**
* <p>
*
* [T][P] null terminated string.</p>
* <p>[T][P] null terminated string.</p>
*/
public final static int VT_LPSTR = 30;
/**
* <p>
*
* [T][P] wide (Unicode) null terminated string.</p>
* <p>[T][P] wide (Unicode) null terminated string.</p>
*/
public final static int VT_LPWSTR = 31;
/**
* <p>
*
* [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>
* <p>[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>
*/
public final static int VT_FILETIME = 64;
/**
* <p>
*
* [P] Length prefixed bytes.</p>
* <p>[P] Length prefixed bytes.</p>
*/
public final static int VT_BLOB = 65;
/**
* <p>
*
* [P] Name of the stream follows.</p>
* <p>[P] Name of the stream follows.</p>
*/
public final static int VT_STREAM = 66;
/**
* <p>
*
* [P] Name of the storage follows.</p>
* <p>[P] Name of the storage follows.</p>
*/
public final static int VT_STORAGE = 67;
/**
* <p>
*
* [P] Stream contains an object. <span style="background-color: #ffff00">
* How long is this? How is it to be interpreted?</span> </p>
* <p>[P] Stream contains an object. <span
* style="background-color: #ffff00"> How long is this? How is it
* to be interpreted?</span></p>
*/
public final static int VT_STREAMED_OBJECT = 68;
/**
* <p>
*
* [P] Storage contains an object. <span style="background-color: #ffff00">
* How long is this? How is it to be interpreted?</span> </p>
* <p>[P] Storage contains an object. <span
* style="background-color: #ffff00"> How long is this? How is it
* to be interpreted?</span></p>
*/
public final static int VT_STORED_OBJECT = 69;
/**
* <p>
*
* [P] Blob contains an object. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span> </p>
* <p>[P] Blob contains an object. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_BLOB_OBJECT = 70;
/**
* <p>
*
* [P] Clipboard format. <span style="background-color: #ffff00">How long
* is this? How is it to be interpreted?</span> </p>
* <p>[P] Clipboard format. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_CF = 71;
/**
* <p>
* <p>[P] A Class ID.</p>
*
* [P] A Class ID.</p> <p>
* <p>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>
*
* 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> <p>
* <p>The valid Clipboard Format Tags are:</p>
*
* The valid Clipboard Format Tags are:
* <ul>
* <li> {@link Thumbnail#CFTAG_WINDOWS}</li>
* <li> {@link Thumbnail#CFTAG_MACINTOSH}</li>
* <li> {@link Thumbnail#CFTAG_NODATA}</li>
* <li> {@link Thumbnail#CFTAG_FMTID}</li>
* </ul>
* </p> <p>
* <ul>
* <li>{@link Thumbnail#CFTAG_WINDOWS}</li>
* <li>{@link Thumbnail#CFTAG_MACINTOSH}</li>
* <li>{@link Thumbnail#CFTAG_NODATA}</li>
* <li>{@link Thumbnail#CFTAG_FMTID}</li>
* </ul>
*
* <pre>typedef struct tagCLIPDATA {
* <pre>typedef struct tagCLIPDATA {
* // cbSize is the size of the buffer pointed to
* // by pClipData, plus sizeof(ulClipFmt)
* ULONG cbSize;
* long ulClipFmt;
* BYTE* pClipData;
* } CLIPDATA;</pre> See <a href="msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp"
* target="_blank"> msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp
* </a> </p>
* } CLIPDATA;</pre>
*
* <p>See <a
* href="msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp"
* target="_blank">
* msdn.microsoft.com/library/en-us/com/stgrstrc_0uwk.asp</a>.</p>
*/
public final static int VT_CLSID = 72;
/**
* <p>
*
* [P] simple counted array. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span> </p>
* <p>[P] simple counted array. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
public final static int VT_VECTOR = 0x1000;
/**
* <p>
*
* [V] SAFEARRAY*. <span style="background-color: #ffff00">How long is
* this? How is it to be interpreted?</span> </p>
* <p>[V] SAFEARRAY*. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span></p>
*/
public final static int VT_ARRAY = 0x2000;
/**
* <p>
*
* [V] void* for local use. <span style="background-color: #ffff00">How
* long is this? How is it to be interpreted?</span> </p>
* <p>[V] void* for local use. <span style="background-color:
* #ffff00">How long is this? How is it to be
* interpreted?</span></p>
*/
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;
}