PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-05-11 14:47:24 +00:00
parent 56015327fe
commit 46a9bd9bff
18 changed files with 2895 additions and 2248 deletions

View File

@ -1,57 +1,57 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import java.io.*;
@ -59,207 +59,257 @@ import java.util.*;
import org.apache.poi.hpsf.wellknown.*;
/**
* <p>Convenience class representing a DocumentSummary Information
* stream in a Microsoft Office document.</p>
* <p>
*
* @see SummaryInformation
* Convenience class representing a DocumentSummary Information stream in a
* Microsoft Office document.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner closeTo sc.edu)
*
* @version $Id$
* @since 2002-02-09
*@author Rainer Klute (klute@rainer-klute.de)
*@author Drew Varner (Drew.Varner closeTo sc.edu)
*@created May 10, 2002
*@see SummaryInformation
*@version $Id: DocumentSummaryInformation.java,v 1.6 2002/05/03 07:29:09
* klute Exp $
*@since 2002-02-09
*/
public class DocumentSummaryInformation extends SpecialPropertySet
{
public class DocumentSummaryInformation extends SpecialPropertySet {
/**
* <p>Creates a {@link DocumentSummaryInformation} from a given
* {@link PropertySet}.</p>
* <p>
*
* @param ps A property set which should be created from a
* document summary information stream.
* Creates a {@link DocumentSummaryInformation} from a given {@link
* PropertySet}.</p>
*
* @throws UnexpectedPropertySetTypeException if <var>ps</var>
* does not contain a document summary information stream.
*@param ps A property set which
* should be created from a document summary information stream.
*@exception UnexpectedPropertySetTypeException Description of the
* Exception
*@throws UnexpectedPropertySetTypeException if <var>ps</var> does not
* contain a document summary information stream.
*/
public DocumentSummaryInformation(final PropertySet ps)
throws UnexpectedPropertySetTypeException
{
throws UnexpectedPropertySetTypeException {
super(ps);
if (!isDocumentSummaryInformation())
if (!isDocumentSummaryInformation()) {
throw new UnexpectedPropertySetTypeException
("Not a " + getClass().getName());
("Not a " + getClass().getName());
}
}
/**
* <p>Returns the stream's category (or <code>null</code>).</p>
* <p>
*
* Returns the stream's category (or <code>null</code>).</p>
*
*@return The category value
*/
public String getCategory()
{
public String getCategory() {
return (String) getProperty(PropertyIDMap.PID_CATEGORY);
}
/**
* <p>Returns the stream's presentation format (or
* <code>null</code>).</p>
* <p>
*
* Returns the stream's presentation format (or <code>null</code>).</p>
*
*@return The presentationFormat value
*/
public String getPresentationFormat()
{
public String getPresentationFormat() {
return (String) getProperty(PropertyIDMap.PID_PRESFORMAT);
}
/**
* <p>Returns the stream's byte count or 0 if the {@link
* DocumentSummaryInformation} does not contain a byte count.</p>
* <p>
*
* Returns the stream's byte count or 0 if the {@link
* DocumentSummaryInformation} does not contain a byte count.</p>
*
*@return The byteCount value
*/
public int getByteCount()
{
public int getByteCount() {
return getPropertyIntValue(PropertyIDMap.PID_BYTECOUNT);
}
/**
* <p>Returns the stream's line count or 0 if the {@link
* DocumentSummaryInformation} does not contain a line count.</p>
* <p>
*
* Returns the stream's line count or 0 if the {@link
* DocumentSummaryInformation} does not contain a line count.</p>
*
*@return The lineCount value
*/
public int getLineCount()
{
public int getLineCount() {
return getPropertyIntValue(PropertyIDMap.PID_LINECOUNT);
}
/**
* <p>Returns the stream's par count or 0 if the {@link
* DocumentSummaryInformation} does not contain a par count.</p>
* <p>
*
* Returns the stream's par count or 0 if the {@link
* DocumentSummaryInformation} does not contain a par count.</p>
*
*@return The parCount value
*/
public int getParCount()
{
public int getParCount() {
return getPropertyIntValue(PropertyIDMap.PID_PARCOUNT);
}
/**
* <p>Returns the stream's slide count or 0 if the {@link
* DocumentSummaryInformation} does not contain a slide count.</p>
* <p>
*
* Returns the stream's slide count or 0 if the {@link
* DocumentSummaryInformation} does not contain a slide count.</p>
*
*@return The slideCount value
*/
public int getSlideCount()
{
public int getSlideCount() {
return getPropertyIntValue(PropertyIDMap.PID_SLIDECOUNT);
}
/**
* <p>Returns the stream's note count or 0 if the {@link
* DocumentSummaryInformation} does not contain a note count.</p>
* <p>
*
* Returns the stream's note count or 0 if the {@link
* DocumentSummaryInformation} does not contain a note count.</p>
*
*@return The noteCount value
*/
public int getNoteCount()
{
public int getNoteCount() {
return getPropertyIntValue(PropertyIDMap.PID_NOTECOUNT);
}
/**
* <p>Returns the stream's hidden count or 0 if the {@link
* DocumentSummaryInformation} does not contain a hidden count.</p>
* <p>
*
* Returns the stream's hidden count or 0 if the {@link
* DocumentSummaryInformation} does not contain a hidden count.</p>
*
*@return The hiddenCount value
*/
public int getHiddenCount()
{
public int getHiddenCount() {
return getPropertyIntValue(PropertyIDMap.PID_HIDDENCOUNT);
}
/**
* <p>Returns the stream's mmclip count or 0 if the {@link
* DocumentSummaryInformation} does not contain a mmclip count.</p>
* <p>
*
* Returns the stream's mmclip count or 0 if the {@link
* DocumentSummaryInformation} does not contain a mmclip count.</p>
*
*@return The mMClipCount value
*/
public int getMMClipCount()
{
public int getMMClipCount() {
return getPropertyIntValue(PropertyIDMap.PID_MMCLIPCOUNT);
}
/**
* <p>Returns <code>true</code> when scaling of the thumbnail is
* desired, <code>false</code> if cropping is desired.</p>
* <p>
*
* Returns <code>true</code> when scaling of the thumbnail is desired,
* <code>false</code> if cropping is desired.</p>
*
*@return The scale value
*/
public boolean getScale()
{
public boolean getScale() {
return getPropertyBooleanValue(PropertyIDMap.PID_SCALE);
}
/**
* <p>Returns the stream's heading pair (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 heading pair (or <code>null</code>) <strong>when
* this method is implemented. Please note that the return type is likely
* to change!</strong>
*
*@return The headingPair value
*/
public byte[] getHeadingPair()
{
if (true)
public byte[] getHeadingPair() {
if (true) {
throw new UnsupportedOperationException("FIXME");
}
return (byte[]) getProperty(PropertyIDMap.PID_HEADINGPAIR);
}
/**
* <p>Returns the stream's doc parts (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 doc parts (or <code>null</code>) <strong>when this
* method is implemented. Please note that the return type is likely to
* change!</strong>
*
*@return The docparts value
*/
public byte[] getDocparts()
{
if (true)
public byte[] getDocparts() {
if (true) {
throw new UnsupportedOperationException("FIXME");
}
return (byte[]) getProperty(PropertyIDMap.PID_DOCPARTS);
}
/**
* <p>Returns the stream's manager (or <code>null</code>).</p>
* <p>
*
* Returns the stream's manager (or <code>null</code>).</p>
*
*@return The manager value
*/
public String getManager()
{
public String getManager() {
return (String) getProperty(PropertyIDMap.PID_MANAGER);
}
/**
* <p>Returns the stream's company (or <code>null</code>).</p>
* <p>
*
* Returns the stream's company (or <code>null</code>).</p>
*
*@return The company value
*/
public String getCompany()
{
public String getCompany() {
return (String) getProperty(PropertyIDMap.PID_COMPANY);
}
/**
* <p>Returns <code>true</code> if the custom links are hampered
* by excessive noise, for all applications.</p>
* <p>
*
* <p><strong>FIXME:</strong> Explain this some more! I (Rainer)
* don't understand it.</p>
* Returns <code>true</code> if the custom links are hampered by excessive
* noise, for all applications.</p> <p>
*
* <strong>FIXME:</strong> Explain this some more! I (Rainer) don't
* understand it.</p>
*
*@return The linksDirty value
*/
public boolean getLinksDirty()
{
public boolean getLinksDirty() {
return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY);
}

View File

@ -1,101 +1,109 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <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>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* 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)
*@created May 10, 2002
*@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>Creates a new {@link HPSFException} with a message
* string.</p>
* <p>
*
* Creates a new {@link HPSFException} with a message string.</p>
*
*@param msg Description of the Parameter
*/
public HPSFException(final String msg)
{
public HPSFException(final String msg) {
super(msg);
}
/**
* <p>Creates a new {@link HPSFException} with a reason.</p>
* <p>
*
* Creates a new {@link HPSFException} with a reason.</p>
*
*@param reason Description of the Parameter
*/
public HPSFException(final Throwable reason)
{
public HPSFException(final Throwable reason) {
super();
this.reason = reason;
}
@ -103,11 +111,15 @@ public class HPSFException extends Exception
/**
* <p>Creates a new {@link HPSFException} with a message string
* and a reason.</p>
* <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
*/
public HPSFException(final String msg, final Throwable reason)
{
public HPSFException(final String msg, final Throwable reason) {
super(msg);
this.reason = reason;
}
@ -115,12 +127,14 @@ public class HPSFException extends Exception
/**
* <p>Returns the {@link Throwable} that caused this exception to
* be thrown or <code>null</code> if there was no such {@link
* Throwable}.</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>
*
*@return The reason value
*/
public Throwable getReason()
{
public Throwable getReason() {
return reason;
}

View File

@ -1,101 +1,110 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <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>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* 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)
*@created May 10, 2002
*@version $Id: HPSFRuntimeException.java,v 1.3 2002/05/01 09:31:52 klute Exp
* $
*@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>Creates a new {@link HPSFRuntimeException} with a message
* string.</p>
* <p>
*
* Creates a new {@link HPSFRuntimeException} with a message string.</p>
*
*@param msg Description of the Parameter
*/
public HPSFRuntimeException(final String msg)
{
public HPSFRuntimeException(final String msg) {
super(msg);
}
/**
* <p>Creates a new {@link HPSFRuntimeException} with a reason.</p>
* <p>
*
* Creates a new {@link HPSFRuntimeException} with a reason.</p>
*
*@param reason Description of the Parameter
*/
public HPSFRuntimeException(final Throwable reason)
{
public HPSFRuntimeException(final Throwable reason) {
super();
this.reason = reason;
}
@ -103,11 +112,15 @@ public class HPSFRuntimeException extends RuntimeException
/**
* <p>Creates a new {@link HPSFRuntimeException} with a message string
* and a reason.</p>
* <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
*/
public HPSFRuntimeException(final String msg, final Throwable reason)
{
public HPSFRuntimeException(final String msg, final Throwable reason) {
super(msg);
this.reason = reason;
}
@ -115,12 +128,14 @@ public class HPSFRuntimeException extends RuntimeException
/**
* <p>Returns the {@link Throwable} that caused this exception to
* be thrown or <code>null</code> if there was no such {@link
* Throwable}.</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>
*
*@return The reason value
*/
public Throwable getReason()
{
public Throwable getReason() {
return reason;
}

View File

@ -1,87 +1,108 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <p>This exception is thrown if an {@link java.io.InputStream} does
* not support the {@link java.io.InputStream#mark} operation.</p>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* 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)
*@created May 10, 2002
*@version $Id: MarkUnsupportedException.java,v 1.3 2002/05/01 09:31:52 klute
* Exp $
*@since 2002-02-09
*/
public class MarkUnsupportedException extends HPSFException
{
public class MarkUnsupportedException extends HPSFException {
public MarkUnsupportedException()
{
/**
* Constructor for the MarkUnsupportedException object
*/
public MarkUnsupportedException() {
super();
}
public MarkUnsupportedException(final String msg)
{
/**
* Constructor for the MarkUnsupportedException object
*
*@param msg Description of the Parameter
*/
public MarkUnsupportedException(final String msg) {
super(msg);
}
public MarkUnsupportedException(final Throwable reason)
{
/**
* Constructor for the MarkUnsupportedException object
*
*@param reason Description of the Parameter
*/
public MarkUnsupportedException(final Throwable reason) {
super(reason);
}
public MarkUnsupportedException(final String msg, final Throwable 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) {
super(msg, reason);
}

View File

@ -1,92 +1,113 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <p>This exception is thrown if a format error in a property set
* stream is detected or when the input data do not constitute a
* property set stream.</p>
* <p>
*
* <p>The constructors of this class are analogous to those of its
* superclass and documented there.</p>
* This exception is thrown if a format error in a property set stream is
* detected or when the input data do not constitute a property set stream.</p>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* The constructors of this class are analogous to those of its superclass and
* documented there.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id: NoPropertySetStreamException.java,v 1.3 2002/05/01 09:31:52
* klute Exp $
*@since 2002-02-09
*/
public class NoPropertySetStreamException extends HPSFException
{
public class NoPropertySetStreamException extends HPSFException {
public NoPropertySetStreamException()
{
/**
* Constructor for the NoPropertySetStreamException object
*/
public NoPropertySetStreamException() {
super();
}
public NoPropertySetStreamException(final String msg)
{
/**
* Constructor for the NoPropertySetStreamException object
*
*@param msg Description of the Parameter
*/
public NoPropertySetStreamException(final String msg) {
super(msg);
}
public NoPropertySetStreamException(final Throwable reason)
{
/**
* Constructor for the NoPropertySetStreamException object
*
*@param reason Description of the Parameter
*/
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

@ -1,93 +1,113 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <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>
* 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>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* The constructors of this class are analogous to those of its superclass and
* documented there.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id: NoSingleSectionException.java,v 1.3 2002/05/01 09:31:52 klute
* Exp $
*@since 2002-02-09
*/
public class NoSingleSectionException extends HPSFRuntimeException
{
public class NoSingleSectionException extends HPSFRuntimeException {
public NoSingleSectionException()
{
super();
/**
* Constructor for the NoSingleSectionException object
*/
public NoSingleSectionException() {
super();
}
public NoSingleSectionException(final String msg)
{
super(msg);
/**
* Constructor for the NoSingleSectionException object
*
*@param msg Description of the Parameter
*/
public NoSingleSectionException(final String msg) {
super(msg);
}
public NoSingleSectionException(final Throwable reason)
{
super(reason);
/**
* Constructor for the NoSingleSectionException object
*
*@param reason Description of the Parameter
*/
public NoSingleSectionException(final Throwable reason) {
super(reason);
}
public NoSingleSectionException(final String msg, final Throwable reason)
{
super(msg, reason);
/**
* Constructor for the NoSingleSectionException object
*
*@param msg Description of the Parameter
*@param reason Description of the Parameter
*/
public NoSingleSectionException(final String msg, final Throwable reason) {
super(msg, reason);
}
}

View File

@ -1,121 +1,127 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.hpsf;
import java.util.*;
import org.apache.poi.hpsf.littleendian.*;
import org.apache.poi.util.LittleEndian;
/**
* <p>A property in a {@link Section} of a {@link PropertySet}.</p>
* <p>
*
* <p>The property's <strong>ID</strong> gives the property a meaning
* in the context of its {@link Section}. Each {@link Section} spans
* its own name space of property IDs.</p>
* A property in a {@link Section} of a {@link PropertySet}.</p> <p>
*
* <p>The property's <strong>type</strong> determines how its
* <strong>value</strong> is interpreted. For example, if the type is
* {@link Variant#VT_LPSTR} (byte string), the value consists of a
* {@link DWord} telling how many bytes the string contains. The bytes
* follow immediately, including any null bytes that terminate the
* string. The type {@link Variant#VT_I4} denotes a four-byte integer
* value, {@link Variant#VT_FILETIME} some date and time (of a
* file).</p>
* The property's <strong>ID</strong> gives the property a meaning in the
* context of its {@link Section}. Each {@link Section} spans its own name
* space of property IDs.</p> <p>
*
* <p><strong>FIXME:</strong> Reading of other types than those
* mentioned above and the dictionary property is not yet
* implemented.</p>
* The property's <strong>type</strong> determines how its <strong>value
* </strong> is interpreted. For example, if the type is {@link
* Variant#VT_LPSTR} (byte string), the value consists of a {@link DWord}
* telling how many bytes the string contains. The bytes follow immediately,
* including any null bytes that terminate the string. The type {@link
* Variant#VT_I4} denotes a four-byte integer value, {@link
* Variant#VT_FILETIME} some date and time (of a file).</p> <p>
*
* @see Section
* @see Variant
* <strong>FIXME:</strong> Reading of other types than those mentioned above
* and the dictionary property is not yet implemented.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner InAndAround sc.edu)
*
* @version $Id$
* @since 2002-02-09
*@author Rainer Klute (klute@rainer-klute.de)
*@author Drew Varner (Drew.Varner InAndAround sc.edu)
*@created May 10, 2002
*@see Section
*@see Variant
*@version $Id$
*@since 2002-02-09
*/
public class Property
{
public class Property {
private int id;
/**
* <p>Returns the property's ID.</p>
* <p>
*
* Returns the property's ID.</p>
*
*@return The iD value
*/
public int getID()
{
public int getID() {
return id;
}
private int type;
private long type;
/**
* <p>Returns the property's type.</p>
* <p>
*
* Returns the property's type.</p>
*
*@return The type value
*/
public int getType()
{
public long getType() {
return type;
}
@ -123,44 +129,47 @@ public class Property
private Object value;
/**
* <p>Returns the property value's.</p>
* <p>
*
* Returns the property value's.</p>
*
*@return The value value
*/
public Object getValue()
{
public Object getValue() {
return value;
}
/**
* <p>Creates a {@link Property} instance by reading its bytes
* from the property set stream.</p>
* <p>
*
* @param id The property's ID.
* Creates a {@link Property} instance by reading its bytes from the
* property set stream.</p>
*
* @param src The bytes the property set stream consists of.
*
* @param offset The property's type/value pair's offset in the
* section.
*
* @param length The property's type/value pair's length in bytes.
* list.
*@param id The property's ID.
*@param src The bytes the property set stream consists of.
*@param offset The property's type/value pair's offset in the section.
*@param length The property's type/value pair's length in bytes. list.
*/
public Property(final int id, final byte[] src, final int offset,
int length)
{
public Property(final int id, final byte[] src, final long offset,
int length) {
this.id = id;
/* ID 0 is a special case since it specifies a dictionary of
* property IDs and property names. */
if (id == 0)
{
/*
* ID 0 is a special case since it specifies a dictionary of
* property IDs and property names.
*/
if (id == 0) {
value = readDictionary(src, offset, length);
return;
}
/* FIXME: Support this! */
/*
* FIXME: Support this!
*/
// /* ID 1 is another special case: It denotes the code page of
// * byte strings in this section. */
// if (id == 1)
@ -169,89 +178,103 @@ public class Property
// return;
// }
int o = offset;
type = new DWord(src, o).intValue();
o += DWord.LENGTH;
int o = (int) offset;
type = LittleEndian.getUInt(src, o);
o += LittleEndian.INT_SIZE;
/* FIXME: Support reading more types! */
switch (type)
{
/*
* FIXME: Support reading more types!
*/
switch ((int)type) {
case Variant.VT_I4:
{
/* Read a word. In Java it is represented as an
Integer object. */
value = new Integer(new DWord(src, o).intValue());
/*
* Read a word. In Java it is represented as an
* Integer object.
*/
value = new Long(LittleEndian.getUInt(src, o));
break;
}
case Variant.VT_FILETIME:
{
/* Read a FILETIME object. In Java it is represented
as a Date. */
final int low = new DWord(src, o).intValue();
o += DWord.LENGTH;
final int high = new DWord(src, o).intValue();
value = Util.filetimeToDate(high, low);
/*
* Read a FILETIME object. In Java it is represented
* as a Date.
*/
final long low = LittleEndian.getUInt(src, o);
o += LittleEndian.INT_SIZE;
final long high = LittleEndian.getUInt(src, o);
value = Util.filetimeToDate((int)high, (int)low);
break;
}
case Variant.VT_LPSTR:
{
/* Read a byte string. In Java it is represented as a
String. The null bytes at the end of the byte
strings must be stripped. */
final int first = o + DWord.LENGTH;
int last = first + new DWord(src, o).intValue() - 1;
o += DWord.LENGTH;
while (src[last] == 0 && first <= last)
/*
* Read a byte string. In Java it is represented as a
* String. The null bytes at the end of the byte
* strings must be stripped.
*/
final int first = o + LittleEndian.INT_SIZE;
long last = first + LittleEndian.getUInt(src, o) - 1;
o += LittleEndian.INT_SIZE;
while (src[(int)last] == 0 && first <= last) {
last--;
value = new String(src, first, last - first + 1);
}
value = new String(src, (int)first, (int)(last - first + 1));
break;
}
case Variant.VT_CF:
{
/* The first four bytes in src, from rc[offset] to
* src[offset + 3] contain the DWord for VT_CF, so
* skip it, we don't need it. */
/* Truncate the length of the return array by a DWord
* length (4 bytes). */
length = length - DWord.LENGTH;
/*
* The first four bytes in src, from rc[offset] to
* src[offset + 3] contain the DWord for VT_CF, so
* skip it, we don't need it.
*/
/*
* Truncate the length of the return array by a DWord
* length (4 bytes).
*/
length = length - LittleEndian.INT_SIZE;
final byte[] v = new byte[length];
for (int i = 0; i < length; i++)
v[i] = src[o + i];
for (int i = 0; i < length; i++) {
v[i] = src[(int)(o + i)];
}
value = v;
break;
}
case Variant.VT_BOOL:
{
/* The first four bytes in src, from src[offset] to
* src[offset + 3] contain the DWord for VT_BOOL, so
* skip it, we don't need it. */
final int first = o + DWord.LENGTH;
DWord bool = new DWord(src,o);
if (bool.intValue() == -1)
{
/*
* The first four bytes in src, from src[offset] to
* src[offset + 3] contain the DWord for VT_BOOL, so
* skip it, we don't need it.
*/
final int first = o + LittleEndian.INT_SIZE;
long bool = LittleEndian.getUInt(src, o);
if (bool == -1) {
value = new Boolean(true);
}
else if (bool.intValue() == 0)
{
} else if (bool == 0) {
value = new Boolean(false);
}
else
/* FIXME: Someone might invent a new
* HPSFRuntimeException subclass
* IllegalPropertySetDataException for this and
* similar cases. */
} else {
/*
* FIXME: Someone might invent a new
* HPSFRuntimeException subclass
* IllegalPropertySetDataException for this and
* similar cases.
*/
throw new HPSFRuntimeException
("Illegal property set data: A boolean must be " +
"either -1 (true) or 0 (false).");
("Illegal property set data: A boolean must be " +
"either -1 (true) or 0 (false).");
}
break;
}
default:
{
final byte[] v = new byte[length];
for (int i = 0; i < length; i++)
v[i] = src[offset + i];
for (int i = 0; i < length; i++) {
v[i] = src[(int)(offset + i)];
}
value = v;
break;
}
@ -261,41 +284,51 @@ public class Property
/**
* <p>Reads a dictionary.</p>
* <p>
*
* @param src The byte array containing the bytes making out the
* dictionary.
* Reads a dictionary.</p>
*
* @param offset At this offset within <var>src</var> the
* dictionary starts.
*
* @param length The dictionary contains at most this many bytes.
*@param src The byte array containing the bytes making out the
* dictionary.
*@param offset At this offset within <var>src</var> the dictionary
* starts.
*@param length The dictionary contains at most this many bytes.
*@return Description of the Return Value
*/
protected Map readDictionary(final byte[] src, final int offset,
final int length)
{
/* FIXME: Check the length! */
int o = offset;
protected Map readDictionary(final byte[] src, final long offset,
final int length) {
/*
* FIXME: Check the length!
*/
int o = (int)offset;
/* Read the number of dictionary entries. */
final int nrEntries = new DWord(src, o).intValue();
o += DWord.LENGTH;
/*
* Read the number of dictionary entries.
*/
final long nrEntries = LittleEndian.getUInt(src, o);
o += LittleEndian.INT_SIZE;
final Map m = new HashMap(nrEntries, (float) 1.0);
for (int i = 0; i < nrEntries; i++)
{
/* The key */
final Integer id = new Integer(new DWord(src, o).intValue());
o += DWord.LENGTH;
final Map m = new HashMap((int)nrEntries, (float) 1.0);
for (int i = 0; i < nrEntries; i++) {
/*
* The key
*/
final Long id = new Long(LittleEndian.getUInt(src, o));
o += LittleEndian.INT_SIZE;
/* The value (a string) */
final int sLength = new DWord(src, o).intValue();
o += DWord.LENGTH;
/* Strip trailing 0x00 bytes. */
int l = sLength;
while (src[o + l - 1] == 0x00)
/*
* The value (a string)
*/
final long sLength = LittleEndian.getUInt(src, o);
o += LittleEndian.INT_SIZE;
/*
* Strip trailing 0x00 bytes.
*/
long l = sLength;
while (src[(int)(o + l - 1)] == 0x00) {
l--;
final String s = new String(src, o, l);
}
final String s = new String(src, o, (int)l);
o += sLength;
m.put(id, s);
}
@ -305,16 +338,16 @@ public class Property
/**
* <p>Reads a code page.</p>
* <p>
*
* @param src The byte array containing the bytes making out the
* code page.
* Reads a code page.</p>
*
* @param offset At this offset within <var>src</var> the code
* page starts.
*@param src The byte array containing the bytes making out the code
* page.
*@param offset At this offset within <var>src</var> the code page starts.
*@return Description of the Return Value
*/
protected int readCodePage(final byte[] src, final int offset)
{
protected int readCodePage(final byte[] src, final long offset) {
throw new UnsupportedOperationException("FIXME");
}

View File

@ -1,57 +1,57 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import java.io.*;
@ -61,71 +61,77 @@ import org.apache.poi.hpsf.wellknown.*;
import org.apache.poi.poifs.filesystem.*;
/**
* <p>Represents a property set in the Horrible Property Set Format
* (HPSF). These are usually metadata of a Microsoft Office
* document.</p>
* <p>
*
* <p>An application that wants to access these metadata should create
* an instance of this class or one of its subclasses by calling the
* factory method {@link PropertySetFactory#create} and then retrieve
* the information its needs by calling appropriate methods.</p>
* Represents a property set in the Horrible Property Set Format (HPSF). These
* are usually metadata of a Microsoft Office document.</p> <p>
*
* <p>{@link PropertySetFactory#create} does its work by calling one
* of the constructors {@link PropertySet#PropertySet(InputStream)} or
* {@link PropertySet#PropertySet(byte[])}. If the constructor's
* argument is not in the Horrible Property Set Format, i.e. not a
* property set stream, or if any other error occurs, an appropriate
* exception is thrown.</p>
* An application that wants to access these metadata should create an instance
* of this class or one of its subclasses by calling the factory method {@link
* PropertySetFactory#create} and then retrieve the information its needs by
* calling appropriate methods.</p> <p>
*
* <p>A {@link PropertySet} has a list of {@link Section}s, and each
* {@link Section} has a {@link Property} array. Use {@link
* #getSections} to retrieve the {@link Section}s, then call {@link
* Section#getProperties} for each {@link Section} to get hold of the
* {@link Property} arrays.</p>
* {@link PropertySetFactory#create} does its work by calling one of the
* constructors {@link PropertySet#PropertySet(InputStream)} or {@link
* PropertySet#PropertySet(byte[])}. If the constructor's argument is not in
* the Horrible Property Set Format, i.e. not a property set stream, or if any
* other error occurs, an appropriate exception is thrown.</p> <p>
*
* Since the vast majority of {@link PropertySet}s contains only a
* single {@link Section}, the convenience method {@link
* #getProperties} returns the properties of a {@link PropertySet}'s
* {@link Section} (throwing a {@link NoSingleSectionException} if the
* {@link PropertySet} contains more (or less) than exactly one {@link
* Section}).
* A {@link PropertySet} has a list of {@link Section}s, and each {@link
* Section} has a {@link Property} array. Use {@link #getSections} to retrieve
* the {@link Section}s, then call {@link Section#getProperties} for each
* {@link Section} to get hold of the {@link Property} arrays.</p> Since the
* vast majority of {@link PropertySet}s contains only a single {@link
* Section}, the convenience method {@link #getProperties} returns the
* properties of a {@link PropertySet}'s {@link Section} (throwing a {@link
* NoSingleSectionException} if the {@link PropertySet} contains more (or less)
* than exactly one {@link Section}).
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner hanginIn sc.edu)
*
* @version $Id$
* @since 2002-02-09
*@author Rainer Klute (klute@rainer-klute.de)
*@author Drew Varner (Drew.Varner hanginIn sc.edu)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public class PropertySet
{
static final byte[] BYTE_ORDER_ASSERTION =
new byte[] {(byte) 0xFF, (byte) 0xFE};
static final byte[] FORMAT_ASSERTION =
new byte[] {(byte) 0x00, (byte) 0x00};
public class PropertySet {
final static byte[] BYTE_ORDER_ASSERTION =
new byte[]{(byte) 0xFF, (byte) 0xFE};
final static byte[] FORMAT_ASSERTION =
new byte[]{(byte) 0x00, (byte) 0x00};
private Word byteOrder;
private Word byteOrder; // Must equal BYTE_ORDER_ASSERTION
// Must equal BYTE_ORDER_ASSERTION
/**
* <p>Returns the property set stream's low-level "byte order"
* field. It is always <tt>0xFFFE</tt>.</p>
* <p>
*
* Returns the property set stream's low-level "byte order" field. It is
* always <tt>0xFFFE</tt> .</p>
*
*@return The byteOrder value
*/
public Word getByteOrder()
{
public Word getByteOrder() {
return byteOrder;
}
private Word format; // Must equal FORMAT_ASSERTION
private Word format;
// Must equal FORMAT_ASSERTION
/**
* <p>Returns the property set stream's low-level "format"
* field. It is always <tt>0x0000</tt>.</p>
* <p>
*
* Returns the property set stream's low-level "format" field. It is always
* <tt>0x0000</tt> .</p>
*
*@return The format value
*/
public Word getFormat()
{
public Word getFormat() {
return format;
}
@ -133,12 +139,15 @@ public class PropertySet
private DWord osVersion;
/**
* <p>Returns the property set stream's low-level "OS version"
* field.</p>
* <p>
*
* Returns the property set stream's low-level "OS version" field.</p>
*
*@return The oSVersion value
*/
public DWord getOSVersion()
{
public DWord getOSVersion() {
return osVersion;
}
@ -146,12 +155,15 @@ public class PropertySet
private ClassID classID;
/**
* <p>Returns the property set stream's low-level "class ID"
* field.</p>
* <p>
*
* Returns the property set stream's low-level "class ID" field.</p>
*
*@return The classID value
*/
public ClassID getClassID()
{
public ClassID getClassID() {
return classID;
}
@ -159,12 +171,15 @@ public class PropertySet
private int sectionCount;
/**
* <p>Returns the number of {@link Section}s in the property
* set.</p>
* <p>
*
* Returns the number of {@link Section}s in the property set.</p>
*
*@return The sectionCount value
*/
public int getSectionCount()
{
public int getSectionCount() {
return sectionCount;
}
@ -172,148 +187,161 @@ public class PropertySet
private List sections;
/**
* <p>Returns the {@link Section}s in the property set.</p>
* <p>
*
* Returns the {@link Section}s in the property set.</p>
*
*@return The sections value
*/
public List getSections()
{
public List getSections() {
return sections;
}
/**
* <p>Creates an empty (uninitialized) {@link PropertySet}.</p>
* <p>
*
* <p><strong>Please note:</strong> For the time being this
* constructor is protected since it is used for internal purposes
* only, but expect it to become public once the property set
* writing functionality is implemented.</p>
* Creates an empty (uninitialized) {@link PropertySet}.</p> <p>
*
* <strong>Please note:</strong> For the time being this constructor is
* protected since it is used for internal purposes only, but expect it to
* become public once the property set writing functionality is
* implemented.</p>
*/
protected PropertySet()
{}
protected PropertySet() { }
/**
* <p>Creates a {@link PropertySet} instance from an {@link
* InputStream} in the Horrible Property Set Format.</p>
* <p>
*
* <p>The constructor reads the first few bytes from the stream
* and determines whether it is really a property set stream. If
* it is, it parses the rest of the stream. If it is not, it
* resets the stream to its beginning in order to let other
* components mess around with the data and throws an
* exception.</p>
* Creates a {@link PropertySet} instance from an {@link InputStream} in
* the Horrible Property Set Format.</p> <p>
*
* @throws NoPropertySetStreamException if the stream is not a
* property set stream.
* The constructor reads the first few bytes from the stream and determines
* whether it is really a property set stream. If it is, it parses the rest
* of the stream. If it is not, it resets the stream to its beginning in
* order to let other components mess around with the data and throws an
* exception.</p>
*
* @throws MarkUnsupportedException if the stream does not support
* the {@link InputStream#markSupported} method.
*
* @throws IOException if the {@link InputStream} cannot not be
* accessed as needed.
*@param stream Description of the Parameter
*@exception NoPropertySetStreamException Description of the Exception
*@exception MarkUnsupportedException Description of the Exception
*@exception IOException Description of the Exception
*@throws NoPropertySetStreamException if the stream is not a property
* set stream.
*@throws MarkUnsupportedException if the stream does not support
* the {@link InputStream#markSupported} method.
*@throws IOException if the {@link InputStream}
* cannot not be accessed as needed.
*/
public PropertySet(final InputStream stream)
throws NoPropertySetStreamException, MarkUnsupportedException,
IOException
{
if (isPropertySetStream(stream))
{
throws NoPropertySetStreamException, MarkUnsupportedException,
IOException {
if (isPropertySetStream(stream)) {
final int avail = stream.available();
final byte[] buffer = new byte[avail];
stream.read(buffer, 0, buffer.length);
init(buffer, 0, buffer.length);
}
else
} else {
throw new NoPropertySetStreamException();
}
}
/**
* <p>Creates a {@link PropertySet} instance from a byte array
* that represents a stream in the Horrible Property Set
* Format.</p>
* <p>
*
* @param stream The byte array holding the stream data.
* Creates a {@link PropertySet} instance from a byte array that represents
* a stream in the Horrible Property Set Format.</p>
*
* @param offset The offset in <var>stream</var> where the stream
* data begin. If the stream data begin with the first byte in the
* array, the <var>offset</var> is 0.
*
* @param length The length of the stream data.
*
* @throws NoPropertySetStreamException if the byte array is not a
* property set stream.
*@param stream The byte array holding the
* stream data.
*@param offset The offset in <var>stream</var>
* where the stream data begin. If the stream data begin with the first
* byte in the array, the <var>offset</var> is 0.
*@param length The length of the stream data.
*@exception NoPropertySetStreamException Description of the Exception
*@throws NoPropertySetStreamException if the byte array is not a
* property set stream.
*/
public PropertySet(final byte[] stream, final int offset, final int length)
throws NoPropertySetStreamException
{
if (isPropertySetStream(stream, offset, length))
throws NoPropertySetStreamException {
if (isPropertySetStream(stream, offset, length)) {
init(stream, offset, length);
else
} else {
throw new NoPropertySetStreamException();
}
}
/**
* <p>Creates a {@link PropertySet} instance from a byte array
* that represents a stream in the Horrible Property Set
* Format.</p>
* <p>
*
* @param stream The byte array holding the stream data. The
* complete byte array contents is the stream data.
* Creates a {@link PropertySet} instance from a byte array that represents
* a stream in the Horrible Property Set Format.</p>
*
* @throws NoPropertySetStreamException if the byte array is not a
* property set stream.
*@param stream The byte array holding the
* stream data. The complete byte array contents is the stream data.
*@exception NoPropertySetStreamException Description of the Exception
*@throws NoPropertySetStreamException if the byte array is not a
* property set stream.
*/
public PropertySet(final byte[] stream)
throws NoPropertySetStreamException
{
throws NoPropertySetStreamException {
this(stream, 0, stream.length);
}
/**
* <p>Checks whether an {@link InputStream} is in the Horrible
* Property Set Format.</p>
* <p>
*
* @param stream The {@link InputStream} to check. In order to
* perform the check, the method reads the first bytes from the
* stream. After reading, the stream is reset to the position it
* had before reading. The {@link InputStream} must support the
* {@link InputStream#mark} method.
* Checks whether an {@link InputStream} is in the Horrible Property Set
* Format.</p>
*
* @return <code>true</code> if the stream is a property set
* stream, else <code>false</code>.
*
* @throws MarkUnsupportedException if the {@link InputStream}
* does not support the {@link InputStream#mark} method.
*@param stream The {@link InputStream} to check. In
* order to perform the check, the method reads the first bytes from
* the stream. After reading, the stream is reset to the position it
* had before reading. The {@link InputStream} must support the {@link
* InputStream#mark} method.
*@return <code>true</code> if the stream is a
* property set stream, else <code>false</code>.
*@exception IOException Description of the Exception
*@throws MarkUnsupportedException if the {@link InputStream} does not
* support the {@link InputStream#mark} method.
*/
public static boolean isPropertySetStream(final InputStream stream)
throws MarkUnsupportedException, IOException
{
/* Read at most this many bytes. */
throws MarkUnsupportedException, IOException {
/*
* Read at most this many bytes.
*/
final int BUFFER_SIZE = 50;
/* Mark the current position in the stream so that we can
* reset to this position if the stream does not contain a
* property set. */
if (!stream.markSupported())
/*
* Mark the current position in the stream so that we can
* reset to this position if the stream does not contain a
* property set.
*/
if (!stream.markSupported()) {
throw new MarkUnsupportedException(stream.getClass().getName());
}
stream.mark(BUFFER_SIZE);
/* Read a couple of bytes from the stream. */
/*
* Read a couple of bytes from the stream.
*/
final byte[] buffer = new byte[BUFFER_SIZE];
final int bytes =
stream.read(buffer, 0,
Math.min(buffer.length, stream.available()));
stream.read(buffer, 0,
Math.min(buffer.length, stream.available()));
final boolean isPropertySetStream =
isPropertySetStream(buffer, 0, bytes);
isPropertySetStream(buffer, 0, bytes);
stream.reset();
return isPropertySetStream;
}
@ -321,54 +349,63 @@ public class PropertySet
/**
* <p>Checks whether a byte array is in the Horrible Property Set
* Format.</p>
* <p>
*
* @param src The byte array to check.
* Checks whether a byte array is in the Horrible Property Set Format.</p>
*
* @param offset The offset in the byte array.
*
* @param length The significant number of bytes in the byte
* array. Only this number of bytes will be checked.
*
* @return <code>true</code> if the byte array is a property set
* stream, <code>false</code> if not.
*@param src The byte array to check.
*@param offset The offset in the byte array.
*@param length The significant number of bytes in the byte array. Only
* this number of bytes will be checked.
*@return <code>true</code> if the byte array is a property set
* stream, <code>false</code> if not.
*/
public static boolean isPropertySetStream(final byte[] src, int offset,
final int length)
{
/* Read the header fields of the stream. They must always be
* there. */
final int length) {
/*
* Read the header fields of the stream. They must always be
* there.
*/
final Word byteOrder = new Word(src, offset);
offset += Word.LENGTH;
if (!Util.equal(byteOrder.getBytes(), BYTE_ORDER_ASSERTION))
if (!Util.equal(byteOrder.getBytes(), BYTE_ORDER_ASSERTION)) {
return false;
}
final Word format = new Word(src, offset);
offset += Word.LENGTH;
if (!Util.equal(format.getBytes(), FORMAT_ASSERTION))
if (!Util.equal(format.getBytes(), FORMAT_ASSERTION)) {
return false;
}
final DWord osVersion = new DWord(src, offset);
offset += DWord.LENGTH;
final ClassID classID = new ClassID(src, offset);
offset += ClassID.LENGTH;
final DWord sectionCount = new DWord(src, offset);
offset += DWord.LENGTH;
if (sectionCount.intValue() < 1)
if (sectionCount.intValue() < 1) {
return false;
}
return true;
}
/**
* <p>Initializes this {@link PropertySet} instance from a byte
* array. The method assumes that it has been checked already that
* the byte array indeed represents a property set stream. It does
* no more checks on its own.</p>
* <p>
*
* Initializes this {@link PropertySet} instance from a byte array. The
* method assumes that it has been checked already that the byte array
* indeed represents a property set stream. It does no more checks on its
* own.</p>
*
*@param src Description of the Parameter
*@param offset Description of the Parameter
*@param length Description of the Parameter
*/
private void init(final byte[] src, int offset, final int length)
{
/* Read the stream's header fields. */
private void init(final byte[] src, int offset, final int length) {
/*
* Read the stream's header fields.
*/
byteOrder = new Word(src, offset);
offset += Word.LENGTH;
format = new Word(src, offset);
@ -380,21 +417,26 @@ public class PropertySet
sectionCount = new DWord(src, offset).intValue();
offset += DWord.LENGTH;
/* Read the sections, which are following the header. They
* start with an array of section descriptions. Each one
* consists of a format ID telling what the section contains
* and an offset telling how many bytes from the start of the
* stream the section begins. */
/* Most property sets have only one section. The Document
* Summary Information stream has 2. Everything else is a rare
* exception and is no longer fostered by Microsoft. */
/*
* Read the sections, which are following the header. They
* start with an array of section descriptions. Each one
* consists of a format ID telling what the section contains
* and an offset telling how many bytes from the start of the
* stream the section begins.
*/
/*
* Most property sets have only one section. The Document
* Summary Information stream has 2. Everything else is a rare
* exception and is no longer fostered by Microsoft.
*/
sections = new ArrayList(2);
/* Loop over the section descriptor array. Each descriptor
* consists of a ClassID and a DWord, and we have to increment
* "offset" accordingly. */
for (int i = 0; i < sectionCount; i++)
{
/*
* Loop over the section descriptor array. Each descriptor
* consists of a ClassID and a DWord, and we have to increment
* "offset" accordingly.
*/
for (int i = 0; i < sectionCount; i++) {
final Section s = new Section(src, offset);
offset += ClassID.LENGTH + DWord.LENGTH;
sections.add(s);
@ -404,141 +446,155 @@ public class PropertySet
/**
* <p>Checks whether this {@link PropertySet} represents a Summary
* Information.</p>
* <p>
*
* Checks whether this {@link PropertySet} represents a Summary
* Information.</p>
*
*@return The summaryInformation value
*/
public boolean isSummaryInformation()
{
public boolean isSummaryInformation() {
return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(),
SectionIDMap.SUMMARY_INFORMATION_ID);
SectionIDMap.SUMMARY_INFORMATION_ID);
}
/**
* <p>Checks whether this {@link PropertySet} is a Document
* Summary Information.</p>
* <p>
*
* Checks whether this {@link PropertySet} is a Document Summary
* Information.</p>
*
*@return The documentSummaryInformation value
*/
public boolean isDocumentSummaryInformation()
{
public boolean isDocumentSummaryInformation() {
return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(),
SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID);
SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID);
}
/**
* <p>Convenience method returning the {@link Property} array
* contained in this property set. It is a shortcut for getting
* the {@link PropertySet}'s {@link Section}s list and then
* getting the {@link Property} array from the first {@link
* Section}. However, it can only be used if the {@link
* PropertySet} contains exactly one {@link Section}, so check
* {@link #getSectionCount} first!</p>
* <p>
*
* @return The properties of the only {@link Section} of this
* {@link PropertySet}.
* Convenience method returning the {@link Property} array contained in
* this property set. It is a shortcut for getting the {@link
* PropertySet}'s {@link Section}s list and then getting the {@link
* Property} array from the first {@link Section}. However, it can only be
* used if the {@link PropertySet} contains exactly one {@link Section}, so
* check {@link #getSectionCount} first!</p>
*
* @throws NoSingleSectionException if the {@link PropertySet} has
* more or less than one {@link Section}.
*@return The properties of the only {@link
* Section} of this {@link PropertySet}.
*@throws NoSingleSectionException if the {@link PropertySet} has more or
* less than one {@link Section}.
*/
public Property[] getProperties()
throws NoSingleSectionException
{
throws NoSingleSectionException {
return getSingleSection().getProperties();
}
/**
* <p>Convenience method returning the value of the property with
* the specified ID. If the property is not available,
* <code>null</code> is returned and a subsequent call to {@link
* #wasNull} will return <code>true</code>.</p>
* <p>
*
* @throws NoSingleSectionException if the {@link PropertySet} has
* more or less than one {@link Section}.
* Convenience method returning the value of the property with the
* specified ID. If the property is not available, <code>null</code> is
* returned and a subsequent call to {@link #wasNull} will return <code>true</code>
* .</p>
*
*@param id Description of the Parameter
*@return The property value
*@throws NoSingleSectionException if the {@link PropertySet} has more or
* less than one {@link Section}.
*/
protected Object getProperty(final int id)
throws NoSingleSectionException
{
throws NoSingleSectionException {
return getSingleSection().getProperty(id);
}
/**
* <p>Convenience method returning the value of a boolean property
* with the specified ID. If the property is not available,
* <code>false</code> is returned. A subsequent call to {@link
* #wasNull} will return <code>true</code> to let the caller
* distinguish that case from a real property value of
* <code>false</code>.</p>
* <p>
*
* @throws NoSingleSectionException if the {@link PropertySet} has
* more or less than one {@link Section}.
* Convenience method returning the value of a boolean property with the
* specified ID. If the property is not available, <code>false</code> is
* returned. A subsequent call to {@link #wasNull} will return <code>true</code>
* to let the caller distinguish that case from a real property value of
* <code>false</code>.</p>
*
*@param id Description of the Parameter
*@return The propertyBooleanValue value
*@throws NoSingleSectionException if the {@link PropertySet} has more or
* less than one {@link Section}.
*/
protected boolean getPropertyBooleanValue(final int id)
throws NoSingleSectionException
{
throws NoSingleSectionException {
return getSingleSection().getPropertyBooleanValue(id);
}
/**
* <p>Convenience method returning the value of the numeric
* property with the specified ID. If the property is not
* available, 0 is returned. A subsequent call to {@link #wasNull}
* will return <code>true</code> to let the caller distinguish
* that case from a real property value of 0.</p>
* <p>
*
* @throws NoSingleSectionException if the {@link PropertySet} has
* more or less than one {@link Section}.
* Convenience method returning the value of the numeric property with the
* specified ID. If the property is not available, 0 is returned. A
* subsequent call to {@link #wasNull} will return <code>true</code> to let
* the caller distinguish that case from a real property value of 0.</p>
*
*@param id Description of the Parameter
*@return The propertyIntValue value
*@throws NoSingleSectionException if the {@link PropertySet} has more or
* less than one {@link Section}.
*/
protected int getPropertyIntValue(final int id)
throws NoSingleSectionException
{
throws NoSingleSectionException {
return getSingleSection().getPropertyIntValue(id);
}
/**
* <p>Checks whether the property which the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access
* was available or not. This information might be important for
* callers of {@link #getPropertyIntValue} since the latter
* returns 0 if the property does not exist. Using {@link
* #wasNull}, the caller can distiguish this case from a
* property's real value of 0.</p>
* <p>
*
* @return <code>true</code> if the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access a
* property that was not available, else <code>false</code>.
* Checks whether the property which the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access was
* available or not. This information might be important for callers of
* {@link #getPropertyIntValue} since the latter returns 0 if the property
* does not exist. Using {@link #wasNull}, the caller can distiguish this
* case from a property's real value of 0.</p>
*
* @throws NoSingleSectionException if the {@link PropertySet} has
* more than one {@link Section}.
*@return <code>true</code> if the last call to
* {@link #getPropertyIntValue} or {@link #getProperty} tried to access
* a property that was not available, else <code>false</code>.
*@throws NoSingleSectionException if the {@link PropertySet} has more
* than one {@link Section}.
*/
public boolean wasNull() throws NoSingleSectionException
{
public boolean wasNull() throws NoSingleSectionException {
return getSingleSection().wasNull();
}
/**
* <p>If the {@link PropertySet} has only a single section this
* method returns it.</p>
* <p>
*
* @throws NoSingleSectionException if the {@link PropertySet} has
* more or less than exactly one {@link Section}.
* If the {@link PropertySet} has only a single section this method returns
* it.</p>
*
*@return The singleSection value
*@throws NoSingleSectionException if the {@link PropertySet} has more or
* less than exactly one {@link Section}.
*/
public Section getSingleSection()
{
if (sectionCount != 1)
public Section getSingleSection() {
if (sectionCount != 1) {
throw new NoSingleSectionException
("Property set contains " + sectionCount + " sections.");
("Property set contains " + sectionCount + " sections.");
}
return ((Section) sections.get(0));
}

View File

@ -1,93 +1,107 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import java.io.*;
/**
* <p>Factory class to create instances of {@link SummaryInformation},
* {@link DocumentSummaryInformation} and {@link PropertySet}.</p>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* Factory class to create instances of {@link SummaryInformation}, {@link
* DocumentSummaryInformation} and {@link PropertySet}.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public class PropertySetFactory
{
public class PropertySetFactory {
/**
* <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>
* <p>
*
* @param stream Contains the property set stream's data.
* 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
*/
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

@ -1,103 +1,111 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import java.util.*;
import org.apache.poi.hpsf.littleendian.*;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hpsf.wellknown.*;
/**
* <p>Represents a section in a {@link PropertySet}.</p>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner allUpIn sc.edu)
* Represents a section in a {@link PropertySet}.</p>
*
* @version $Id$
* @since 2002-02-09
*@author Rainer Klute (klute@rainer-klute.de)
*@author Drew Varner (Drew.Varner allUpIn sc.edu)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public class Section
{
public class Section {
/**
* <p>Maps property IDs to section-private PID strings. These
* strings can be found in the property with ID 0.</p>
* <p>
*
* Maps property IDs to section-private PID strings. These strings can be
* found in the property with ID 0.</p>
*/
protected Map dictionary;
private ClassID formatID;
/**
* <p>Returns the format ID. The format ID is the "type" of the
* section.</p>
* <p>
*
* Returns the format ID. The format ID is the "type" of the section.</p>
*
*@return The formatID value
*/
public ClassID getFormatID()
{
public ClassID getFormatID() {
return formatID;
}
private int offset;
private long offset;
/**
* <p>Returns the offset of the section in the stream.</p>
* <p>
*
* Returns the offset of the section in the stream.</p>
*
*@return The offset value
*/
public int getOffset()
{
public int getOffset() {
return offset;
}
@ -105,11 +113,15 @@ public class Section
private int size;
/**
* <p>Returns the section's size in bytes.</p>
* <p>
*
* Returns the section's size in bytes.</p>
*
*@return The size value
*/
public int getSize()
{
public int getSize() {
return size;
}
@ -117,11 +129,15 @@ public class Section
private int propertyCount;
/**
* <p>Returns the number of properties in this section.</p>
* <p>
*
* Returns the number of properties in this section.</p>
*
*@return The propertyCount value
*/
public int getPropertyCount()
{
public int getPropertyCount() {
return propertyCount;
}
@ -129,86 +145,113 @@ public class Section
private Property[] properties;
/**
* <p>Returns this section's properties.</p>
* <p>
*
* Returns this section's properties.</p>
*
*@return The properties value
*/
public Property[] getProperties()
{
public Property[] getProperties() {
return properties;
}
/**
* <p>Creates a {@link Section} instance from a byte array.</p>
* <p>
*
* @param src Contains the complete property set stream.
* Creates a {@link Section} instance from a byte array.</p>
*
* @param offset The position in the stream that points to the
* section's format ID.
*@param src Contains the complete property set stream.
*@param offset The position in the stream that points to the section's
* format ID.
*/
public Section(final byte[] src, int offset)
{
/* Read the format ID. */
public Section(final byte[] src, int offset) {
/*
* Read the format ID.
*/
formatID = new ClassID(src, offset);
offset += ClassID.LENGTH;
/* Read the offset from the stream's start and positions to
* the section header. */
this.offset = new DWord(src, offset).intValue();
offset = this.offset;
/*
* Read the offset from the stream's start and positions to
* the section header.
*/
this.offset = LittleEndian.getUInt(src, offset);
offset = (int)this.offset;
/* Read the section length. */
size = new DWord(src, offset).intValue();
offset += DWord.LENGTH;
/*
* Read the section length.
*/
size = (int)LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
/* Read the number of properties. */
propertyCount = new DWord(src, offset).intValue();
offset += DWord.LENGTH;
/*
* Read the number of properties.
*/
propertyCount = (int)LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
/* Read the properties. The offset is positioned at the first
* entry of the property list. */
/*
* Read the properties. The offset is positioned at the first
* entry of the property list.
*/
properties = new Property[propertyCount];
for (int i = 0; i < properties.length; i++)
{
final int id = new DWord(src, offset).intValue();
offset += DWord.LENGTH;
for (int i = 0; i < properties.length; i++) {
final int id = (int)LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
/* Offset from the section. */
final int sOffset = new DWord(src, offset).intValue();
offset += DWord.LENGTH;
/*
* Offset from the section.
*/
final int sOffset = (int)LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
/* Calculate the length of the property. */
/*
* Calculate the length of the property.
*/
int length;
if (i == properties.length - 1)
length = src.length - this.offset - sOffset;
else
length =
new DWord(src, offset + DWord.LENGTH).intValue() - sOffset;
if (i == properties.length - 1) {
length = (int)(src.length - this.offset - sOffset);
} else {
length = (int)
LittleEndian.getUInt(src, offset + LittleEndian.INT_SIZE) - sOffset;
}
/* Create it. */
/*
* Create it.
*/
properties[i] =
new Property(id, src, this.offset + sOffset, length);
new Property(id, src, this.offset + sOffset, length);
}
/* Extract the dictionary (if available). */
/*
* Extract the dictionary (if available).
*/
dictionary = (Map) getProperty(0);
}
/**
* <p>Returns the value of the property with the specified ID. If
* the property is not available, <code>null</code> is returned
* and a subsequent call to {@link #wasNull} will return
* <code>true</code>.</p>
* <p>
*
* Returns the value of the property with the specified ID. If the property
* is not available, <code>null</code> is returned and a subsequent call to
* {@link #wasNull} will return <code>true</code>.</p>
*
*@param id Description of the Parameter
*@return The property value
*/
protected Object getProperty(final int id)
{
protected Object getProperty(final int id) {
wasNull = false;
for (int i = 0; i < properties.length; i++)
if (id == properties[i].getID())
for (int i = 0; i < properties.length; i++) {
if (id == properties[i].getID()) {
return properties[i].getValue();
}
}
wasNull = true;
return null;
}
@ -216,78 +259,94 @@ public class Section
/**
* <p>Returns the value of the numeric property with the specified
* ID. If the property is not available, 0 is returned. A
* subsequent call to {@link #wasNull} will return
* <code>true</code> to let the caller distinguish that case from
* a real property value of 0.</p>
* <p>
*
* Returns the value of the numeric property with the specified ID. If the
* property is not available, 0 is returned. A subsequent call to {@link
* #wasNull} will return <code>true</code> to let the caller distinguish
* that case from a real property value of 0.</p>
*
*@param id Description of the Parameter
*@return The propertyIntValue value
*/
protected int getPropertyIntValue(final int id)
{
protected int getPropertyIntValue(final int id) {
final Integer i = (Integer) getProperty(id);
if (i != null)
if (i != null) {
return i.intValue();
else
} else {
return 0;
}
}
/**
* <p>Returns the value of the boolean property with the specified
* ID. If the property is not available, <code>false</code> is
* returned. A subsequent call to {@link #wasNull} will return
* <code>true</code> to let the caller distinguish that case from
* a real property value of <code>false</code>.</p>
* <p>
*
* Returns the value of the boolean property with the specified ID. If the
* property is not available, <code>false</code> is returned. A subsequent
* call to {@link #wasNull} will return <code>true</code> to let the caller
* distinguish that case from a real property value of <code>false</code>.
* </p>
*
*@param id Description of the Parameter
*@return The propertyBooleanValue value
*/
protected boolean getPropertyBooleanValue(final int id)
{
protected boolean getPropertyBooleanValue(final int id) {
final Boolean b = (Boolean) getProperty(id);
if (b != null)
if (b != null) {
return b.booleanValue();
else
} else {
return false;
}
}
private boolean wasNull;
/**
* <p>Checks whether the property which the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access
* was available or not. This information might be important for
* callers of {@link #getPropertyIntValue} since the latter
* returns 0 if the property does not exist. Using {@link
* #wasNull} the caller can distiguish this case from a property's
* real value of 0.</p>
* <p>
*
* @return <code>true</code> if the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access a
* property that was not available, else <code>false</code>.
* Checks whether the property which the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access was
* available or not. This information might be important for callers of
* {@link #getPropertyIntValue} since the latter returns 0 if the property
* does not exist. Using {@link #wasNull} the caller can distiguish this
* case from a property's real value of 0.</p>
*
*@return <code>true</code> if the last call to {@link
* #getPropertyIntValue} or {@link #getProperty} tried to access a
* property that was not available, else <code>false</code>.
*/
public boolean wasNull()
{
public boolean wasNull() {
return wasNull;
}
/**
* <p>Returns the PID string associated with a property ID. The ID
* is first looked up in the {@link Section}'s private
* dictionary. If it is not found there, the method calls {@link
* SectionIDMap#getPIDString}.</p>
* <p>
*
* Returns the PID string associated with a property ID. The ID is first
* looked up in the {@link Section}'s private dictionary. If it is not
* found there, the method calls {@link SectionIDMap#getPIDString}.</p>
*
*@param pid Description of the Parameter
*@return The pIDString value
*/
public String getPIDString(final int pid)
{
public String getPIDString(final int pid) {
String s = null;
if (dictionary != null)
if (dictionary != null) {
s = (String) dictionary.get(new Integer(pid));
if (s == null)
s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid);
if (s == null)
}
if (s == null) {
s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid);
}
if (s == null) {
s = SectionIDMap.UNDEFINED;
}
return s;
}

View File

@ -1,164 +1,205 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import java.util.*;
import org.apache.poi.hpsf.littleendian.*;
/**
* <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>
* Abstract superclass for the convenience classes {@link SummaryInformation}
* and {@link DocumentSummaryInformation}.</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>
* 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>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* 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)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public abstract class SpecialPropertySet extends PropertySet
{
public abstract class SpecialPropertySet extends PropertySet {
private PropertySet delegate;
public SpecialPropertySet(PropertySet ps)
{
/**
* Constructor for the SpecialPropertySet object
*
*@param ps Description of the Parameter
*/
public SpecialPropertySet(PropertySet ps) {
delegate = ps;
}
public Word getByteOrder()
{
/**
* Gets the byteOrder attribute of the SpecialPropertySet object
*
*@return The byteOrder value
*/
public Word getByteOrder() {
return delegate.getByteOrder();
}
public Word getFormat()
{
/**
* Gets the format attribute of the SpecialPropertySet object
*
*@return The format value
*/
public Word getFormat() {
return delegate.getFormat();
}
public DWord getOSVersion()
{
/**
* Gets the oSVersion attribute of the SpecialPropertySet object
*
*@return The oSVersion value
*/
public DWord getOSVersion() {
return delegate.getOSVersion();
}
public ClassID getClassID()
{
/**
* Gets the classID attribute of the SpecialPropertySet object
*
*@return The classID value
*/
public ClassID getClassID() {
return delegate.getClassID();
}
public int getSectionCount()
{
/**
* Gets the sectionCount attribute of the SpecialPropertySet object
*
*@return The sectionCount value
*/
public int getSectionCount() {
return delegate.getSectionCount();
}
public List getSections()
{
/**
* Gets the sections attribute of the SpecialPropertySet object
*
*@return The sections value
*/
public List getSections() {
return delegate.getSections();
}
public boolean isSummaryInformation()
{
/**
* Gets the summaryInformation attribute of the SpecialPropertySet object
*
*@return The summaryInformation value
*/
public boolean isSummaryInformation() {
return delegate.isSummaryInformation();
}
public boolean isDocumentSummaryInformation()
{
/**
* Gets the documentSummaryInformation attribute of the SpecialPropertySet
* object
*
*@return The documentSummaryInformation value
*/
public boolean isDocumentSummaryInformation() {
return delegate.isDocumentSummaryInformation();
}
public Section getSingleSection()
{
/**
* Gets the singleSection attribute of the SpecialPropertySet object
*
*@return The singleSection value
*/
public Section getSingleSection() {
return delegate.getSingleSection();
}

View File

@ -1,61 +1,61 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.hpsf;
import java.io.*;
@ -63,256 +63,311 @@ import java.util.*;
import org.apache.poi.hpsf.wellknown.*;
/**
* <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.
* Convenience class representing a Summary Information stream in a Microsoft
* Office document.</p> <p>
*
* @see DocumentSummaryInformation
* 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)
* @version $Id$
* @since 2002-02-09
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@see DocumentSummaryInformation
*@version $Id$
*@since 2002-02-09
*/
public class SummaryInformation extends SpecialPropertySet
{
public class SummaryInformation extends SpecialPropertySet {
/**
* <p>Creates a {@link SummaryInformation} from a given {@link
* PropertySet}.</p>
* <p>
*
* @param ps A property set which should be created from a summary
* information stream.
* Creates a {@link SummaryInformation} from a given {@link PropertySet}.
* </p>
*
* @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.
*@exception UnexpectedPropertySetTypeException Description of the
* Exception
*@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>Returns the stream's title (or <code>null</code>).</p>
* <p>
*
* Returns the stream's title (or <code>null</code>).</p>
*
*@return The title value
*/
public String getTitle()
{
public String getTitle() {
return (String) getProperty(PropertyIDMap.PID_TITLE);
}
/**
* <p>Returns the stream's subject (or <code>null</code>).</p>
* <p>
*
* Returns the stream's subject (or <code>null</code>).</p>
*
*@return The subject value
*/
public String getSubject()
{
public String getSubject() {
return (String) getProperty(PropertyIDMap.PID_SUBJECT);
}
/**
* <p>Returns the stream's author (or <code>null</code>).</p>
* <p>
*
* Returns the stream's author (or <code>null</code>).</p>
*
*@return The author value
*/
public String getAuthor()
{
public String getAuthor() {
return (String) getProperty(PropertyIDMap.PID_AUTHOR);
}
/**
* <p>Returns the stream's keywords (or <code>null</code>).</p>
* <p>
*
* Returns the stream's keywords (or <code>null</code>).</p>
*
*@return The keywords value
*/
public String getKeywords()
{
public String getKeywords() {
return (String) getProperty(PropertyIDMap.PID_KEYWORDS);
}
/**
* <p>Returns the stream's comments (or <code>null</code>).</p>
* <p>
*
* Returns the stream's comments (or <code>null</code>).</p>
*
*@return The comments value
*/
public String getComments()
{
public String getComments() {
return (String) getProperty(PropertyIDMap.PID_COMMENTS);
}
/**
* <p>Returns the stream's template (or <code>null</code>).</p>
* <p>
*
* Returns the stream's template (or <code>null</code>).</p>
*
*@return The template value
*/
public String getTemplate()
{
public String getTemplate() {
return (String) getProperty(PropertyIDMap.PID_TEMPLATE);
}
/**
* <p>Returns the stream's last author (or <code>null</code>).</p>
* <p>
*
* Returns the stream's last author (or <code>null</code>).</p>
*
*@return The lastAuthor value
*/
public String getLastAuthor()
{
public String getLastAuthor() {
return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR);
}
/**
* <p>Returns the stream's revision number (or
* <code>null</code>).
</p> */
public String getRevNumber()
{
* <p>
*
* Returns the stream's revision number (or <code>null</code>). </p>
*
*@return The revNumber value
*/
public String getRevNumber() {
return (String) getProperty(PropertyIDMap.PID_REVNUMBER);
}
/**
* <p>Returns the stream's edit time (or <code>null</code>).</p>
* <p>
*
* Returns the stream's edit time (or <code>null</code>).</p>
*
*@return The editTime value
*/
public Date getEditTime()
{
public Date getEditTime() {
return (Date) getProperty(PropertyIDMap.PID_EDITTIME);
}
/**
* <p>Returns the stream's last printed time (or
* <code>null</code>).</p>
* <p>
*
* Returns the stream's last printed time (or <code>null</code>).</p>
*
*@return The lastPrinted value
*/
public Date getLastPrinted()
{
public Date getLastPrinted() {
return (Date) getProperty(PropertyIDMap.PID_LASTPRINTED);
}
/**
* <p>Returns the stream's creation time (or
* <code>null</code>).</p>
* <p>
*
* Returns the stream's creation time (or <code>null</code>).</p>
*
*@return The createDateTime value
*/
public Date getCreateDateTime()
{
public Date getCreateDateTime() {
return (Date) getProperty(PropertyIDMap.PID_CREATE_DTM);
}
/**
* <p>Returns the stream's last save time (or
* <code>null</code>).</p>
* <p>
*
* Returns the stream's last save time (or <code>null</code>).</p>
*
*@return The lastSaveDateTime value
*/
public Date getLastSaveDateTime()
{
public Date getLastSaveDateTime() {
return (Date) getProperty(PropertyIDMap.PID_LASTSAVE_DTM);
}
/**
* <p>Returns the stream's page count or 0 if the {@link
* SummaryInformation} does not contain a page count.</p>
* <p>
*
* Returns the stream's page count or 0 if the {@link SummaryInformation}
* does not contain a page count.</p>
*
*@return The pageCount value
*/
public int getPageCount()
{
public int getPageCount() {
return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT);
}
/**
* <p>Returns the stream's word count or 0 if the {@link
* SummaryInformation} does not contain a word count.</p>
* <p>
*
* Returns the stream's word count or 0 if the {@link SummaryInformation}
* does not contain a word count.</p>
*
*@return The wordCount value
*/
public int getWordCount()
{
public int getWordCount() {
return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT);
}
/**
* <p>Returns the stream's char count or 0 if the {@link
* SummaryInformation} does not contain a char count.</p>
* <p>
*
* Returns the stream's char count or 0 if the {@link SummaryInformation}
* does not contain a char count.</p>
*
*@return The charCount value
*/
public int getCharCount()
{
public int getCharCount() {
return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);
}
/**
* <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>
* 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>
*
* <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
*/
public byte[] getThumbnail()
{
public byte[] getThumbnail() {
return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL);
}
/**
* <p>Returns the stream's application name (or
* <code>null</code>).</p>
* <p>
*
* Returns the stream's application name (or <code>null</code>).</p>
*
*@return The applicationName value
*/
public String getApplicationName()
{
public String getApplicationName() {
return (String) getProperty(PropertyIDMap.PID_APPNAME);
}
/**
* <p>Returns one of the following values:</p>
* <p>
*
* <ul>
* Returns one of the following values:</p>
* <ul>
* <li> <p>
*
* <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
*/
public int getSecurity()
{
public int getSecurity() {
return getPropertyIntValue(PropertyIDMap.PID_SECURITY);
}

View File

@ -1,247 +1,248 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import org.apache.poi.hpsf.littleendian.DWord;
/**
* <p>Class to manipulate data in the Clipboard Variant
* ({@link Variant#VT_CF VT_CF}) format.</p>
* <p>
*
* @see SummaryInformation#getThumbnail()
* Class to manipulate data in the Clipboard Variant ({@link Variant#VT_CF
* VT_CF}) format.</p>
*
* @author Drew Varner (Drew.Varner inOrAround sc.edu)
* @version $Id$
* @since 2002-04-29
*@author Drew Varner (Drew.Varner inOrAround sc.edu)
*@created May 10, 2002
*@see SummaryInformation#getThumbnail()
*@version $Id$
*@since 2002-04-29
*/
public class Thumbnail
{
public class Thumbnail {
/**
* <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>Offset in bytes where the Clipboard Format
* starts in the <code>byte[]</code> returned by
* {@link SummaryInformation#getThumbnail()}</p>
* <p>
*
* <p>This is only valid if the Clipboard Format Tag
* is {@link #CFTAG_WINDOWS} </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>
*/
public static int OFFSET_CF = 8;
/**
* <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>
* Offset in bytes where the Windows Metafile (WMF) image data starts in
* the <code>byte[]</code> returned by {@link
* SummaryInformation#getThumbnail()}</p> <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>
* 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>
*/
public static int OFFSET_WMFDATA = 20;
/**
* <p>Clipboard Format Tag - Windows clipboard format</p>
* <p>A <code>DWORD</code> indicating a built-in Windows clipboard
* format value</p>
* <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>
* Clipboard Format Tag - Windows clipboard format</p> <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>
*/
public static int CFTAG_WINDOWS = -1;
/**
* <p>Clipboard Format Tag - Macintosh clipboard format</p>
* <p>A <code>DWORD</code> indicating a Macintosh clipboard format value</p>
* <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>
* Clipboard Format Tag - Macintosh clipboard format</p> <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>
*/
public static int CFTAG_MACINTOSH = -2;
/**
* <p>Clipboard Format Tag - Format ID</p>
* <p>A GUID containing a format identifier (FMTID). This is rarely used.</p>
* <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>
* Clipboard Format Tag - Format ID</p> <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>
*/
public static int CFTAG_FMTID = -3;
/**
* <p>Clipboard Format Tag - No Data</p>
* <p>a <code>DWORD</code> indicating No data. This is rarely used.</p>
* <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>
* Clipboard Format Tag - No Data</p> <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>
*/
public static int CFTAG_NODATA = 0;
/**
* <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>
*
* 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>
*/
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>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>
*
* 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>
*/
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 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>
* <p>
*
* </p>
*
*@param thumbnailData Description of the Parameter
*/
public Thumbnail(byte[] thumbnailData)
{
public Thumbnail(byte[] thumbnailData) {
this.thumbnailData = thumbnailData;
}
/**
* <p>Returns the thumbnail as a <code>byte[]</code> in
* {@link Variant#VT_CF VT_CF} format.</p>
* <p>
*
* @see SummaryInformation#getThumbnail()
* Returns the thumbnail as a <code>byte[]</code> in {@link Variant#VT_CF
* VT_CF} format.</p>
*
*@return The thumbnail value
*@see SummaryInformation#getThumbnail()
*/
public byte[] getThumbnail() {
return thumbnailData;
@ -250,10 +251,13 @@ public class Thumbnail
/**
* <p>Sets the Thumbnail's underlying <code>byte[]</code> in
* {@link Variant#VT_CF VT_CF} format.</p>
* <p>
*
* @see SummaryInformation#getThumbnail()
* 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()
*/
public void setThumbnail(byte[] thumbnail) {
this.thumbnailData = thumbnail;
@ -262,106 +266,97 @@ public class Thumbnail
/**
* <p>Returns an <code>int</code> representing the Clipboard
* Format Tag</p>
* <p>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>
* <p>
*
* @return a flag indicating the Clipboard Format Tag
* Returns an <code>int</code> representing the Clipboard Format Tag</p>
* <p>
*
* 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
*/
public int getClipboardFormatTag()
{
DWord clipboardFormatTag = new DWord(getThumbnail(),OFFSET_CFTAG);
public int getClipboardFormatTag() {
DWord clipboardFormatTag = new DWord(getThumbnail(), OFFSET_CFTAG);
return clipboardFormatTag.intValue();
}
/**
* <p>Returns an <code>int</code> representing the Clipboard
* Format</p>
* <p>
*
* <p>Will throw an exceptionif the Thumbnail's Clipboard
* Format Tag is not
* {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS}
* </p>
* Returns an <code>int</code> representing the Clipboard Format</p> <p>
*
* <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>
* Will throw an exceptionif the Thumbnail's Clipboard Format Tag is not
* {@link Thumbnail#CFTAG_WINDOWS CFTAG_WINDOWS} </p> <p>
*
* @return a flag indicating the Clipboard Format
*
* @throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS
* 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>
*
*@return a flag indicating the Clipboard Format
*@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS
*/
public int getClipboardFormat() throws HPSFException
{
if ( !(getClipboardFormatTag() == CFTAG_WINDOWS) )
{
public int getClipboardFormat() throws HPSFException {
if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) {
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS.");
"be CFTAG_WINDOWS.");
}
DWord clipboardFormat = new DWord(getThumbnail(),OFFSET_CF);
DWord clipboardFormat = new DWord(getThumbnail(), OFFSET_CF);
return clipboardFormat.intValue();
}
/**
* <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>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>
*
* @throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS
* and CF_METAFILEPICT
* 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
*@return a WMF image of the Thumbnail
*@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS and
* CF_METAFILEPICT
*/
public byte[] getThumbnailAsWMF() throws HPSFException
{
if ( !(getClipboardFormatTag() == CFTAG_WINDOWS) )
{
public byte[] getThumbnailAsWMF() throws HPSFException {
if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) {
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS.");
"be CFTAG_WINDOWS.");
}
if ( !(getClipboardFormat() == CF_METAFILEPICT) )
{
if (!(getClipboardFormat() == CF_METAFILEPICT)) {
throw new HPSFException("Clipboard Format of Thumbnail must " +
"be CF_METAFILEPICT.");
}
else
{
"be CF_METAFILEPICT.");
} else {
byte[] thumbnail = getThumbnail();
int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
byte[] wmfImage = new byte[wmfImageLength];
System.arraycopy(thumbnail,
OFFSET_WMFDATA,
wmfImage,
0,
wmfImageLength);
OFFSET_WMFDATA,
wmfImage,
0,
wmfImageLength);
return wmfImage;
}
}

View File

@ -1,92 +1,113 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <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>
* 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>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* The constructors of this class are analogous to those of its superclass and
* documented there.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id: UnexpectedPropertySetTypeException.java,v 1.3 2002/05/01
* 09:31:52 klute Exp $
*@since 2002-02-09
*/
public class UnexpectedPropertySetTypeException extends HPSFException
{
public class UnexpectedPropertySetTypeException extends HPSFException {
public UnexpectedPropertySetTypeException()
{
/**
* Constructor for the UnexpectedPropertySetTypeException object
*/
public UnexpectedPropertySetTypeException() {
super();
}
public UnexpectedPropertySetTypeException(final String msg)
{
/**
* Constructor for the UnexpectedPropertySetTypeException object
*
*@param msg Description of the Parameter
*/
public UnexpectedPropertySetTypeException(final String msg) {
super(msg);
}
public UnexpectedPropertySetTypeException(final Throwable reason)
{
/**
* Constructor for the UnexpectedPropertySetTypeException object
*
*@param reason Description of the Parameter
*/
public UnexpectedPropertySetTypeException(final Throwable reason) {
super(reason);
}
/**
* Constructor for the UnexpectedPropertySetTypeException object
*
*@param msg Description of the Parameter
*@param reason Description of the Parameter
*/
public UnexpectedPropertySetTypeException(final String msg,
final Throwable reason)
{
final Throwable reason) {
super(msg, reason);
}

View File

@ -1,148 +1,168 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
import java.util.*;
/**
* <p>Provides various static utility methods.</p>
* <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* Provides various static utility methods.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public class Util
{
public class Util {
/**
* <p>Checks whether two byte arrays <var>a</var> and <var>b</var>
* are equal. They are equal</p>
* <p>
*
* <ul>
* <li><p>if they have the same length and</p></li>
* Checks whether two byte arrays <var>a</var> and <var>b</var> are equal.
* They are equal</p>
* <ul>
* <li> <p>
*
* <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>
* if they have the same length and</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>
*
*
*@param a Description of the Parameter
*@param b Description of the Parameter
*@return Description of the Return Value
*/
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;
}
/**
* <p>Copies a part of a byte array into another byte array.</p>
* <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
*/
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>Concatenates the contents of several byte arrays into a
* single one.</p>
* <p>
*
* @param byteArrays The byte arrays to be concatened.
* Concatenates the contents of several byte arrays into a single one.</p>
*
* @return A new byte array containing the concatenated byte
* arrays.
*@param byteArrays The byte arrays to be concatened.
*@return A new byte array containing the concatenated byte
* arrays.
*/
public static byte[] cat(final byte[][] byteArrays)
{
public static byte[] cat(final byte[][] byteArrays) {
int capacity = 0;
for (int i = 0; i < byteArrays.length; i++)
for (int i = 0; i < byteArrays.length; i++) {
capacity += byteArrays[i].length;
}
final byte[] result = new byte[capacity];
int r = 0;
for (int i = 0; i < byteArrays.length; i++)
for (int j = 0; j < byteArrays[i].length; j++)
for (int i = 0; i < byteArrays.length; i++) {
for (int j = 0; j < byteArrays[i].length; j++) {
result[r++] = byteArrays[i][j];
}
}
return result;
}
/**
* <p>Copies bytes from a source byte array into a new byte
* array.</p>
* <p>
*
* @param src Copy from this byte array.
* Copies bytes from a source byte array into a new byte array.</p>
*
* @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;
@ -151,29 +171,31 @@ 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>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>
* <p>
*
* @param high The higher double word of the FILETIME structure.
* Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME
* structure holds a date and time associated with a file. The structure
* identifies a 64-bit integer specifying the number of 100-nanosecond
* intervals which have passed since January 1, 1601. This 64-bit value is
* split into the two double word stored in the structure.</p>
*
* @param low The lower double word of the FILETIME structure.
*@param high The higher double word of the FILETIME structure.
*@param low The lower double word of the FILETIME structure.
*@return Description of the Return Value
*/
public static Date filetimeToDate(final int high, final int low)
{
public static Date filetimeToDate(final int high, final int low) {
final long filetime = ((long) high) << 32 | ((long) low);
final long ms_since_16010101 = filetime / (1000 * 10);
final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF;

View File

@ -1,362 +1,443 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf;
/**
* <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>
* 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>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* 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)
*@created May 10, 2002
*@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] A Class ID.</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>
* <p>
*
* <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] A Class ID.</p> <p>
*
* <p>
* <pre>typedef struct tagCLIPDATA {
* 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>
*
* 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>
*
* <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> 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;
}

View File

@ -1,230 +1,346 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf.wellknown;
import java.util.*;
/**
* <p>This is a dictionary mapping property IDs to property ID
* strings.</p>
* <p>
*
* <p>The methods {@link #getSummaryInformationProperties} and {@link
* #getDocumentSummaryInformationProperties} return singleton {@link
* PropertyIDMap}s. An application that wants to extend these maps
* should treat them as unmodifiable, copy them and modifiy the
* copies.</p>
* This is a dictionary mapping property IDs to property ID strings.</p> <p>
*
* <p><strong>FIXME:</strong> Make the singletons
* unmodifiable. However, since this requires use a {@link HashMap}
* delegate instead of extending {@link HashMap} and would require a
* lot of stupid typing, I won't do it for the time being.</p>
* The methods {@link #getSummaryInformationProperties} and {@link
* #getDocumentSummaryInformationProperties} return singleton {@link
* PropertyIDMap}s. An application that wants to extend these maps should treat
* them as unmodifiable, copy them and modifiy the copies.</p> <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* <strong>FIXME:</strong> Make the singletons unmodifiable. However, since
* this requires use a {@link HashMap} delegate instead of extending {@link
* HashMap} and would require a lot of stupid typing, I won't do it for the
* time being.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public class PropertyIDMap extends HashMap
{
public class PropertyIDMap extends HashMap {
/* The following definitions are for the Summary Information. */
public static final int PID_TITLE = 2;
public static final int PID_SUBJECT = 3;
public static final int PID_AUTHOR = 4;
public static final int PID_KEYWORDS = 5;
public static final int PID_COMMENTS = 6;
public static final int PID_TEMPLATE = 7;
public static final int PID_LASTAUTHOR = 8;
public static final int PID_REVNUMBER = 9;
public static final int PID_EDITTIME = 10;
public static final int PID_LASTPRINTED = 11;
public static final int PID_CREATE_DTM = 12;
public static final int PID_LASTSAVE_DTM = 13;
public static final int PID_PAGECOUNT = 14;
public static final int PID_WORDCOUNT = 15;
public static final int PID_CHARCOUNT = 16;
public static final int PID_THUMBNAIL = 17;
public static final int PID_APPNAME = 18;
public static final int PID_SECURITY = 19;
/*
* The following definitions are for the Summary Information.
*/
/**
* Description of the Field
*/
public final static int PID_TITLE = 2;
/**
* Description of the Field
*/
public final static int PID_SUBJECT = 3;
/**
* Description of the Field
*/
public final static int PID_AUTHOR = 4;
/**
* Description of the Field
*/
public final static int PID_KEYWORDS = 5;
/**
* Description of the Field
*/
public final static int PID_COMMENTS = 6;
/**
* Description of the Field
*/
public final static int PID_TEMPLATE = 7;
/**
* Description of the Field
*/
public final static int PID_LASTAUTHOR = 8;
/**
* Description of the Field
*/
public final static int PID_REVNUMBER = 9;
/**
* Description of the Field
*/
public final static int PID_EDITTIME = 10;
/**
* Description of the Field
*/
public final static int PID_LASTPRINTED = 11;
/**
* Description of the Field
*/
public final static int PID_CREATE_DTM = 12;
/**
* Description of the Field
*/
public final static int PID_LASTSAVE_DTM = 13;
/**
* Description of the Field
*/
public final static int PID_PAGECOUNT = 14;
/**
* Description of the Field
*/
public final static int PID_WORDCOUNT = 15;
/**
* Description of the Field
*/
public final static int PID_CHARCOUNT = 16;
/**
* Description of the Field
*/
public final static int PID_THUMBNAIL = 17;
/**
* Description of the Field
*/
public final static int PID_APPNAME = 18;
/**
* Description of the Field
*/
public final static int PID_SECURITY = 19;
/* The following definitions are for the Document Summary Information. */
public static final int PID_CATEGORY = 2;
public static final int PID_PRESFORMAT = 3;
public static final int PID_BYTECOUNT = 4;
public static final int PID_LINECOUNT = 5;
public static final int PID_PARCOUNT = 6;
public static final int PID_SLIDECOUNT = 7;
public static final int PID_NOTECOUNT = 8;
public static final int PID_HIDDENCOUNT = 9;
public static final int PID_MMCLIPCOUNT = 10;
public static final int PID_SCALE = 11;
public static final int PID_HEADINGPAIR = 12;
public static final int PID_DOCPARTS = 13;
public static final int PID_MANAGER = 14;
public static final int PID_COMPANY = 15;
public static final int PID_LINKSDIRTY = 16;
/*
* The following definitions are for the Document Summary Information.
*/
/**
* Description of the Field
*/
public final static int PID_CATEGORY = 2;
/**
* Description of the Field
*/
public final static int PID_PRESFORMAT = 3;
/**
* Description of the Field
*/
public final static int PID_BYTECOUNT = 4;
/**
* Description of the Field
*/
public final static int PID_LINECOUNT = 5;
/**
* Description of the Field
*/
public final static int PID_PARCOUNT = 6;
/**
* Description of the Field
*/
public final static int PID_SLIDECOUNT = 7;
/**
* Description of the Field
*/
public final static int PID_NOTECOUNT = 8;
/**
* Description of the Field
*/
public final static int PID_HIDDENCOUNT = 9;
/**
* Description of the Field
*/
public final static int PID_MMCLIPCOUNT = 10;
/**
* Description of the Field
*/
public final static int PID_SCALE = 11;
/**
* Description of the Field
*/
public final static int PID_HEADINGPAIR = 12;
/**
* Description of the Field
*/
public final static int PID_DOCPARTS = 13;
/**
* Description of the Field
*/
public final static int PID_MANAGER = 14;
/**
* Description of the Field
*/
public final static int PID_COMPANY = 15;
/**
* Description of the Field
*/
public final static int PID_LINKSDIRTY = 16;
private static PropertyIDMap summaryInformationProperties;
private static PropertyIDMap documentSummaryInformationProperties;
public PropertyIDMap(int initialCapacity, float loadFactor)
{
super(initialCapacity, loadFactor);
}
/**
* <p>Puts a ID string for an ID into the {@link
* PropertyIDMap}.</p>
* Constructor for the PropertyIDMap object
*
* @param id The ID.
*@param initialCapacity Description of the Parameter
*@param loadFactor Description of the Parameter
*/
public PropertyIDMap(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
}
/**
* <p>
*
* @param idString The ID string.
*/
public Object put(int id, String idString)
{
return put(new Integer(id), idString);
}
/**
* <p>Gets the ID string for an ID from the {@link
* PropertyIDMap}.</p>
* Puts a ID string for an ID into the {@link PropertyIDMap}.</p>
*
* @param id The ID.
*@param id The ID.
*@param idString The ID string.
*@return Description of the Return Value
*/
public Object get(int id)
{
return get(new Integer(id));
public Object put(int id, String idString) {
return put(new Integer(id), idString);
}
/**
* <p>Returns the Summary Information properties singleton.</p>
* <p>
*
* Gets the ID string for an ID from the {@link PropertyIDMap}.</p>
*
*@param id The ID.
*@return Description of the Return Value
*/
public static PropertyIDMap getSummaryInformationProperties()
{
if (summaryInformationProperties == null)
{
PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
m.put(PID_TITLE, "PID_TITLE");
m.put(PID_SUBJECT, "PID_SUBJECT");
m.put(PID_AUTHOR, "PID_AUTHOR");
m.put(PID_KEYWORDS, "PID_KEYWORDS");
m.put(PID_COMMENTS, "PID_COMMENTS");
m.put(PID_TEMPLATE, "PID_TEMPLATE");
m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR");
m.put(PID_REVNUMBER, "PID_REVNUMBER");
m.put(PID_EDITTIME, "PID_EDITTIME");
m.put(PID_LASTPRINTED, "PID_LASTPRINTED");
m.put(PID_CREATE_DTM, "PID_CREATE_DTM");
m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM");
m.put(PID_PAGECOUNT, "PID_PAGECOUNT");
m.put(PID_WORDCOUNT, "PID_WORDCOUNT");
m.put(PID_CHARCOUNT, "PID_CHARCOUNT");
m.put(PID_THUMBNAIL, "PID_THUMBNAIL");
m.put(PID_APPNAME, "PID_APPNAME");
m.put(PID_SECURITY, "PID_SECURITY");
summaryInformationProperties = m;
}
return summaryInformationProperties;
public Object get(int id) {
return get(new Integer(id));
}
/**
* <p>Returns the Summary Information properties singleton.</p>
* <p>
*
* Returns the Summary Information properties singleton.</p>
*
*@return The summaryInformationProperties value
*/
public static PropertyIDMap getDocumentSummaryInformationProperties()
{
if (documentSummaryInformationProperties == null)
{
PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
m.put(PID_CATEGORY, "PID_CATEGORY");
m.put(PID_PRESFORMAT, "PID_PRESFORMAT");
m.put(PID_BYTECOUNT, "PID_BYTECOUNT");
m.put(PID_LINECOUNT, "PID_LINECOUNT");
m.put(PID_PARCOUNT, "PID_PARCOUNT");
m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT");
m.put(PID_NOTECOUNT, "PID_NOTECOUNT");
m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT");
m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT");
m.put(PID_SCALE, "PID_SCALE");
m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR");
m.put(PID_DOCPARTS, "PID_DOCPARTS");
m.put(PID_MANAGER, "PID_MANAGER");
m.put(PID_COMPANY, "PID_COMPANY");
m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY");
documentSummaryInformationProperties = m;
}
return documentSummaryInformationProperties;
public static PropertyIDMap getSummaryInformationProperties() {
if (summaryInformationProperties == null) {
PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
m.put(PID_TITLE, "PID_TITLE");
m.put(PID_SUBJECT, "PID_SUBJECT");
m.put(PID_AUTHOR, "PID_AUTHOR");
m.put(PID_KEYWORDS, "PID_KEYWORDS");
m.put(PID_COMMENTS, "PID_COMMENTS");
m.put(PID_TEMPLATE, "PID_TEMPLATE");
m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR");
m.put(PID_REVNUMBER, "PID_REVNUMBER");
m.put(PID_EDITTIME, "PID_EDITTIME");
m.put(PID_LASTPRINTED, "PID_LASTPRINTED");
m.put(PID_CREATE_DTM, "PID_CREATE_DTM");
m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM");
m.put(PID_PAGECOUNT, "PID_PAGECOUNT");
m.put(PID_WORDCOUNT, "PID_WORDCOUNT");
m.put(PID_CHARCOUNT, "PID_CHARCOUNT");
m.put(PID_THUMBNAIL, "PID_THUMBNAIL");
m.put(PID_APPNAME, "PID_APPNAME");
m.put(PID_SECURITY, "PID_SECURITY");
summaryInformationProperties = m;
}
return summaryInformationProperties;
}
public static void main(String args[])
{
PropertyIDMap s1 = getSummaryInformationProperties();
PropertyIDMap s2 = getDocumentSummaryInformationProperties();
System.out.println("s1: " + s1);
System.out.println("s2: " + s2);
/**
* <p>
*
* Returns the Summary Information properties singleton.</p>
*
*@return The documentSummaryInformationProperties value
*/
public static PropertyIDMap getDocumentSummaryInformationProperties() {
if (documentSummaryInformationProperties == null) {
PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
m.put(PID_CATEGORY, "PID_CATEGORY");
m.put(PID_PRESFORMAT, "PID_PRESFORMAT");
m.put(PID_BYTECOUNT, "PID_BYTECOUNT");
m.put(PID_LINECOUNT, "PID_LINECOUNT");
m.put(PID_PARCOUNT, "PID_PARCOUNT");
m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT");
m.put(PID_NOTECOUNT, "PID_NOTECOUNT");
m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT");
m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT");
m.put(PID_SCALE, "PID_SCALE");
m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR");
m.put(PID_DOCPARTS, "PID_DOCPARTS");
m.put(PID_MANAGER, "PID_MANAGER");
m.put(PID_COMPANY, "PID_COMPANY");
m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY");
documentSummaryInformationProperties = m;
}
return documentSummaryInformationProperties;
}
/**
* Description of the Method
*
*@param args Description of the Parameter
*/
public static void main(String args[]) {
PropertyIDMap s1 = getSummaryInformationProperties();
PropertyIDMap s2 = getDocumentSummaryInformationProperties();
System.out.println("s1: " + s1);
System.out.println("s2: " + s2);
}
}

View File

@ -1,124 +1,130 @@
/* ====================================================================
* The Apache Software License, Version 1.1
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hpsf.wellknown;
import java.util.*;
/**
* <p>Maps section format IDs to {@link PropertyIDMap}s. It is
* initialized with two well-known section format IDs: those of the
* <tt>\005SummaryInformation</tt> stream and the
* <tt>\005DocumentSummaryInformation stream.</p>
* <p>
*
* <p>If you have a section format ID you can use it as a key to query
* this map. If you get a {@link PropertyIDMap} returned your section
* is well-known and you can query the {@link PropertyIDMap} for PID
* strings. If you get back <code>null</code> you are on your own.</p>
* Maps section format IDs to {@link PropertyIDMap}s. It is initialized with
* two well-known section format IDs: those of the <tt>\005SummaryInformation
* </tt> stream and the <tt>\005DocumentSummaryInformation stream.</p> <p>
*
* <p>This {@link Map} expects the byte arrays of section format IDs
* as keys. A key maps to a {@link PropertyIDMap} describing the
* property IDs in sections with the specified section format ID.</p>
* If you have a section format ID you can use it as a key to query this map.
* If you get a {@link PropertyIDMap} returned your section is well-known and
* you can query the {@link PropertyIDMap} for PID strings. If you get back
* <code>null</code> you are on your own.</p> <p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-09
* This {@link Map} expects the byte arrays of section format IDs as keys. A
* key maps to a {@link PropertyIDMap} describing the property IDs in sections
* with the specified section format ID.</p>
*
*@author Rainer Klute (klute@rainer-klute.de)
*@created May 10, 2002
*@version $Id$
*@since 2002-02-09
*/
public class SectionIDMap extends HashMap
{
public class SectionIDMap extends HashMap {
/**
* <p>The SummaryInformation's section's format ID.</p>
* <p>
*
* The SummaryInformation's section's format ID.</p>
*/
public final static byte[] SUMMARY_INFORMATION_ID =
new byte[]{(byte) 0xF2, (byte) 0x9F, (byte) 0x85, (byte) 0xE0,
(byte) 0x4F, (byte) 0xF9, (byte) 0x10, (byte) 0x68,
(byte) 0xAB, (byte) 0x91, (byte) 0x08, (byte) 0x00,
(byte) 0x2B, (byte) 0x27, (byte) 0xB3, (byte) 0xD9};
new byte[]{(byte) 0xF2, (byte) 0x9F, (byte) 0x85, (byte) 0xE0,
(byte) 0x4F, (byte) 0xF9, (byte) 0x10, (byte) 0x68,
(byte) 0xAB, (byte) 0x91, (byte) 0x08, (byte) 0x00,
(byte) 0x2B, (byte) 0x27, (byte) 0xB3, (byte) 0xD9};
/**
* <p>The DocumentSummaryInformation's first section's format
* ID. The second section has a different format ID which is not
* well-known.</p>
* <p>
*
* The DocumentSummaryInformation's first section's format ID. The second
* section has a different format ID which is not well-known.</p>
*/
public final static byte[] DOCUMENT_SUMMARY_INFORMATION_ID =
new byte[]{(byte) 0xD5, (byte) 0xCD, (byte) 0xD5, (byte) 0x02,
(byte) 0x2E, (byte) 0x9C, (byte) 0x10, (byte) 0x1B,
(byte) 0x93, (byte) 0x97, (byte) 0x08, (byte) 0x00,
(byte) 0x2B, (byte) 0x2C, (byte) 0xF9, (byte) 0xAE};
new byte[]{(byte) 0xD5, (byte) 0xCD, (byte) 0xD5, (byte) 0x02,
(byte) 0x2E, (byte) 0x9C, (byte) 0x10, (byte) 0x1B,
(byte) 0x93, (byte) 0x97, (byte) 0x08, (byte) 0x00,
(byte) 0x2B, (byte) 0x2C, (byte) 0xF9, (byte) 0xAE};
/**
* Description of the Field
*/
public final static String UNDEFINED = "[undefined]";
private static SectionIDMap defaultMap;
/**
* <p>Returns the singleton instance of the default {@link
* SectionIDMap}.</p>
* <p>
*
* Returns the singleton instance of the default {@link SectionIDMap}.</p>
*
*@return The instance value
*/
public static SectionIDMap getInstance()
{
if (defaultMap == null)
{
public static SectionIDMap getInstance() {
if (defaultMap == null) {
final SectionIDMap m = new SectionIDMap();
m.put(SUMMARY_INFORMATION_ID,
PropertyIDMap.getSummaryInformationProperties());
PropertyIDMap.getSummaryInformationProperties());
m.put(DOCUMENT_SUMMARY_INFORMATION_ID,
PropertyIDMap.getDocumentSummaryInformationProperties());
PropertyIDMap.getDocumentSummaryInformationProperties());
defaultMap = m;
}
return defaultMap;
@ -127,32 +133,31 @@ public class SectionIDMap extends HashMap
/**
* <p>Returns the property ID string that is associated with a
* given property ID in a section format ID's namespace.</p>
* <p>
*
* @param sectionFormatID Each section format ID has its own name
* space of property ID strings and thus must be specified.
* Returns the property ID string that is associated with a given property
* ID in a section format ID's namespace.</p>
*
* @param pid The property ID
*
* @return The well-known property ID string associated with the
* property ID <var>pid</var> in the name space spanned by
* <var>sectionFormatID</var>. If the
* <var>pid</var>/<var>sectionFormatID</var> combination is not
* well-known, the string "[undefined]" is returned.
*@param sectionFormatID Each section format ID has its own name space of
* property ID strings and thus must be specified.
*@param pid The property ID
*@return The well-known property ID string associated with
* the property ID <var>pid</var> in the name space spanned by <var>
* sectionFormatID</var> . If the <var>pid</var> /<var>sectionFormatID
* </var> combination is not well-known, the string "[undefined]" is
* returned.
*/
public static String getPIDString(final byte[] sectionFormatID,
final int pid)
{
final int pid) {
final PropertyIDMap m =
(PropertyIDMap) getInstance().get(sectionFormatID);
if (m == null)
(PropertyIDMap) getInstance().get(sectionFormatID);
if (m == null) {
return UNDEFINED;
else
{
} else {
final String s = (String) m.get(pid);
if (s == null)
if (s == null) {
return UNDEFINED;
}
return s;
}
}
@ -160,49 +165,57 @@ public class SectionIDMap extends HashMap
/**
* <p>Returns the {@link PropertyIDMap} for a given section format
* ID.</p>
* <p>
*
* Returns the {@link PropertyIDMap} for a given section format ID.</p>
*
*@param sectionFormatID Description of the Parameter
*@return Description of the Return Value
*/
public PropertyIDMap get(final byte[] sectionFormatID)
{
public PropertyIDMap get(final byte[] sectionFormatID) {
return (PropertyIDMap) super.get(new String(sectionFormatID));
}
/**
* <p>Returns the {@link PropertyIDMap} for a given section format
* ID.</p>
* <p>
*
* @param sectionFormatID A section format ID as a
* <tt>byte[]</tt>.
* Returns the {@link PropertyIDMap} for a given section format ID.</p>
*
* @deprecated Use {@link #get(byte[])} instead!
*@param sectionFormatID A section format ID as a <tt>byte[]</tt> .
*@return Description of the Return Value
*@deprecated Use {@link #get(byte[])} instead!
*/
public Object get(final Object sectionFormatID)
{
public Object get(final Object sectionFormatID) {
return get((byte[]) sectionFormatID);
}
/**
* <p>Associates a section format ID with a {@link
* PropertyIDMap}.</p>
* <p>
*
* Associates a section format ID with a {@link PropertyIDMap}.</p>
*
*@param sectionFormatID Description of the Parameter
*@param propertyIDMap Description of the Parameter
*@return Description of the Return Value
*/
public Object put(final byte[] sectionFormatID,
final PropertyIDMap propertyIDMap)
{
final PropertyIDMap propertyIDMap) {
return super.put(new String(sectionFormatID), propertyIDMap);
}
/**
* @deprecated Use {@link #put(byte[], PropertyIDMap)} instead!
*@param key Description of the Parameter
*@param value Description of the Parameter
*@return Description of the Return Value
*@deprecated Use {@link #put(byte[], PropertyIDMap)} instead!
*/
public Object put(final Object key, final Object value)
{
public Object put(final Object key, final Object value) {
return put((byte[]) key, (PropertyIDMap) value);
}