|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.hpsf.PropertySet org.apache.poi.hpsf.MutablePropertySet org.apache.poi.hpsf.SpecialPropertySet
public abstract class SpecialPropertySet
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.
Field Summary |
---|
Fields inherited from class org.apache.poi.hpsf.PropertySet |
---|
byteOrder, classID, format, OS_MACINTOSH, OS_WIN16, OS_WIN32, osVersion, sections |
Constructor Summary | |
---|---|
SpecialPropertySet(MutablePropertySet ps)
Creates a SpecialPropertySet . |
|
SpecialPropertySet(PropertySet ps)
Creates a SpecialPropertySet . |
Method Summary | |
---|---|
void |
addSection(Section section)
Adds a section to this property set. |
void |
clearSections()
Removes all sections from this property set. |
boolean |
equals(java.lang.Object o)
Returns true if the PropertySet is equal
to the specified parameter, else false . |
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 the PropertySet '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 the Property array
contained in this property set. |
protected java.lang.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. |
abstract PropertyIDMap |
getPropertySetIDMap()
The id to name mapping of the properties in this set. |
int |
getSectionCount()
Returns the number of Section s in the property
set. |
java.util.List |
getSections()
Returns the Section s in the property set. |
int |
hashCode()
|
boolean |
isDocumentSummaryInformation()
Checks whether this PropertySet is a Document
Summary Information. |
boolean |
isSummaryInformation()
Checks whether this PropertySet 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. |
java.io.InputStream |
toInputStream()
Returns the contents of this property set stream as an input stream. |
java.lang.String |
toString()
|
boolean |
wasNull()
Checks whether the property which the last call to PropertySet.getPropertyIntValue(int) or PropertySet.getProperty(int) tried to access
was available or not. |
void |
write(DirectoryEntry dir,
java.lang.String name)
Writes a property set to a document in a POI filesystem directory. |
void |
write(java.io.OutputStream out)
Writes the property set to an output stream. |
Methods inherited from class org.apache.poi.hpsf.PropertySet |
---|
getSingleSection, isPropertySetStream, isPropertySetStream |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SpecialPropertySet(PropertySet ps)
Creates a SpecialPropertySet
.
ps
- The property set to be encapsulated by the
SpecialPropertySet
public SpecialPropertySet(MutablePropertySet ps)
Creates a SpecialPropertySet
.
ps
- The mutable property set to be encapsulated by the
SpecialPropertySet
Method Detail |
---|
public abstract PropertyIDMap getPropertySetIDMap()
public int getByteOrder()
PropertySet
Returns the property set stream's low-level "byte order" field. It is always 0xFFFE .
getByteOrder
in class PropertySet
PropertySet.getByteOrder()
public int getFormat()
PropertySet
Returns the property set stream's low-level "format" field. It is always 0x0000 .
getFormat
in class PropertySet
PropertySet.getFormat()
public int getOSVersion()
PropertySet
Returns the property set stream's low-level "OS version" field.
getOSVersion
in class PropertySet
PropertySet.getOSVersion()
public ClassID getClassID()
PropertySet
Returns the property set stream's low-level "class ID" field.
getClassID
in class PropertySet
PropertySet.getClassID()
public int getSectionCount()
PropertySet
Returns the number of Section
s in the property
set.
getSectionCount
in class PropertySet
Section
s in the property set.PropertySet.getSectionCount()
public java.util.List getSections()
PropertySet
Returns the Section
s in the property set.
getSections
in class PropertySet
Section
s in the property set.PropertySet.getSections()
public boolean isSummaryInformation()
PropertySet
Checks whether this PropertySet
represents a Summary
Information.
isSummaryInformation
in class PropertySet
true
if this PropertySet
represents a Summary Information, else false
.PropertySet.isSummaryInformation()
public boolean isDocumentSummaryInformation()
PropertySet
Checks whether this PropertySet
is a Document
Summary Information.
isDocumentSummaryInformation
in class PropertySet
true
if this PropertySet
represents a Document Summary Information, else false
.PropertySet.isDocumentSummaryInformation()
public Section getFirstSection()
PropertySet
Gets the PropertySet
's first section.
getFirstSection
in class PropertySet
PropertySet
's first section.PropertySet.getSingleSection()
public void addSection(Section section)
MutablePropertySet
Adds a section to this property set.
addSection
in class MutablePropertySet
section
- The Section
to add. It will be appended
after any sections that are already present in the property set
and thus become the last section.MutablePropertySet.addSection(org.apache.poi.hpsf.Section)
public void clearSections()
MutablePropertySet
Removes all sections from this property set.
clearSections
in class MutablePropertySet
MutablePropertySet.clearSections()
public void setByteOrder(int byteOrder)
MutablePropertySet
Sets the "byteOrder" property.
setByteOrder
in class MutablePropertySet
byteOrder
- the byteOrder value to setMutablePropertySet.setByteOrder(int)
public void setClassID(ClassID classID)
MutablePropertySet
Sets the property set stream's low-level "class ID" field.
setClassID
in class MutablePropertySet
classID
- The property set stream's low-level "class ID" field.MutablePropertySet.setClassID(org.apache.poi.hpsf.ClassID)
public void setFormat(int format)
MutablePropertySet
Sets the "format" property.
setFormat
in class MutablePropertySet
format
- the format value to setMutablePropertySet.setFormat(int)
public void setOSVersion(int osVersion)
MutablePropertySet
Sets the "osVersion" property.
setOSVersion
in class MutablePropertySet
osVersion
- the osVersion value to setMutablePropertySet.setOSVersion(int)
public java.io.InputStream toInputStream() throws java.io.IOException, WritingNotSupportedException
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.
toInputStream
in class MutablePropertySet
java.io.IOException
- if an I/O exception occurs.
WritingNotSupportedException
- if HPSF does not yet support writing
of a property's variant type.MutablePropertySet.toInputStream()
public void write(DirectoryEntry dir, java.lang.String name) throws WritingNotSupportedException, java.io.IOException
MutablePropertySet
Writes a property set to a document in a POI filesystem directory.
write
in class MutablePropertySet
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.
WritingNotSupportedException
java.io.IOException
MutablePropertySet.write(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
public void write(java.io.OutputStream out) throws WritingNotSupportedException, java.io.IOException
MutablePropertySet
Writes the property set to an output stream.
write
in class MutablePropertySet
out
- the output stream to write the section to
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
occursMutablePropertySet.write(java.io.OutputStream)
public boolean equals(java.lang.Object o)
PropertySet
Returns true
if the PropertySet
is equal
to the specified parameter, else false
.
equals
in class PropertySet
o
- the object to compare this PropertySet
with
true
if the objects are equal, false
if notPropertySet.equals(java.lang.Object)
public Property[] getProperties() throws NoSingleSectionException
PropertySet
Convenience method returning the Property
array
contained in this property set. It is a shortcut for getting
the PropertySet
's Section
s list and then
getting the Property
array from the first Section
.
getProperties
in class PropertySet
Section
of this
PropertySet
.
NoSingleSectionException
- if the PropertySet
has
more or less than one Section
.PropertySet.getProperties()
protected java.lang.Object getProperty(int id) throws NoSingleSectionException
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 to PropertySet.wasNull()
will return true
.
getProperty
in class PropertySet
id
- The property ID
NoSingleSectionException
- if the PropertySet
has
more or less than one Section
.PropertySet.getProperty(int)
protected boolean getPropertyBooleanValue(int id) throws NoSingleSectionException
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 to PropertySet.wasNull()
will return true
to let the caller
distinguish that case from a real property value of
false
.
getPropertyBooleanValue
in class PropertySet
id
- The property ID
NoSingleSectionException
- if the PropertySet
has
more or less than one Section
.PropertySet.getPropertyBooleanValue(int)
protected int getPropertyIntValue(int id) throws NoSingleSectionException
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 return true
to let the caller distinguish
that case from a real property value of 0.
getPropertyIntValue
in class PropertySet
id
- The property ID
NoSingleSectionException
- if the PropertySet
has
more or less than one Section
.PropertySet.getPropertyIntValue(int)
public int hashCode()
hashCode
in class PropertySet
PropertySet.hashCode()
public java.lang.String toString()
toString
in class PropertySet
PropertySet.toString()
public boolean wasNull() throws NoSingleSectionException
PropertySet
Checks whether the property which the last call to PropertySet.getPropertyIntValue(int)
or PropertySet.getProperty(int)
tried to access
was available or not. This information might be important for
callers of PropertySet.getPropertyIntValue(int)
since the latter
returns 0 if the property does not exist. Using PropertySet.wasNull()
, the caller can distiguish this case from a
property's real value of 0.
wasNull
in class PropertySet
true
if the last call to PropertySet.getPropertyIntValue(int)
or PropertySet.getProperty(int)
tried to access a
property that was not available, else false
.
NoSingleSectionException
- if the PropertySet
has
more than one Section
.PropertySet.wasNull()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |