Class SpecialPropertySet
- Direct Known Subclasses:
DocumentSummaryInformation,SummaryInformation
Abstract superclass for the convenience classes SummaryInformation and DocumentSummaryInformation.
The motivation behind this class is quite nasty if you look
behind the scenes, but it serves the application programmer well by
providing him with the easy-to-use SummaryInformation and
DocumentSummaryInformation classes. When parsing the data a
property set stream consists of (possibly coming from an 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 PropertySet. Creating a special subclass should be as easy as
calling the special subclass' constructor and pass the general
PropertySet in. To make things easy internally, the special
class just holds a reference to the general PropertySet 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 a SummaryInformation, a DocumentSummaryInformation or a
general PropertySet. 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
ConstructorsConstructorDescriptionCreates aSpecialPropertySet.Creates aSpecialPropertySet. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSection(Section section) Adds a section to this property set.voidRemoves all sections from this property set.booleanReturnstrueif thePropertySetis equal to the specified parameter, elsefalse.intReturns the property set stream's low-level "byte order" field.Returns the property set stream's low-level "class ID" field.Gets thePropertySet's first section.intReturns the property set stream's low-level "format" field.intReturns the property set stream's low-level "OS version" field.Property[]Convenience method returning thePropertyarray contained in this property set.protected ObjectgetProperty(int id) Convenience method returning the value of the property with the specified ID.protected booleangetPropertyBooleanValue(int id) Convenience method returning the value of a boolean property with the specified ID.protected intgetPropertyIntValue(int id) Convenience method returning the value of the numeric property with the specified ID.intReturns the number ofSections in the property set.Returns theSections in the property set.inthashCode()booleanChecks whether thisPropertySetis a Document Summary Information.booleanChecks whether thisPropertySetrepresents a Summary Information.voidsetByteOrder(int byteOrder) Sets the "byteOrder" property.voidsetClassID(ClassID classID) Sets the property set stream's low-level "class ID" field.voidsetFormat(int format) Sets the "format" property.voidsetOSVersion(int osVersion) Sets the "osVersion" property.loci.common.RandomAccessInputStreamReturns the contents of this property set stream as an input stream.toString()booleanwasNull()Checks whether the property which the last call toPropertySet.getPropertyIntValue(int)orPropertySet.getProperty(int)tried to access was available or not.voidwrite(OutputStream out) Writes the property set to an output stream.voidwrite(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 Details
-
SpecialPropertySet
Creates a
SpecialPropertySet.- Parameters:
ps- The property set to be encapsulated by theSpecialPropertySet
-
SpecialPropertySet
Creates a
SpecialPropertySet.- Parameters:
ps- The mutable property set to be encapsulated by theSpecialPropertySet
-
-
Method Details
-
getByteOrder
public int getByteOrder()Description copied from class:PropertySetReturns the property set stream's low-level "byte order" field. It is always 0xFFFE .
- Overrides:
getByteOrderin classPropertySet- Returns:
- The property set stream's low-level "byte order" field.
- See Also:
-
getFormat
public int getFormat()Description copied from class:PropertySetReturns the property set stream's low-level "format" field. It is always 0x0000 .
- Overrides:
getFormatin classPropertySet- Returns:
- The property set stream's low-level "format" field.
- See Also:
-
getOSVersion
public int getOSVersion()Description copied from class:PropertySetReturns the property set stream's low-level "OS version" field.
- Overrides:
getOSVersionin classPropertySet- Returns:
- The property set stream's low-level "OS version" field.
- See Also:
-
getClassID
Description copied from class:PropertySetReturns the property set stream's low-level "class ID" field.
- Overrides:
getClassIDin classPropertySet- Returns:
- The property set stream's low-level "class ID" field.
- See Also:
-
getSectionCount
public int getSectionCount()Description copied from class:PropertySetReturns the number of
Sections in the property set.- Overrides:
getSectionCountin classPropertySet- Returns:
- The number of
Sections in the property set. - See Also:
-
getSections
Description copied from class:PropertySetReturns the
Sections in the property set.- Overrides:
getSectionsin classPropertySet- Returns:
- The
Sections in the property set. - See Also:
-
isSummaryInformation
public boolean isSummaryInformation()Description copied from class:PropertySetChecks whether this
PropertySetrepresents a Summary Information.- Overrides:
isSummaryInformationin classPropertySet- Returns:
trueif thisPropertySetrepresents a Summary Information, elsefalse.- See Also:
-
isDocumentSummaryInformation
public boolean isDocumentSummaryInformation()Description copied from class:PropertySetChecks whether this
PropertySetis a Document Summary Information.- Overrides:
isDocumentSummaryInformationin classPropertySet- Returns:
trueif thisPropertySetrepresents a Document Summary Information, elsefalse.- See Also:
-
getFirstSection
Description copied from class:PropertySetGets the
PropertySet's first section.- Overrides:
getFirstSectionin classPropertySet- Returns:
- The
PropertySet's first section. - See Also:
-
addSection
Description copied from class:MutablePropertySetAdds a section to this property set.
- Overrides:
addSectionin classMutablePropertySet- Parameters:
section- TheSectionto add. It will be appended after any sections that are already present in the property set and thus become the last section.- See Also:
-
clearSections
public void clearSections()Description copied from class:MutablePropertySetRemoves all sections from this property set.
- Overrides:
clearSectionsin classMutablePropertySet- See Also:
-
setByteOrder
public void setByteOrder(int byteOrder) Description copied from class:MutablePropertySetSets the "byteOrder" property.
- Overrides:
setByteOrderin classMutablePropertySet- Parameters:
byteOrder- the byteOrder value to set- See Also:
-
setClassID
Description copied from class:MutablePropertySetSets the property set stream's low-level "class ID" field.
- Overrides:
setClassIDin classMutablePropertySet- Parameters:
classID- The property set stream's low-level "class ID" field.- See Also:
-
setFormat
public void setFormat(int format) Description copied from class:MutablePropertySetSets the "format" property.
- Overrides:
setFormatin classMutablePropertySet- Parameters:
format- the format value to set- See Also:
-
setOSVersion
public void setOSVersion(int osVersion) Description copied from class:MutablePropertySetSets the "osVersion" property.
- Overrides:
setOSVersionin classMutablePropertySet- Parameters:
osVersion- the osVersion value to set- See Also:
-
toInputStream
public loci.common.RandomAccessInputStream toInputStream() throws IOException, WritingNotSupportedExceptionDescription copied from class:MutablePropertySetReturns 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
MutablePropertySetonly.- Overrides:
toInputStreamin 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:
-
write
Description copied from class:MutablePropertySetWrites a property set to a document in a POI filesystem directory.
- Overrides:
writein 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:
WritingNotSupportedExceptionIOException- See Also:
-
write
Description copied from class:MutablePropertySetWrites the property set to an output stream.
- Overrides:
writein 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:
-
equals
Description copied from class:PropertySetReturns
trueif thePropertySetis equal to the specified parameter, elsefalse.- Overrides:
equalsin classPropertySet- Parameters:
o- the object to compare thisPropertySetwith- Returns:
trueif the objects are equal,falseif not- See Also:
-
getProperties
Description copied from class:PropertySetConvenience method returning the
Propertyarray contained in this property set. It is a shortcut for getting thePropertySet'sSections list and then getting thePropertyarray from the firstSection.- Overrides:
getPropertiesin classPropertySet- Returns:
- The properties of the only
Sectionof thisPropertySet. - Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.- See Also:
-
getProperty
Description copied from class:PropertySetConvenience method returning the value of the property with the specified ID. If the property is not available,
nullis returned and a subsequent call toPropertySet.wasNull()will returntrue.- Overrides:
getPropertyin classPropertySet- Parameters:
id- The property ID- Returns:
- The property value
- Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.- See Also:
-
getPropertyBooleanValue
Description copied from class:PropertySetConvenience method returning the value of a boolean property with the specified ID. If the property is not available,
falseis returned. A subsequent call toPropertySet.wasNull()will returntrueto let the caller distinguish that case from a real property value offalse.- Overrides:
getPropertyBooleanValuein classPropertySet- Parameters:
id- The property ID- Returns:
- The property value
- Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.- See Also:
-
getPropertyIntValue
Description copied from class:PropertySetConvenience 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 returntrueto let the caller distinguish that case from a real property value of 0.- Overrides:
getPropertyIntValuein classPropertySet- Parameters:
id- The property ID- Returns:
- The propertyIntValue value
- Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.- See Also:
-
hashCode
public int hashCode()- Overrides:
hashCodein classPropertySet- See Also:
-
toString
- Overrides:
toStringin classPropertySet- See Also:
-
wasNull
Description copied from class:PropertySetChecks 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:
wasNullin classPropertySet- Returns:
trueif the last call toPropertySet.getPropertyIntValue(int)orPropertySet.getProperty(int)tried to access a property that was not available, elsefalse.- Throws:
NoSingleSectionException- if thePropertySethas more than oneSection.- See Also:
-