Package loci.poi.hpsf

Class MutableSection


  • public class MutableSection
    extends Section

    Adds writing capability to the Section class.

    Please be aware that this class' functionality will be merged into the Section class at a later time, so the API will change.

    Since:
    2002-02-20
    Version:
    $Id: MutableSection.java 489730 2006-12-22 19:18:16Z bayard $
    • Constructor Detail

      • MutableSection

        public MutableSection()

        Creates an empty mutable section.

      • MutableSection

        public MutableSection​(Section s)

        Constructs a MutableSection by doing a deep copy of an existing Section. All nested Property instances, will be their mutable counterparts in the new MutableSection.

        Parameters:
        s - The section set to copy
    • Method Detail

      • setFormatID

        public void setFormatID​(byte[] formatID)

        Sets the section's format ID.

        Parameters:
        formatID - The section's format ID as a byte array. It components are in big-endian format.
        See Also:
        setFormatID(ClassID), Section.getFormatID()
      • setProperties

        public void setProperties​(Property[] properties)

        Sets this section's properties. Any former values are overwritten.

        Parameters:
        properties - This section's new properties.
      • setProperty

        public void setProperty​(int id,
                                String value)

        Sets the string value of the property with the specified ID.

        Parameters:
        id - The property's ID
        value - The property's value. It will be written as a Unicode string.
        See Also:
        setProperty(int, long, Object), getProperty(long)
      • setProperty

        public void setProperty​(int id,
                                int value)

        Sets the int value of the property with the specified ID.

        Parameters:
        id - The property's ID
        value - The property's value.
        See Also:
        setProperty(int, long, Object), getProperty(long)
      • setProperty

        public void setProperty​(int id,
                                long value)

        Sets the long value of the property with the specified ID.

        Parameters:
        id - The property's ID
        value - The property's value.
        See Also:
        setProperty(int, long, Object), getProperty(long)
      • setProperty

        public void setProperty​(int id,
                                boolean value)

        Sets the boolean value of the property with the specified ID.

        Parameters:
        id - The property's ID
        value - The property's value.
        See Also:
        setProperty(int, long, Object), getProperty(long)
      • setProperty

        public void setProperty​(int id,
                                long variantType,
                                Object value)

        Sets the value and the variant type of the property with the specified ID. If a property with this ID is not yet present in the section, it will be added. An already present property with the specified ID will be overwritten. A default mapping will be used to choose the property's type.

        Parameters:
        id - The property's ID.
        variantType - The property's variant type.
        value - The property's value.
        See Also:
        setProperty(int, String), getProperty(long), Variant
      • removeProperty

        public void removeProperty​(long id)

        Removes a property.

        Parameters:
        id - The ID of the property to be removed
      • setPropertyBooleanValue

        protected void setPropertyBooleanValue​(int id,
                                               boolean value)

        Sets the value of the boolean property with the specified ID.

        Parameters:
        id - The property's ID
        value - The property's value
        See Also:
        setProperty(int, long, Object), getProperty(long), Variant
      • getSize

        public int getSize()

        Returns the section's size.

        Overrides:
        getSize in class Section
        Returns:
        the section's size.
      • write

        public int write​(OutputStream out)
                  throws WritingNotSupportedException,
                         IOException

        Writes this section into an output stream.

        Internally this is done by writing into three byte array output streams: one for the properties, one for the property list and one for the section as such. The two former are appended to the latter when they have received all their data.

        Parameters:
        out - The stream to write into.
        Returns:
        The number of bytes written, i.e. the section's size.
        Throws:
        IOException - if an I/O error occurs
        WritingNotSupportedException - if HPSF does not yet support writing a property's variant type.
      • getPropertyCount

        public int getPropertyCount()

        Overwrites the super class' method to cope with a redundancy: the property count is maintained in a separate member variable, but shouldn't.

        Overrides:
        getPropertyCount in class Section
        Returns:
        The number of properties in this section
      • getProperties

        public Property[] getProperties()

        Gets this section's properties.

        Overrides:
        getProperties in class Section
        Returns:
        this section's properties.
      • getProperty

        public Object getProperty​(long id)

        Gets a property.

        Overrides:
        getProperty in class Section
        Parameters:
        id - The ID of the property to get
        Returns:
        The property or null if there is no such property
      • setDictionary

        public void setDictionary​(Map dictionary)
                           throws IllegalPropertySetDataException

        Sets the section's dictionary. All keys in the dictionary must be Long instances, all values must be Strings. This method overwrites the properties with IDs 0 and 1 since they are reserved for the dictionary and the dictionary's codepage. Setting these properties explicitly might have surprising effects. An application should never do this but always use this method.

        Parameters:
        dictionary - The dictionary
        Throws:
        IllegalPropertySetDataException - if the dictionary's key and value types are not correct.
        See Also:
        Section.getDictionary()
      • setProperty

        public void setProperty​(int id,
                                Object value)

        Sets a property.

        Parameters:
        id - The property ID.
        value - The property's value. The value's class must be one of those supported by HPSF.
      • clear

        public void clear()

        Removes all properties from the section including 0 (dictionary) and 1 (codepage).

      • setCodepage

        public void setCodepage​(int codepage)

        Sets the codepage.

        Parameters:
        codepage - the codepage