Package loci.poi.hpsf

Class PropertySet

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int byteOrder
      Specifies this PropertySet's byte order.
      protected ClassID classID
      Specifies this PropertySet's "classID" field.
      protected int format
      Specifies this PropertySet's format.
      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.
      protected int osVersion
      Specifies the version of the operating system that created this PropertySet.
      protected java.util.List sections
      The sections in this PropertySet.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PropertySet()
      Creates an empty (uninitialized) PropertySet.
        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.
    • Field Detail

      • byteOrder

        protected int byteOrder

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

      • format

        protected int format

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

      • osVersion

        protected int osVersion

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

      • 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
      • classID

        protected ClassID classID

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

      • sections

        protected java.util.List sections

        The sections in this PropertySet.

    • Constructor Detail

      • 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​(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.

        Parameters:
        stream - Holds the data making out the property set stream.
        Throws:
        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.
      • PropertySet

        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.

        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.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.
        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 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.IOException

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

        Parameters:
        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.
        Returns:
        true if the stream is a property set stream, else false.
        Throws:
        MarkUnsupportedException - if the InputStream does not support the InputStream.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:
        true if the byte array is a property set stream, false if not.
      • isSummaryInformation

        public boolean isSummaryInformation()

        Checks whether this PropertySet represents a Summary Information.

        Returns:
        true if this PropertySet represents a Summary Information, else false.
      • isDocumentSummaryInformation

        public boolean isDocumentSummaryInformation()

        Checks whether this PropertySet is a Document Summary Information.

        Returns:
        true if this PropertySet represents a Document Summary Information, else false.
      • getProperty

        protected java.lang.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 .

        Parameters:
        id - The property ID
        Returns:
        The property value
        Throws:
        NoSingleSectionException - if the PropertySet has more or less than one Section.
      • getPropertyBooleanValue

        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.

        Parameters:
        id - The property ID
        Returns:
        The property value
        Throws:
        NoSingleSectionException - if the PropertySet has more or less than one Section.
      • getPropertyIntValue

        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.

        Parameters:
        id - The property ID
        Returns:
        The propertyIntValue value
        Throws:
        NoSingleSectionException - if the PropertySet has more or less than one Section.
      • getSingleSection

        public Section getSingleSection()

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

        Returns:
        The singleSection value
      • equals

        public boolean equals​(java.lang.Object o)

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

        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the object to compare this PropertySet with
        Returns:
        true if the objects are equal, false if not
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()