Class SpecialPropertySet
- java.lang.Object
-
- org.apache.poi.hpsf.PropertySet
-
- org.apache.poi.hpsf.MutablePropertySet
-
- org.apache.poi.hpsf.SpecialPropertySet
-
- Direct Known Subclasses:
- DocumentSummaryInformation, SummaryInformation
public abstract class SpecialPropertySet extends MutablePropertySet
Abstract superclass for the convenience classes
SummaryInformationandDocumentSummaryInformation.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
SummaryInformationandDocumentSummaryInformationclasses. 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 generalPropertySetin. To make things easy internally, the special class just holds a reference to the generalPropertySetand delegates all method calls to it.A cleaner implementation would have been like this: The
PropertySetFactoryparses the stream data into some internal object first. Then it finds out whether the stream is aSummaryInformation, aDocumentSummaryInformationor a generalPropertySet. However, the current implementation went the other way round historically: the convenience classes came only late to my mind.
-
-
Field Summary
-
Fields inherited from class org.apache.poi.hpsf.PropertySet
OS_MACINTOSH, OS_WIN16, OS_WIN32
-
-
Constructor Summary
Constructors Constructor and Description SpecialPropertySet(MutablePropertySet ps)Creates aSpecialPropertySet.SpecialPropertySet(PropertySet ps)Creates aSpecialPropertySet.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidaddSection(Section section)Adds a section to this property set.voidclearSections()Removes all sections from this property set.booleanequals(java.lang.Object o)Returnstrueif thePropertySetis equal to the specified parameter, elsefalse.intgetByteOrder()Returns the property set stream's low-level "byte order" field.ClassIDgetClassID()Returns the property set stream's low-level "class ID" field.SectiongetFirstSection()Gets thePropertySet's first section.intgetFormat()Returns the property set stream's low-level "format" field.intgetOSVersion()Returns the property set stream's low-level "OS version" field.Property[]getProperties()Convenience method returning thePropertyarray contained in this property set.abstract PropertyIDMapgetPropertySetIDMap()The id to name mapping of the properties in this set.intgetSectionCount()Returns the number ofSections in the property set.java.util.List<Section>getSections()Returns theSections in the property set.inthashCode()booleanisDocumentSummaryInformation()Checks whether thisPropertySetis a Document Summary Information.booleanisSummaryInformation()Checks 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.java.io.InputStreamtoInputStream()Returns the contents of this property set stream as an input stream.java.lang.StringtoString()booleanwasNull()Checks whether the property which the last call toPropertySet.getPropertyIntValue(int)orPropertySet.getProperty(int)tried to access was available or not.voidwrite(DirectoryEntry dir, java.lang.String name)Writes a property set to a document in a POI filesystem directory.voidwrite(java.io.OutputStream out)Writes the property set to an output stream.-
Methods inherited from class org.apache.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
-
getPropertySetIDMap
public abstract PropertyIDMap getPropertySetIDMap()
The id to name mapping of the properties in this set.
-
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:
PropertySet.getByteOrder()
-
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:
PropertySet.getFormat()
-
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:
PropertySet.getOSVersion()
-
getClassID
public ClassID 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:
PropertySet.getClassID()
-
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:
PropertySet.getSectionCount()
-
getSections
public java.util.List<Section> getSections()
Description copied from class:PropertySetReturns the
Sections in the property set.- Overrides:
getSectionsin classPropertySet- Returns:
- The
Sections in the property set. - See Also:
PropertySet.getSections()
-
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:
PropertySet.isSummaryInformation()
-
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:
PropertySet.isDocumentSummaryInformation()
-
getFirstSection
public Section getFirstSection()
Description copied from class:PropertySetGets the
PropertySet's first section.- Overrides:
getFirstSectionin classPropertySet- Returns:
- The
PropertySet's first section. - See Also:
PropertySet.getSingleSection()
-
addSection
public void addSection(Section section)
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:
MutablePropertySet.addSection(org.apache.poi.hpsf.Section)
-
clearSections
public void clearSections()
Description copied from class:MutablePropertySetRemoves all sections from this property set.
- Overrides:
clearSectionsin classMutablePropertySet- See Also:
MutablePropertySet.clearSections()
-
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:
MutablePropertySet.setByteOrder(int)
-
setClassID
public void setClassID(ClassID classID)
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:
MutablePropertySet.setClassID(org.apache.poi.hpsf.ClassID)
-
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:
MutablePropertySet.setFormat(int)
-
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:
MutablePropertySet.setOSVersion(int)
-
toInputStream
public java.io.InputStream toInputStream() throws java.io.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:
java.io.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, java.lang.String name) throws WritingNotSupportedException, java.io.IOException
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:
WritingNotSupportedExceptionjava.io.IOException- See Also:
MutablePropertySet.write(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
-
write
public void write(java.io.OutputStream out) throws WritingNotSupportedException, java.io.IOExceptionDescription 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.java.io.IOException- if an error when writing to the output stream occurs- See Also:
MutablePropertySet.write(java.io.OutputStream)
-
equals
public boolean equals(java.lang.Object o)
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:
PropertySet.equals(java.lang.Object)
-
getProperties
public Property[] getProperties() throws NoSingleSectionException
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:
PropertySet.getProperties()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classPropertySet- See Also:
PropertySet.hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classPropertySet- See Also:
PropertySet.toString()
-
wasNull
public boolean wasNull() throws NoSingleSectionExceptionDescription 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:
PropertySet.wasNull()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG