Class PropertySet
- Direct Known Subclasses:
MutablePropertySet
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 Sections, and each
Section has a Property array. Use getSections() to retrieve the Sections, then call Section.getProperties() for each Section to get hold of the
Property arrays.
PropertySets 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).- Since:
- 2002-02-09
- Version:
- $Id: PropertySet.java 489730 2006-12-22 19:18:16Z bayard $
- Author:
- Rainer Klute <klute@rainer-klute.de>, Drew Varner (Drew.Varner hanginIn sc.edu)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intSpecifies thisPropertySet's byte order.protected ClassIDSpecifies thisPropertySet's "classID" field.protected intSpecifies thisPropertySet's format.static final intIf the OS version field holds this value the property set stream was created on a Macintosh system.static final intIf the OS version field holds this value the property set stream was created on a 16-bit Windows system.static final intIf the OS version field holds this value the property set stream was created on a 32-bit Windows system.protected intSpecifies the version of the operating system that created thisPropertySet.protected ListThe sections in thisPropertySet. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates an empty (uninitialized)PropertySet.PropertySet(byte[] stream) Creates aPropertySetinstance from a byte array that represents a stream in the Horrible Property Set Format.PropertySet(byte[] stream, int offset, int length) Creates aPropertySetinstance from a byte array that represents a stream in the Horrible Property Set Format.PropertySet(InputStream stream) Creates aPropertySetinstance from anInputStreamin the Horrible Property Set Format. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif 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.If thePropertySethas only a single section this method returns it.inthashCode()booleanChecks whether thisPropertySetis a Document Summary Information.static booleanisPropertySetStream(byte[] src, int offset, int length) Checks whether a byte array is in the Horrible Property Set Format.static booleanisPropertySetStream(InputStream stream) Checks whether anInputStreamis in the Horrible Property Set Format.booleanChecks whether thisPropertySetrepresents a Summary Information.toString()booleanwasNull()Checks whether the property which the last call togetPropertyIntValue(int)orgetProperty(int)tried to access was available or not.
-
Field Details
-
byteOrder
protected int byteOrderSpecifies this
PropertySet's byte order. See the HPFS documentation for details! -
format
protected int formatSpecifies this
PropertySet's format. See the HPFS documentation for details! -
osVersion
protected int osVersionSpecifies the version of the operating system that created this
PropertySet. See the HPFS documentation for details! -
OS_WIN16
public static final int OS_WIN16If the OS version field holds this value the property set stream was created on a 16-bit Windows system.
- See Also:
-
OS_MACINTOSH
public static final int OS_MACINTOSHIf the OS version field holds this value the property set stream was created on a Macintosh system.
- See Also:
-
OS_WIN32
public static final int OS_WIN32If the OS version field holds this value the property set stream was created on a 32-bit Windows system.
- See Also:
-
classID
Specifies this
PropertySet's "classID" field. See the HPFS documentation for details! -
sections
The sections in this
PropertySet.
-
-
Constructor Details
-
PropertySet
protected PropertySet()Creates an empty (uninitialized)
PropertySet.Please note: For the time being this constructor is protected since it is used for internal purposes only, but expect it to become public once the property set's writing functionality is implemented.
-
PropertySet
public PropertySet(InputStream stream) throws NoPropertySetStreamException, MarkUnsupportedException, IOException, UnsupportedEncodingException Creates a
PropertySetinstance from anInputStreamin 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.
- Parameters:
stream- Holds the data making out the property set stream.- Throws:
MarkUnsupportedException- if the stream does not support theInputStream.markSupported()method.IOException- if theInputStreamcannot not be accessed as needed.NoPropertySetStreamException- if the input stream does not contain a property set.UnsupportedEncodingException- if a character encoding is not supported.
-
PropertySet
public PropertySet(byte[] stream, int offset, int length) throws NoPropertySetStreamException, UnsupportedEncodingException Creates a
PropertySetinstance from a byte array that represents a stream in the Horrible Property Set Format.- Parameters:
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.- Throws:
NoPropertySetStreamException- if the byte array is not a property set stream.UnsupportedEncodingException- if the codepage is not supported.
-
PropertySet
Creates a
PropertySetinstance from a byte array that represents a stream in the Horrible Property Set Format.- Parameters:
stream- The byte array holding the stream data. The complete byte array contents is the stream data.- Throws:
NoPropertySetStreamException- if the byte array is not a property set stream.UnsupportedEncodingException- if the codepage is not supported.
-
-
Method Details
-
getByteOrder
public int getByteOrder()Returns the property set stream's low-level "byte order" field. It is always 0xFFFE .
- Returns:
- The property set stream's low-level "byte order" field.
-
getFormat
public int getFormat()Returns the property set stream's low-level "format" field. It is always 0x0000 .
- Returns:
- The property set stream's low-level "format" field.
-
getOSVersion
public int getOSVersion()Returns the property set stream's low-level "OS version" field.
- Returns:
- The property set stream's low-level "OS version" field.
-
getClassID
Returns the property set stream's low-level "class ID" field.
- Returns:
- The property set stream's low-level "class ID" field.
-
getSectionCount
public int getSectionCount()Returns the number of
Sections in the property set.- Returns:
- The number of
Sections in the property set.
-
getSections
Returns the
Sections in the property set.- Returns:
- The
Sections in the property set.
-
isPropertySetStream
public static boolean isPropertySetStream(InputStream stream) throws MarkUnsupportedException, IOException Checks whether an
InputStreamis in the Horrible Property Set Format.- Parameters:
stream- TheInputStreamto 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. TheInputStreammust support theInputStream.mark(int)method.- Returns:
trueif the stream is a property set stream, elsefalse.- Throws:
MarkUnsupportedException- if theInputStreamdoes not support theInputStream.mark(int)method.IOException- if an I/O error occurs
-
isPropertySetStream
public static boolean isPropertySetStream(byte[] src, int offset, int length) Checks whether a byte array is in the Horrible Property Set Format.
- Parameters:
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.- Returns:
trueif the byte array is a property set stream,falseif not.
-
isSummaryInformation
public boolean isSummaryInformation()Checks whether this
PropertySetrepresents a Summary Information.- Returns:
trueif thisPropertySetrepresents a Summary Information, elsefalse.
-
isDocumentSummaryInformation
public boolean isDocumentSummaryInformation()Checks whether this
PropertySetis a Document Summary Information.- Returns:
trueif thisPropertySetrepresents a Document Summary Information, elsefalse.
-
getProperties
Convenience 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.- Returns:
- The properties of the only
Sectionof thisPropertySet. - Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.
-
getProperty
Convenience method returning the value of the property with the specified ID. If the property is not available,
nullis returned and a subsequent call towasNull()will returntrue.- Parameters:
id- The property ID- Returns:
- The property value
- Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.
-
getPropertyBooleanValue
Convenience method returning the value of a boolean property with the specified ID. If the property is not available,
falseis returned. A subsequent call towasNull()will returntrueto let the caller distinguish that case from a real property value offalse.- Parameters:
id- The property ID- Returns:
- The property value
- Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.
-
getPropertyIntValue
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
wasNull()will returntrueto let the caller distinguish that case from a real property value of 0.- Parameters:
id- The property ID- Returns:
- The propertyIntValue value
- Throws:
NoSingleSectionException- if thePropertySethas more or less than oneSection.
-
wasNull
Checks whether the property which the last call to
getPropertyIntValue(int)orgetProperty(int)tried to access was available or not. This information might be important for callers ofgetPropertyIntValue(int)since the latter returns 0 if the property does not exist. UsingwasNull(), the caller can distiguish this case from a property's real value of 0.- Returns:
trueif the last call togetPropertyIntValue(int)orgetProperty(int)tried to access a property that was not available, elsefalse.- Throws:
NoSingleSectionException- if thePropertySethas more than oneSection.
-
getFirstSection
Gets the
PropertySet's first section.- Returns:
- The
PropertySet's first section.
-
getSingleSection
If the
PropertySethas only a single section this method returns it.- Returns:
- The singleSection value
-
equals
Returns
trueif thePropertySetis equal to the specified parameter, elsefalse. -
hashCode
public int hashCode() -
toString
-