Class PropertySet
- java.lang.Object
-
- org.apache.poi.hpsf.PropertySet
-
- Direct Known Subclasses:
- MutablePropertySet
public class PropertySet extends java.lang.ObjectRepresents 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(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)and then retrieve the information its needs by calling appropriate methods.PropertySetFactory.create(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)does its work by calling one of the constructorsPropertySet(InputStream)orPropertySet(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
Since the vast majority ofPropertySethas a list ofSections, and eachSectionhas aPropertyarray. UsegetSections()to retrieve theSections, then callSection.getProperties()for eachSectionto get hold of thePropertyarrays.PropertySets contains only a singleSection, the convenience methodgetProperties()returns the properties of aPropertySet'sSection(throwing aNoSingleSectionExceptionif thePropertySetcontains more (or less) than exactly oneSection).
-
-
Field Summary
Fields Modifier and Type Field and Description static intOS_MACINTOSHIf the OS version field holds this value the property set stream was created on a Macintosh system.static intOS_WIN16If the OS version field holds this value the property set stream was created on a 16-bit Windows system.static intOS_WIN32If the OS version field holds this value the property set stream was created on a 32-bit Windows system.
-
Constructor Summary
Constructors Constructor and Description 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(java.io.InputStream stream)Creates aPropertySetinstance from anInputStreamin the Horrible Property Set Format.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description 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.intgetSectionCount()Returns the number ofSections in the property set.java.util.List<Section>getSections()Returns theSections in the property set.SectiongetSingleSection()If thePropertySethas only a single section this method returns it.inthashCode()booleanisDocumentSummaryInformation()Checks 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(java.io.InputStream stream)Checks whether anInputStreamis in the Horrible Property Set Format.booleanisSummaryInformation()Checks whether thisPropertySetrepresents a Summary Information.java.lang.StringtoString()booleanwasNull()Checks whether the property which the last call togetPropertyIntValue(int)orgetProperty(int)tried to access was available or not.
-
-
-
Field Detail
-
OS_WIN16
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.
- See Also:
- Constant Field Values
-
OS_MACINTOSH
public static final int OS_MACINTOSH
If the OS version field holds this value the property set stream was created on a Macintosh system.
- See Also:
- Constant Field Values
-
OS_WIN32
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.
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PropertySet
public PropertySet(java.io.InputStream stream) throws NoPropertySetStreamException, MarkUnsupportedException, java.io.IOException, java.io.UnsupportedEncodingExceptionCreates 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.java.io.IOException- if theInputStreamcannot 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.
-
PropertySet
public PropertySet(byte[] stream, int offset, int length) throws NoPropertySetStreamException, java.io.UnsupportedEncodingExceptionCreates 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.java.io.UnsupportedEncodingException- if the codepage is not supported.
-
PropertySet
public PropertySet(byte[] stream) throws NoPropertySetStreamException, java.io.UnsupportedEncodingExceptionCreates 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.java.io.UnsupportedEncodingException- if the codepage is not supported.
-
-
Method Detail
-
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
public ClassID 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
public java.util.List<Section> getSections()
Returns the
Sections in the property set.- Returns:
- The
Sections in the property set.
-
isPropertySetStream
public static boolean isPropertySetStream(java.io.InputStream stream) throws MarkUnsupportedException, java.io.IOExceptionChecks 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.java.io.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
public Property[] getProperties() throws NoSingleSectionException
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.
-
wasNull
public boolean wasNull() throws NoSingleSectionExceptionChecks 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
public Section getFirstSection()
Gets the
PropertySet's first section.- Returns:
- The
PropertySet's first section.
-
getSingleSection
public Section getSingleSection()
If the
PropertySethas only a single section this method returns it.- Returns:
- The singleSection value
-
equals
public boolean equals(java.lang.Object o)
Returns
trueif thePropertySetis equal to the specified parameter, elsefalse.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- the object to compare thisPropertySetwith- Returns:
trueif the objects are equal,falseif not
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG