Save This Page
Home » poi-src-3.2-FINAL-20081019 » org.apache » poi » hpsf » [javadoc | source]
org.apache.poi.hpsf
public class: PropertySet [javadoc | source]
java.lang.Object
   org.apache.poi.hpsf.PropertySet

Direct Known Subclasses:
    MutablePropertySet, DocumentSummaryInformation, SpecialPropertySet, SummaryInformation

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 and then retrieve the information its needs by calling appropriate methods.

PropertySetFactory#create does its work by calling one of the constructors PropertySet#PropertySet(InputStream) or PropertySet#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.

Since the vast majority of 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 final  byte[] BYTE_ORDER_ASSERTION   

The "byteOrder" field must equal this value.

 
protected  int byteOrder   

Specifies this PropertySet 's byte order. See the HPFS documentation for details!

 
static final  byte[] FORMAT_ASSERTION   

The "format" field must equal this value.

 
protected  int format   

Specifies this PropertySet 's format. See the HPFS documentation for details!

 
protected  int osVersion   

Specifies the version of the operating system that created this PropertySet . See the HPFS documentation for details!

 
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.

 
protected  ClassID classID   

Specifies this PropertySet 's "classID" field. See the HPFS documentation for details!

 
protected  List sections   

The sections in this PropertySet .

 
Constructor:
 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.

 public PropertySet(InputStream stream) throws IOException, NoPropertySetStreamException, MarkUnsupportedException, 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.

    Parameters:
    stream - Holds the data making out the property set stream.
    Throws:
    MarkUnsupportedException - if the stream does not support the InputStream#markSupported method.
    IOException - if the InputStream cannot not be accessed as needed.
    NoPropertySetStreamException - if the input stream does not contain a property set.
    UnsupportedEncodingException - if a character encoding is not supported.
    exception: NoPropertySetStreamException - if the input stream does not contain a property set.
    exception: UnsupportedEncodingException - if a character encoding is not supported.
 public PropertySet(byte[] stream) throws NoPropertySetStreamException, UnsupportedEncodingException 

    Creates a PropertySet instance 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.
    exception: UnsupportedEncodingException - if the codepage is not supported.
 public PropertySet(byte[] stream,
    int offset,
    int length) throws NoPropertySetStreamException, UnsupportedEncodingException 

    Creates a PropertySet instance 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.
    exception: UnsupportedEncodingException - if the codepage is not supported.
Method from org.apache.poi.hpsf.PropertySet Summary:
equals,   getByteOrder,   getClassID,   getFirstSection,   getFormat,   getOSVersion,   getProperties,   getProperty,   getPropertyBooleanValue,   getPropertyIntValue,   getSectionCount,   getSections,   getSingleSection,   hashCode,   isDocumentSummaryInformation,   isPropertySetStream,   isPropertySetStream,   isSummaryInformation,   toString,   wasNull
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.hpsf.PropertySet Detail:
 public boolean equals(Object o) 

    Returns true if the PropertySet is equal to the specified parameter, else false.

 public int getByteOrder() 

    Returns the property set stream's low-level "byte order" field. It is always 0xFFFE .

 public ClassID getClassID() 

    Returns the property set stream's low-level "class ID" field.

 public Section getFirstSection() 
 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 Property[] getProperties() throws NoSingleSectionException 
 protected Object getProperty(int id) throws NoSingleSectionException 

    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 #wasNull will return true .

 protected boolean getPropertyBooleanValue(int id) throws NoSingleSectionException 

    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 #wasNull will return true to let the caller distinguish that case from a real property value of false.

 protected int getPropertyIntValue(int id) throws NoSingleSectionException 

    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 return true to let the caller distinguish that case from a real property value of 0.

 public int getSectionCount() 

    Returns the number of Section s in the property set.

 public List getSections() 

    Returns the Section s in the property set.

 public Section getSingleSection() 

    If the PropertySet has only a single section this method returns it.

 public int hashCode() 
 public boolean isDocumentSummaryInformation() 

    Checks whether this PropertySet is a Document Summary Information.

 public static boolean isPropertySetStream(InputStream stream) throws IOException, MarkUnsupportedException 

    Checks whether an InputStream is in the Horrible Property Set Format.

 public static boolean isPropertySetStream(byte[] src,
    int offset,
    int length) 

    Checks whether a byte array is in the Horrible Property Set Format.

 public boolean isSummaryInformation() 

    Checks whether this PropertySet represents a Summary Information.

 public String toString() 
 public boolean wasNull() throws NoSingleSectionException 

    Checks whether the property which the last call to #getPropertyIntValue or #getProperty tried to access was available or not. This information might be important for callers of #getPropertyIntValue 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.