Package org.apache.poi.poifs.filesystem
Class DirectoryNode
java.lang.Object
org.apache.poi.poifs.filesystem.EntryNode
org.apache.poi.poifs.filesystem.DirectoryNode
- All Implemented Interfaces:
Iterable<Entry>
,POIFSViewable
,DirectoryEntry
,Entry
public class DirectoryNode
extends EntryNode
implements DirectoryEntry, POIFSViewable, Iterable<Entry>
Simple implementation of DirectoryEntry
-
Method Summary
Modifier and TypeMethodDescriptioncreateDirectory
(String name) create a new DirectoryEntrycreateDocument
(String name, int size, POIFSWriterListener writer) create a new DocumentEntry; the data will be provided latercreateDocument
(String name, InputStream stream) create a new DocumentEntrycreateDocumentInputStream
(String documentName) open a document in the directory's entry's list of entriescreateDocumentInputStream
(Entry document) open a document in the directory's entry's list of entriescreateOrUpdateDocument
(String name, InputStream stream) Set the contents of a document, creating if needed, otherwise updating.get an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)get a specified Entry by nameint
find out how many Entry instances are contained directly within this DirectoryEntryget the names of all the Entries contained directly in this instance (in other words, names of children only; no grandchildren etc).getPath()
Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.Gets the storage clsid of the directory entryObject[]
Get an array of objects, some of which may implement POIFSViewableGet an Iterator of objects, some of which may implement POIFSViewableboolean
Checks if entry with specified name presentboolean
is this a DirectoryEntry?boolean
isEmpty()
is this DirectoryEntry empty?iterator()
Returns an Iterator over all the entriesboolean
Give viewers a hint as to whether to call getViewableArray or getViewableIteratorvoid
setStorageClsid
(ClassID clsidStorage) Sets the storage clsid for the directory entryReturns a Spliterator over all the entriesMethods inherited from class org.apache.poi.poifs.filesystem.EntryNode
delete, getName, getParent, isDocumentEntry, renameTo
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
getPath
- Returns:
- this directory's path representation
-
getFileSystem
- Returns:
- the filesystem that this belongs to
-
createDocumentInputStream
open a document in the directory's entry's list of entries- Parameters:
documentName
- the name of the document to be opened- Returns:
- a newly opened DocumentInputStream
- Throws:
IOException
- if the document does not exist or the name is that of a DirectoryEntry
-
createDocumentInputStream
open a document in the directory's entry's list of entries- Parameters:
document
- the document to be opened- Returns:
- a newly opened DocumentInputStream or DocumentInputStream
- Throws:
IOException
- if the document does not exist or the name is that of a DirectoryEntry
-
getEntries
get an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)- Specified by:
getEntries
in interfaceDirectoryEntry
- Returns:
- iterator; never null, but hasNext() may return false immediately (i.e., this DirectoryEntry is empty). All objects retrieved by next() are guaranteed to be implementations of Entry.
-
getEntryNames
get the names of all the Entries contained directly in this instance (in other words, names of children only; no grandchildren etc).- Specified by:
getEntryNames
in interfaceDirectoryEntry
- Returns:
- the names of all the entries that may be retrieved with getEntry(String), which may be empty (if this DirectoryEntry is empty)
-
isEmpty
public boolean isEmpty()is this DirectoryEntry empty?- Specified by:
isEmpty
in interfaceDirectoryEntry
- Returns:
- true if this instance contains no Entry instances
-
getEntryCount
public int getEntryCount()find out how many Entry instances are contained directly within this DirectoryEntry- Specified by:
getEntryCount
in interfaceDirectoryEntry
- Returns:
- number of immediately (no grandchildren etc.) contained Entry instances
-
hasEntry
Description copied from interface:DirectoryEntry
Checks if entry with specified name present- Specified by:
hasEntry
in interfaceDirectoryEntry
-
getEntry
get a specified Entry by name- Specified by:
getEntry
in interfaceDirectoryEntry
- Parameters:
name
- the name of the Entry to obtain.- Returns:
- the specified Entry, if it is directly contained in this DirectoryEntry
- Throws:
FileNotFoundException
- if no Entry with the specified name exists in this DirectoryEntry
-
createDocument
create a new DocumentEntry- Specified by:
createDocument
in interfaceDirectoryEntry
- Parameters:
name
- the name of the new DocumentEntrystream
- the InputStream from which to create the new DocumentEntry- Returns:
- the new DocumentEntry
- Throws:
IOException
- if the document can't be created
-
createDocument
public DocumentEntry createDocument(String name, int size, POIFSWriterListener writer) throws IOException create a new DocumentEntry; the data will be provided later- Specified by:
createDocument
in interfaceDirectoryEntry
- Parameters:
name
- the name of the new DocumentEntrysize
- the size of the new DocumentEntrywriter
- the writer of the new DocumentEntry- Returns:
- the new DocumentEntry
- Throws:
IOException
- if the document can't be created
-
createDirectory
create a new DirectoryEntry- Specified by:
createDirectory
in interfaceDirectoryEntry
- Parameters:
name
- the name of the new DirectoryEntry- Returns:
- the new DirectoryEntry
- Throws:
IOException
- if the directory can't be created
-
createOrUpdateDocument
Set the contents of a document, creating if needed, otherwise updating. Returns the created / updated DocumentEntry- Parameters:
name
- the name of the new or existing DocumentEntrystream
- the InputStream from which to populate the DocumentEntry- Returns:
- the new or updated DocumentEntry
- Throws:
IOException
- if the document can't be created or its content be replaced
-
getStorageClsid
Gets the storage clsid of the directory entry- Specified by:
getStorageClsid
in interfaceDirectoryEntry
- Returns:
- storage Class ID
-
setStorageClsid
Sets the storage clsid for the directory entry- Specified by:
setStorageClsid
in interfaceDirectoryEntry
- Parameters:
clsidStorage
- storage Class ID
-
isDirectoryEntry
public boolean isDirectoryEntry()is this a DirectoryEntry?- Specified by:
isDirectoryEntry
in interfaceEntry
- Overrides:
isDirectoryEntry
in classEntryNode
- Returns:
- true if the Entry is a DirectoryEntry, else false
-
getViewableArray
Get an array of objects, some of which may implement POIFSViewable- Specified by:
getViewableArray
in interfacePOIFSViewable
- Returns:
- an array of Object; may not be null, but may be empty
-
getViewableIterator
Get an Iterator of objects, some of which may implement POIFSViewable- Specified by:
getViewableIterator
in interfacePOIFSViewable
- 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 interfacePOIFSViewable
- Returns:
- true if a viewer should call getViewableArray, false if a viewer should call getViewableIterator
-
getShortDescription
Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.- Specified by:
getShortDescription
in interfacePOIFSViewable
- Returns:
- short description
-
iterator
Returns an Iterator over all the entries -
spliterator
Returns a Spliterator over all the entries- Specified by:
spliterator
in interfaceIterable<Entry>
- Since:
- POI 5.2.0
-