Package org.apache.poi.poifs.filesystem
Class FilteringDirectoryNode
java.lang.Object
org.apache.poi.poifs.filesystem.FilteringDirectoryNode
- All Implemented Interfaces:
Iterable<Entry>
,DirectoryEntry
,Entry
A DirectoryEntry filter, which exposes another
DirectoryEntry less certain parts.
This is typically used when copying or comparing
Filesystems.
-
Constructor Summary
ConstructorsConstructorDescriptionFilteringDirectoryNode
(DirectoryEntry directory, Collection<String> excludes) Creates a filter round the specified directory, which will exclude entries such as "MyNode" and "MyDir/IgnoreNode". -
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 DocumentEntryboolean
delete()
Delete this Entry.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).getName()
get the name of the Entryget this Entry's parent (the DirectoryEntry that owns this Entry).Gets the storage clsid of the directory entryboolean
Checks if entry with specified name presentboolean
is this a DirectoryEntry?boolean
is this a DocumentEntry?boolean
isEmpty()
is this DirectoryEntry empty?iterator()
boolean
Rename this Entry.void
setStorageClsid
(ClassID clsidStorage) Sets the storage clsid for the directory entryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FilteringDirectoryNode
Creates a filter round the specified directory, which will exclude entries such as "MyNode" and "MyDir/IgnoreNode". The excludes can stretch into children, if they contain a /.- Parameters:
directory
- The Directory to filterexcludes
- The Entries to exclude
-
-
Method Details
-
createDirectory
Description copied from interface:DirectoryEntry
create a new DirectoryEntry- Specified by:
createDirectory
in interfaceDirectoryEntry
- Parameters:
name
- the name of the new DirectoryEntry- Returns:
- the new DirectoryEntry
- Throws:
IOException
-
createDocument
Description copied from interface:DirectoryEntry
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
-
createDocument
public DocumentEntry createDocument(String name, int size, POIFSWriterListener writer) throws IOException Description copied from interface:DirectoryEntry
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
-
getEntries
Description copied from interface:DirectoryEntry
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.
-
iterator
-
getEntryCount
public int getEntryCount()Description copied from interface:DirectoryEntry
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
-
getEntryNames
Description copied from interface:DirectoryEntry
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()Description copied from interface:DirectoryEntry
is this DirectoryEntry empty?- Specified by:
isEmpty
in interfaceDirectoryEntry
- Returns:
- true if this instance contains no Entry instances
-
hasEntry
Description copied from interface:DirectoryEntry
Checks if entry with specified name present- Specified by:
hasEntry
in interfaceDirectoryEntry
-
getEntry
Description copied from interface:DirectoryEntry
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
-
getStorageClsid
Description copied from interface:DirectoryEntry
Gets the storage clsid of the directory entry- Specified by:
getStorageClsid
in interfaceDirectoryEntry
- Returns:
- storage Class ID
-
setStorageClsid
Description copied from interface:DirectoryEntry
Sets the storage clsid for the directory entry- Specified by:
setStorageClsid
in interfaceDirectoryEntry
- Parameters:
clsidStorage
- storage Class ID
-
delete
public boolean delete()Description copied from interface:Entry
Delete this Entry. This operation should succeed, but there are special circumstances when it will not: If this Entry is the root of the Entry tree, it cannot be deleted, as there is no way to create another one. If this Entry is a directory, it cannot be deleted unless it is empty. -
renameTo
Description copied from interface:Entry
Rename this Entry. This operation will fail if: There is a sibling Entry (i.e., an Entry whose parent is the same as this Entry's parent) with the same name. This Entry is the root of the Entry tree. Its name is dictated by the Filesystem and many not be changed. -
getName
Description copied from interface:Entry
get the name of the Entry -
getParent
Description copied from interface:Entry
get this Entry's parent (the DirectoryEntry that owns this Entry). All Entry objects, except the root Entry, has a parent. -
isDirectoryEntry
public boolean isDirectoryEntry()Description copied from interface:Entry
is this a DirectoryEntry?- Specified by:
isDirectoryEntry
in interfaceEntry
- Returns:
- true if the Entry is a DirectoryEntry, else false
-
isDocumentEntry
public boolean isDocumentEntry()Description copied from interface:Entry
is this a DocumentEntry?- Specified by:
isDocumentEntry
in interfaceEntry
- Returns:
- true if the Entry is a DocumentEntry, else false
-