Class SpecialPropertySet
- java.lang.Object
-
- loci.poi.hpsf.PropertySet
-
- loci.poi.hpsf.MutablePropertySet
-
- loci.poi.hpsf.SpecialPropertySet
-
- Direct Known Subclasses:
DocumentSummaryInformation
,SummaryInformation
public abstract class SpecialPropertySet extends MutablePropertySet
Abstract superclass for the convenience classes
SummaryInformation
andDocumentSummaryInformation
.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
SummaryInformation
andDocumentSummaryInformation
classes. When parsing the data a property set stream consists of (possibly coming from anInputStream
) 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 generalPropertySet
. Creating a special subclass should be as easy as calling the special subclass' constructor and pass the generalPropertySet
in. To make things easy internally, the special class just holds a reference to the generalPropertySet
and delegates all method calls to it.A cleaner implementation would have been like this: The
PropertySetFactory
parses the stream data into some internal object first. Then it finds out whether the stream is aSummaryInformation
, aDocumentSummaryInformation
or a generalPropertySet
. However, the current implementation went the other way round historically: the convenience classes came only late to my mind.- Since:
- 2002-02-09
- Version:
- $Id: SpecialPropertySet.java 489730 2006-12-22 19:18:16Z bayard $
- Author:
- Rainer Klute <klute@rainer-klute.de>
-
-
Field Summary
-
Fields inherited from class loci.poi.hpsf.PropertySet
byteOrder, classID, format, OS_MACINTOSH, OS_WIN16, OS_WIN32, osVersion, sections
-
-
Constructor Summary
Constructors Constructor Description SpecialPropertySet(MutablePropertySet ps)
Creates aSpecialPropertySet
.SpecialPropertySet(PropertySet ps)
Creates aSpecialPropertySet
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSection(Section section)
Adds a section to this property set.void
clearSections()
Removes all sections from this property set.boolean
equals(Object o)
Returnstrue
if thePropertySet
is equal to the specified parameter, elsefalse
.int
getByteOrder()
Returns the property set stream's low-level "byte order" field.ClassID
getClassID()
Returns the property set stream's low-level "class ID" field.Section
getFirstSection()
Gets thePropertySet
's first section.int
getFormat()
Returns the property set stream's low-level "format" field.int
getOSVersion()
Returns the property set stream's low-level "OS version" field.Property[]
getProperties()
Convenience method returning theProperty
array contained in this property set.protected Object
getProperty(int id)
Convenience method returning the value of the property with the specified ID.protected boolean
getPropertyBooleanValue(int id)
Convenience method returning the value of a boolean property with the specified ID.protected int
getPropertyIntValue(int id)
Convenience method returning the value of the numeric property with the specified ID.int
getSectionCount()
Returns the number ofSection
s in the property set.List
getSections()
Returns theSection
s in the property set.int
hashCode()
boolean
isDocumentSummaryInformation()
Checks whether thisPropertySet
is a Document Summary Information.boolean
isSummaryInformation()
Checks whether thisPropertySet
represents a Summary Information.void
setByteOrder(int byteOrder)
Sets the "byteOrder" property.void
setClassID(ClassID classID)
Sets the property set stream's low-level "class ID" field.void
setFormat(int format)
Sets the "format" property.void
setOSVersion(int osVersion)
Sets the "osVersion" property.loci.common.RandomAccessInputStream
toInputStream()
Returns the contents of this property set stream as an input stream.String
toString()
boolean
wasNull()
Checks whether the property which the last call toPropertySet.getPropertyIntValue(int)
orPropertySet.getProperty(int)
tried to access was available or not.void
write(OutputStream out)
Writes the property set to an output stream.void
write(DirectoryEntry dir, String name)
Writes a property set to a document in a POI filesystem directory.-
Methods inherited from class loci.poi.hpsf.PropertySet
getSingleSection, isPropertySetStream, isPropertySetStream
-
-
-
-
Constructor Detail
-
SpecialPropertySet
public SpecialPropertySet(PropertySet ps)
Creates a
SpecialPropertySet
.- Parameters:
ps
- The property set to be encapsulated by theSpecialPropertySet
-
SpecialPropertySet
public SpecialPropertySet(MutablePropertySet ps)
Creates a
SpecialPropertySet
.- Parameters:
ps
- The mutable property set to be encapsulated by theSpecialPropertySet
-
-
Method Detail
-
getByteOrder
public int getByteOrder()
Description copied from class:PropertySet
Returns the property set stream's low-level "byte order" field. It is always 0xFFFE .
- Overrides:
getByteOrder
in classPropertySet
- Returns:
- The property set stream's low-level "byte order" field.
- See Also:
PropertySet.getByteOrder()
-
getFormat
public int getFormat()
Description copied from class:PropertySet
Returns the property set stream's low-level "format" field. It is always 0x0000 .
- Overrides:
getFormat
in classPropertySet
- Returns:
- The property set stream's low-level "format" field.
- See Also:
PropertySet.getFormat()
-
getOSVersion
public int getOSVersion()
Description copied from class:PropertySet
Returns the property set stream's low-level "OS version" field.
- Overrides:
getOSVersion
in classPropertySet
- Returns:
- The property set stream's low-level "OS version" field.
- See Also:
PropertySet.getOSVersion()
-
getClassID
public ClassID getClassID()
Description copied from class:PropertySet
Returns the property set stream's low-level "class ID" field.
- Overrides:
getClassID
in classPropertySet
- Returns:
- The property set stream's low-level "class ID" field.
- See Also:
PropertySet.getClassID()
-
getSectionCount
public int getSectionCount()
Description copied from class:PropertySet
Returns the number of
Section
s in the property set.- Overrides:
getSectionCount
in classPropertySet
- Returns:
- The number of
Section
s in the property set. - See Also:
PropertySet.getSectionCount()
-
getSections
public List getSections()
Description copied from class:PropertySet
Returns the
Section
s in the property set.- Overrides:
getSections
in classPropertySet
- Returns:
- The
Section
s in the property set. - See Also:
PropertySet.getSections()
-
isSummaryInformation
public boolean isSummaryInformation()
Description copied from class:PropertySet
Checks whether this
PropertySet
represents a Summary Information.- Overrides:
isSummaryInformation
in classPropertySet
- Returns:
true
if thisPropertySet
represents a Summary Information, elsefalse
.- See Also:
PropertySet.isSummaryInformation()
-
isDocumentSummaryInformation
public boolean isDocumentSummaryInformation()
Description copied from class:PropertySet
Checks whether this
PropertySet
is a Document Summary Information.- Overrides:
isDocumentSummaryInformation
in classPropertySet
- Returns:
true
if thisPropertySet
represents a Document Summary Information, elsefalse
.- See Also:
PropertySet.isDocumentSummaryInformation()
-
getFirstSection
public Section getFirstSection()
Description copied from class:PropertySet
Gets the
PropertySet
's first section.- Overrides:
getFirstSection
in classPropertySet
- Returns:
- The
PropertySet
's first section. - See Also:
PropertySet.getSingleSection()
-
addSection
public void addSection(Section section)
Description copied from class:MutablePropertySet
Adds a section to this property set.
- Overrides:
addSection
in classMutablePropertySet
- Parameters:
section
- TheSection
to add. It will be appended after any sections that are already present in the property set and thus become the last section.- See Also:
MutablePropertySet.addSection(loci.poi.hpsf.Section)
-
clearSections
public void clearSections()
Description copied from class:MutablePropertySet
Removes all sections from this property set.
- Overrides:
clearSections
in classMutablePropertySet
- See Also:
MutablePropertySet.clearSections()
-
setByteOrder
public void setByteOrder(int byteOrder)
Description copied from class:MutablePropertySet
Sets the "byteOrder" property.
- Overrides:
setByteOrder
in classMutablePropertySet
- Parameters:
byteOrder
- the byteOrder value to set- See Also:
MutablePropertySet.setByteOrder(int)
-
setClassID
public void setClassID(ClassID classID)
Description copied from class:MutablePropertySet
Sets the property set stream's low-level "class ID" field.
- Overrides:
setClassID
in classMutablePropertySet
- Parameters:
classID
- The property set stream's low-level "class ID" field.- See Also:
MutablePropertySet.setClassID(loci.poi.hpsf.ClassID)
-
setFormat
public void setFormat(int format)
Description copied from class:MutablePropertySet
Sets the "format" property.
- Overrides:
setFormat
in classMutablePropertySet
- Parameters:
format
- the format value to set- See Also:
MutablePropertySet.setFormat(int)
-
setOSVersion
public void setOSVersion(int osVersion)
Description copied from class:MutablePropertySet
Sets the "osVersion" property.
- Overrides:
setOSVersion
in classMutablePropertySet
- Parameters:
osVersion
- the osVersion value to set- See Also:
MutablePropertySet.setOSVersion(int)
-
toInputStream
public loci.common.RandomAccessInputStream toInputStream() throws IOException, WritingNotSupportedException
Description copied from class:MutablePropertySet
Returns the contents of this property set stream as an input stream. The latter can be used for example to write the property set into a POIFS document. The input stream represents a snapshot of the property set. If the latter is modified while the input stream is still being read, the modifications will not be reflected in the input stream but in the
MutablePropertySet
only.- Overrides:
toInputStream
in classMutablePropertySet
- Returns:
- the contents of this property set stream
- Throws:
IOException
- if an I/O exception occurs.WritingNotSupportedException
- if HPSF does not yet support writing of a property's variant type.- See Also:
MutablePropertySet.toInputStream()
-
write
public void write(DirectoryEntry dir, String name) throws WritingNotSupportedException, IOException
Description copied from class:MutablePropertySet
Writes a property set to a document in a POI filesystem directory.
- Overrides:
write
in classMutablePropertySet
- Parameters:
dir
- The directory in the POI filesystem to write the document to.name
- The document's name. If there is already a document with the same name in the directory the latter will be overwritten.- Throws:
WritingNotSupportedException
IOException
- See Also:
MutablePropertySet.write(loci.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
-
write
public void write(OutputStream out) throws WritingNotSupportedException, IOException
Description copied from class:MutablePropertySet
Writes the property set to an output stream.
- Overrides:
write
in classMutablePropertySet
- Parameters:
out
- the output stream to write the section to- Throws:
WritingNotSupportedException
- if HPSF does not yet support writing a property's variant type.IOException
- if an error when writing to the output stream occurs- See Also:
MutablePropertySet.write(java.io.OutputStream)
-
equals
public boolean equals(Object o)
Description copied from class:PropertySet
Returns
true
if thePropertySet
is equal to the specified parameter, elsefalse
.- Overrides:
equals
in classPropertySet
- Parameters:
o
- the object to compare thisPropertySet
with- Returns:
true
if the objects are equal,false
if not- See Also:
PropertySet.equals(java.lang.Object)
-
getProperties
public Property[] getProperties() throws NoSingleSectionException
Description copied from class:PropertySet
Convenience method returning the
Property
array contained in this property set. It is a shortcut for getting thePropertySet
'sSection
s list and then getting theProperty
array from the firstSection
.- Overrides:
getProperties
in classPropertySet
- Returns:
- The properties of the only
Section
of thisPropertySet
. - Throws:
NoSingleSectionException
- if thePropertySet
has more or less than oneSection
.- See Also:
PropertySet.getProperties()
-
getProperty
protected Object getProperty(int id) throws NoSingleSectionException
Description copied from class:PropertySet
Convenience method returning the value of the property with the specified ID. If the property is not available,
null
is returned and a subsequent call toPropertySet.wasNull()
will returntrue
.- Overrides:
getProperty
in classPropertySet
- Parameters:
id
- The property ID- Returns:
- The property value
- Throws:
NoSingleSectionException
- if thePropertySet
has more or less than oneSection
.- See Also:
PropertySet.getProperty(int)
-
getPropertyBooleanValue
protected boolean getPropertyBooleanValue(int id) throws NoSingleSectionException
Description copied from class:PropertySet
Convenience method returning the value of a boolean property with the specified ID. If the property is not available,
false
is returned. A subsequent call toPropertySet.wasNull()
will returntrue
to let the caller distinguish that case from a real property value offalse
.- Overrides:
getPropertyBooleanValue
in classPropertySet
- Parameters:
id
- The property ID- Returns:
- The property value
- Throws:
NoSingleSectionException
- if thePropertySet
has more or less than oneSection
.- See Also:
PropertySet.getPropertyBooleanValue(int)
-
getPropertyIntValue
protected int getPropertyIntValue(int id) throws NoSingleSectionException
Description copied from class:PropertySet
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
PropertySet.wasNull()
will returntrue
to let the caller distinguish that case from a real property value of 0.- Overrides:
getPropertyIntValue
in classPropertySet
- Parameters:
id
- The property ID- Returns:
- The propertyIntValue value
- Throws:
NoSingleSectionException
- if thePropertySet
has more or less than oneSection
.- See Also:
PropertySet.getPropertyIntValue(int)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classPropertySet
- See Also:
PropertySet.hashCode()
-
toString
public String toString()
- Overrides:
toString
in classPropertySet
- See Also:
PropertySet.toString()
-
wasNull
public boolean wasNull() throws NoSingleSectionException
Description copied from class:PropertySet
Checks whether the property which the last call to
PropertySet.getPropertyIntValue(int)
orPropertySet.getProperty(int)
tried to access was available or not. This information might be important for callers ofPropertySet.getPropertyIntValue(int)
since the latter returns 0 if the property does not exist. UsingPropertySet.wasNull()
, the caller can distiguish this case from a property's real value of 0.- Overrides:
wasNull
in classPropertySet
- Returns:
true
if the last call toPropertySet.getPropertyIntValue(int)
orPropertySet.getProperty(int)
tried to access a property that was not available, elsefalse
.- Throws:
NoSingleSectionException
- if thePropertySet
has more than oneSection
.- See Also:
PropertySet.wasNull()
-
-