# Class Folder

java.lang.Object
com.independentsoft.pst.Folder

public class Folder extends Object
The Class Folder.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Folder()`
  Initializes a new, empty `Folder` that can be added to a PST with addFolder.
  `Folder(String displayName)`
  Initializes a new `Folder` with the given display name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `addFolder(Folder folder)`
  Adds a subfolder under this folder.
  `long`
  `addItem(Item item)`
  Adds an item to this folder.
  `List<Long>`
  `addItems(List<Item> items)`
  Adds many items to this folder in a single pass (one contents-table rebuild and one count update for all).
  `int`
  `getChildrenCount()`
  Gets the children count.
  `String`
  `getComment()`
  Gets the comment.
  `String`
  `getContainerClass()`
  Gets the container class.
  `String`
  `getDisplayName()`
  Gets the display name.
  `byte[]`
  `getEntryId()`
  Gets the entry id.
  `Folder`
  `getFolder(String displayName)`
  Gets the folder.
  `List<Folder>`
  `getFolders()`
  Gets the folders.
  `List<Folder>`
  `getFolders(boolean recursive)`
  Gets the folders.
  `long`
  `getId()`
  Gets the id.
  `int`
  `getItemCount()`
  Gets the item count.
  `List<Item>`
  `getItems()`
  Gets the items.
  `List<Item>`
  `getItems(int endIndex)`
  Gets the items.
  `List<Item>`
  `getItems(int startIndex, int endIndex)`
  Gets the items.
  `long`
  `getParentId()`
  Gets the parent id.
  `Table`
  `getTable()`
  Gets the table.
  `int`
  `getUnreadItemCount()`
  Gets the unread item count.
  `boolean`
  `hasSubFolders()`
  Checks for sub folders.
  `void`
  `setComment(String comment)`
  Sets the comment.
  `void`
  `setContainerClass(String containerClass)`
  Sets the container class.
  `void`
  `setDisplayName(String displayName)`
  Sets the display name.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Folder

    public Folder()
    Initializes a new, empty `Folder` that can be added to a PST with addFolder.

  - ### Folder

    public Folder(String displayName)
    Initializes a new `Folder` with the given display name.
    Parameters:
      `displayName` - the folder display name.

- ## Method Details

  - ### getFolders

    public List<Folder> getFolders(boolean recursive) throws IOException
    Gets the folders.
    Parameters:
      `recursive` - the recursive
    Returns:
      the folders
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getFolder

    public Folder getFolder(String displayName) throws IOException
    Gets the folder.
    Parameters:
      `displayName` - the display name
    Returns:
      the folder
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getFolders

    public List<Folder> getFolders() throws IOException
    Gets the folders.
    Returns:
      the folders
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getItems

    public List<Item> getItems() throws IOException
    Gets the items.
    Returns:
      the items
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getItems

    public List<Item> getItems(int endIndex) throws IOException
    Gets the items.
    Parameters:
      `endIndex` - the end index
    Returns:
      the items
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getItems

    public List<Item> getItems(int startIndex, int endIndex) throws IOException
    Gets the items.
    Parameters:
      `startIndex` - the start index
      `endIndex` - the end index
    Returns:
      the items
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getId

    public long getId()
    Gets the id.
    Returns:
      the id

  - ### getParentId

    public long getParentId()
    Gets the parent id.
    Returns:
      the parent id

  - ### getTable

    public Table getTable()
    Gets the table.
    Returns:
      the table

  - ### getDisplayName

    public String getDisplayName()
    Gets the display name.
    Returns:
      the display name

  - ### setDisplayName

    public void setDisplayName(String displayName) throws IOException
    Sets the display name. For a folder from an editable store the change is persisted on the next save().
    Parameters:
      `displayName` - the display name
    Throws:
      `IOException` - if an I/O error occurs

  - ### getComment

    public String getComment()
    Gets the comment.
    Returns:
      the comment

  - ### setComment

    public void setComment(String comment) throws IOException
    Sets the comment. For a folder from an editable store the change is persisted on the next save().
    Parameters:
      `comment` - the comment
    Throws:
      `IOException` - if an I/O error occurs

  - ### getItemCount

    public int getItemCount()
    Gets the item count.
    Returns:
      the item count

  - ### getUnreadItemCount

    public int getUnreadItemCount()
    Gets the unread item count.
    Returns:
      the unread item count

  - ### hasSubFolders

    public boolean hasSubFolders()
    Checks for sub folders.
    Returns:
      true, if successful

  - ### getContainerClass

    public String getContainerClass()
    Gets the container class.
    Returns:
      the container class

  - ### setContainerClass

    public void setContainerClass(String containerClass) throws IOException
    Sets the container class. For a folder from an editable store the change is persisted on the next save().
    Parameters:
      `containerClass` - the container class
    Throws:
      `IOException` - if an I/O error occurs

  - ### getChildrenCount

    public int getChildrenCount()
    Gets the children count.
    Returns:
      the children count

  - ### getEntryId

    public byte[] getEntryId()
    Gets the entry id.
    Returns:
      the entry id

  - ### addItem

    public long addItem(Item item) throws IOException
    Adds an item to this folder. The folder must have been obtained from `PstFile.getRoot()` of an editable store (e.g. `PstFile.create(String)`). Returns the new item's node id.
    Parameters:
      `item` - the item to add.
    Returns:
      the new item's NID.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### addItems

    public List<Long> addItems(List<Item> items) throws IOException
    Adds many items to this folder in a single pass (one contents-table rebuild and one count update for all).
    Parameters:
      `items` - the items to add.
    Returns:
      the new items' NIDs.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### addFolder

    public long addFolder(Folder folder) throws IOException
    Adds a subfolder under this folder. Returns the new folder's node id.
    Parameters:
      `folder` - the subfolder to add.
    Returns:
      the new folder's NID.
    Throws:
      `IOException` - if an I/O error occurs.