Class Property

java.lang.Object
org.apache.poi.poifs.property.Property
All Implemented Interfaces:
POIFSViewable, Child
Direct Known Subclasses:
DirectoryProperty, DocumentProperty

public abstract class Property extends Object implements Child, POIFSViewable
This abstract base class is the ancestor of all classes implementing POIFS Property behavior.
Author:
Marc Johnson (mjohnson at apache dot org)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
     
    protected static final byte
     
    protected static final byte
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    Property(int index, byte[] array, int offset)
    Constructor from byte data
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    Get the child property (its index in the Property Table)
    protected int
    get the index for this Property
    Get the name of this property
    Get the next Child, if any
    Get the previous Child, if any
    Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.
    int
    find out the document size
    int
     
    Sets the storage clsid, which is the Class ID of a COM object which reads and writes this stream
    Get an array of objects, some of which may implement POIFSViewable
    Get an Iterator of objects, some of which may implement POIFSViewable
    abstract boolean
     
    static boolean
    isSmall(int length)
    does the length indicate a small document?
    boolean
    Give viewers a hint as to whether to call getViewableArray or getViewableIterator
    protected abstract void
    Perform whatever activities need to be performed prior to writing
    protected void
    setChildProperty(int child)
    Set the child property.
    protected void
    setIndex(int index)
    Set the index for this Property
    protected void
    Set the name; silently truncates the name if it's too long.
    void
    Set the next Child
    protected void
    setNodeColor(byte nodeColor)
    Set the node color.
    void
    Set the previous Child
    protected void
    setPropertyType(byte propertyType)
    Set the property type.
    protected void
    setSize(int size)
    Set the size of the document associated with this Property
    void
    setStartBlock(int startBlock)
    Set the start block for the document referred to by this Property.
    void
    setStorageClsid(ClassID clsidStorage)
    Sets the storage class ID for this property stream.
    boolean
    Based on the currently defined size, should this property use small blocks?
    void
    Write the raw data to an OutputStream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Property

      protected Property()
    • Property

      protected Property(int index, byte[] array, int offset)
      Constructor from byte data
      Parameters:
      index - index number
      array - byte data
      offset - offset into byte data
  • Method Details

    • writeData

      public void writeData(OutputStream stream) throws IOException
      Write the raw data to an OutputStream.
      Parameters:
      stream - the OutputStream to which the data should be written.
      Throws:
      IOException - on problems writing to the specified stream.
    • setStartBlock

      public void setStartBlock(int startBlock)
      Set the start block for the document referred to by this Property.
      Parameters:
      startBlock - the start block index
    • getStartBlock

      public int getStartBlock()
      Returns:
      the start block
    • getSize

      public int getSize()
      find out the document size
      Returns:
      size in bytes
    • shouldUseSmallBlocks

      public boolean shouldUseSmallBlocks()
      Based on the currently defined size, should this property use small blocks?
      Returns:
      true if the size is less than _big_block_minimum_bytes
    • isSmall

      public static boolean isSmall(int length)
      does the length indicate a small document?
      Parameters:
      length - length in bytes
      Returns:
      true if the length is less than _big_block_minimum_bytes
    • getName

      public String getName()
      Get the name of this property
      Returns:
      property name as String
    • isDirectory

      public abstract boolean isDirectory()
      Returns:
      true if a directory type Property
    • getStorageClsid

      public ClassID getStorageClsid()
      Sets the storage clsid, which is the Class ID of a COM object which reads and writes this stream
      Returns:
      storage Class ID for this property stream
    • setName

      protected void setName(String name)
      Set the name; silently truncates the name if it's too long.
      Parameters:
      name - the new name
    • setStorageClsid

      public void setStorageClsid(ClassID clsidStorage)
      Sets the storage class ID for this property stream. This is the Class ID of the COM object which can read and write this property stream
      Parameters:
      clsidStorage - Storage Class ID
    • setPropertyType

      protected void setPropertyType(byte propertyType)
      Set the property type. Makes no attempt to validate the value.
      Parameters:
      propertyType - the property type (root, file, directory)
    • setNodeColor

      protected void setNodeColor(byte nodeColor)
      Set the node color.
      Parameters:
      nodeColor - the node color (red or black)
    • setChildProperty

      protected void setChildProperty(int child)
      Set the child property.
      Parameters:
      child - the child property's index in the Property Table
    • getChildIndex

      protected int getChildIndex()
      Get the child property (its index in the Property Table)
      Returns:
      child property index
    • setSize

      protected void setSize(int size)
      Set the size of the document associated with this Property
      Parameters:
      size - the size of the document, in bytes
    • setIndex

      protected void setIndex(int index)
      Set the index for this Property
      Parameters:
      index - this Property's index within its containing Property Table
    • getIndex

      protected int getIndex()
      get the index for this Property
      Returns:
      the index of this Property within its Property Table
    • preWrite

      protected abstract void preWrite()
      Perform whatever activities need to be performed prior to writing
    • getNextChild

      public Child getNextChild()
      Get the next Child, if any
      Specified by:
      getNextChild in interface Child
      Returns:
      the next Child; may return null
    • getPreviousChild

      public Child getPreviousChild()
      Get the previous Child, if any
      Specified by:
      getPreviousChild in interface Child
      Returns:
      the previous Child; may return null
    • setNextChild

      public void setNextChild(Child child)
      Set the next Child
      Specified by:
      setNextChild in interface Child
      Parameters:
      child - the new 'next' child; may be null, which has the effect of saying there is no 'next' child
    • setPreviousChild

      public void setPreviousChild(Child child)
      Set the previous Child
      Specified by:
      setPreviousChild in interface Child
      Parameters:
      child - the new 'previous' child; may be null, which has the effect of saying there is no 'previous' child
    • getViewableArray

      public Object[] getViewableArray()
      Get an array of objects, some of which may implement POIFSViewable
      Specified by:
      getViewableArray in interface POIFSViewable
      Returns:
      an array of Object; may not be null, but may be empty
    • getViewableIterator

      public Iterator<Object> getViewableIterator()
      Get an Iterator of objects, some of which may implement POIFSViewable
      Specified by:
      getViewableIterator in interface POIFSViewable
      Returns:
      an Iterator; may not be null, but may have an empty back end store
    • preferArray

      public boolean preferArray()
      Give viewers a hint as to whether to call getViewableArray or getViewableIterator
      Specified by:
      preferArray in interface POIFSViewable
      Returns:
      true if a viewer should call getViewableArray, false if a viewer should call getViewableIterator
    • getShortDescription

      public String getShortDescription()
      Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.
      Specified by:
      getShortDescription in interface POIFSViewable
      Returns:
      short description