|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.poi.hpsf.PropertySet
public class PropertySet
Represents a property set in the Horrible Property Set Format (HPSF). These are usually metadata of a Microsoft Office document.
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 PropertySetFactory.create(java.io.InputStream)
and then retrieve
the information its needs by calling appropriate methods.
PropertySetFactory.create(java.io.InputStream)
does its work by calling one
of the constructors PropertySet(InputStream)
or
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.
A PropertySet
has a list of Section
s, and each
Section
has a Property
array. Use getSections()
to retrieve the Section
s, then call Section.getProperties()
for each Section
to get hold of the
Property
arrays.
PropertySet
s contains only a single Section
, the
convenience method getProperties()
returns the properties of
a PropertySet
's Section
(throwing a NoSingleSectionException
if the PropertySet
contains more
(or less) than exactly one Section
).
Field Summary | |
---|---|
static int |
OS_MACINTOSH
If the OS version field holds this value the property set stream was created on a Macintosh system. |
static int |
OS_WIN16
If the OS version field holds this value the property set stream was created on a 16-bit Windows system. |
static int |
OS_WIN32
If the OS version field holds this value the property set stream was created on a 32-bit Windows system. |
Constructor Summary | |
---|---|
PropertySet(byte[] stream)
Creates a PropertySet instance from a byte array
that represents a stream in the Horrible Property Set
Format. |
|
PropertySet(byte[] stream,
int offset,
int length)
Creates a PropertySet instance from a byte array
that represents a stream in the Horrible Property Set
Format. |
|
PropertySet(java.io.InputStream stream)
Creates a PropertySet instance from an InputStream in the Horrible Property Set Format. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object o)
Returns true if the PropertySet is equal
to the specified parameter, else |
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. |
int |
getSectionCount()
Returns the number of Section s in the property
set. |
java.util.List |
getSections()
Returns the Section s in the property set. |
Section |
getSingleSection()
If the PropertySet has only a single section this
method returns it. |
int |
hashCode()
|
boolean |
isDocumentSummaryInformation()
Checks whether this PropertySet is a Document
Summary Information. |
static boolean |
isPropertySetStream(byte[] src,
int offset,
int length)
Checks whether a byte array is in the Horrible Property Set Format. |
static boolean |
isPropertySetStream(java.io.InputStream stream)
Checks whether an InputStream is in the Horrible
Property Set Format. |
boolean |
isSummaryInformation()
Checks whether this PropertySet represents a Summary
Information. |
java.lang.String |
toString()
|
boolean |
wasNull()
Checks whether the property which the last call to getPropertyIntValue(int) or getProperty(int) tried to access
was available or not. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int OS_WIN16
If the OS version field holds this value the property set stream was created on a 16-bit Windows system.
public static final int OS_MACINTOSH
If the OS version field holds this value the property set stream was created on a Macintosh system.
public static final int OS_WIN32
If the OS version field holds this value the property set stream was created on a 32-bit Windows system.
Constructor Detail |
---|
public PropertySet(java.io.InputStream stream) throws NoPropertySetStreamException, MarkUnsupportedException, java.io.IOException, java.io.UnsupportedEncodingException
Creates a PropertySet
instance from an InputStream
in the Horrible Property Set Format.
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.
stream
- Holds the data making out the property set
stream.
MarkUnsupportedException
- if the stream does not support
the InputStream.markSupported()
method.
java.io.IOException
- if the InputStream
cannot not be
accessed as needed.
NoPropertySetStreamException
- if the input stream does not
contain a property set.
java.io.UnsupportedEncodingException
- if a character encoding is not
supported.public PropertySet(byte[] stream, int offset, int length) throws NoPropertySetStreamException, java.io.UnsupportedEncodingException
Creates a PropertySet
instance from a byte array
that represents a stream in the Horrible Property Set
Format.
stream
- The byte array holding the stream data.offset
- The offset in stream where the stream
data begin. If the stream data begin with the first byte in the
array, the offset is 0.length
- The length of the stream data.
NoPropertySetStreamException
- if the byte array is not a
property set stream.
java.io.UnsupportedEncodingException
- if the codepage is not supported.public PropertySet(byte[] stream) throws NoPropertySetStreamException, java.io.UnsupportedEncodingException
Creates a PropertySet
instance from a byte array
that represents a stream in the Horrible Property Set
Format.
stream
- The byte array holding the stream data. The
complete byte array contents is the stream data.
NoPropertySetStreamException
- if the byte array is not a
property set stream.
java.io.UnsupportedEncodingException
- if the codepage is not supported.Method Detail |
---|
public int getByteOrder()
Returns the property set stream's low-level "byte order" field. It is always 0xFFFE .
public int getFormat()
Returns the property set stream's low-level "format" field. It is always 0x0000 .
public int getOSVersion()
Returns the property set stream's low-level "OS version" field.
public ClassID getClassID()
Returns the property set stream's low-level "class ID" field.
public int getSectionCount()
Returns the number of Section
s in the property
set.
Section
s in the property set.public java.util.List getSections()
Returns the Section
s in the property set.
Section
s in the property set.public static boolean isPropertySetStream(java.io.InputStream stream) throws MarkUnsupportedException, java.io.IOException
Checks whether an InputStream
is in the Horrible
Property Set Format.
stream
- The 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 InputStream
must support the
InputStream.mark(int)
method.
true
if the stream is a property set
stream, else false
.
MarkUnsupportedException
- if the InputStream
does not support the InputStream.mark(int)
method.
java.io.IOException
- if an I/O error occurspublic static boolean isPropertySetStream(byte[] src, int offset, int length)
Checks whether a byte array is in the Horrible Property Set Format.
src
- The byte array to check.offset
- The offset in the byte array.length
- The significant number of bytes in the byte
array. Only this number of bytes will be checked.
true
if the byte array is a property set
stream, false
if not.public boolean isSummaryInformation()
Checks whether this PropertySet
represents a Summary
Information.
true
if this PropertySet
represents a Summary Information, else false
.public boolean isDocumentSummaryInformation()
Checks whether this PropertySet
is a Document
Summary Information.
true
if this PropertySet
represents a Document Summary Information, else false
.public Property[] getProperties() throws NoSingleSectionException
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
.
Section
of this
PropertySet
.
NoSingleSectionException
- if the PropertySet
has
more or less than one Section
.public boolean wasNull() throws NoSingleSectionException
Checks whether the property which the last call to getPropertyIntValue(int)
or getProperty(int)
tried to access
was available or not. This information might be important for
callers of getPropertyIntValue(int)
since the latter
returns 0 if the property does not exist. Using wasNull()
, the caller can distiguish this case from a
property's real value of 0.
true
if the last call to getPropertyIntValue(int)
or getProperty(int)
tried to access a
property that was not available, else false
.
NoSingleSectionException
- if the PropertySet
has
more than one Section
.public Section getFirstSection()
Gets the PropertySet
's first section.
PropertySet
's first section.public Section getSingleSection()
If the PropertySet
has only a single section this
method returns it.
public boolean equals(java.lang.Object o)
Returns true
if the PropertySet is equal
to the specified parameter, else
false
.
equals
in class java.lang.Object
o
- the object to compare this PropertySet with
- Returns:
true
if the objects are equal, false
if not
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |