Class DirectoryNode
java.lang.Object
org.docx4j.org.apache.poi.poifs.filesystem.EntryNode
org.docx4j.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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NPOIFSFileSystemprivate OPOIFSFileSystemprivate POIFSDocumentPath -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDirectoryNode(DirectoryProperty property, DirectoryNode parent, OPOIFSFileSystem ofilesystem, NPOIFSFileSystem nfilesystem) (package private)DirectoryNode(DirectoryProperty property, NPOIFSFileSystem nfilesystem, DirectoryNode parent) create a DirectoryNode.(package private)DirectoryNode(DirectoryProperty property, OPOIFSFileSystem filesystem, DirectoryNode parent) create a DirectoryNode. -
Method Summary
Modifier and TypeMethodDescription(package private) booleanchangeName(String oldName, String newName) Change a contained Entry's namecreateDirectory(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 DocumentEntry(package private) DocumentEntrycreateDocument(NPOIFSDocument document) create a new DocumentEntry(package private) DocumentEntrycreateDocument(OPOIFSDocument document) 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 entries(package private) booleandeleteEntry(EntryNode entry) Delete an entryget an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)get a specified Entry by nameintfind 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).If this is NPOIFS based, return the NPOIFSFileSystem that this belong to, otherwise Null if OPOIFS basedIf this is OPOIFS based, return the NPOIFSFileSystem that this belong to, otherwise Null if NPOIFS basedgetPath()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 POIFSViewablebooleanChecks if entry with specified name presentprotected booleanextensions use this method to verify internal rules regarding deletion of the underlying store.booleanis this a DirectoryEntry?booleanisEmpty()is this DirectoryEntry empty?iterator()Returns an Iterator over all the entriesbooleanGive viewers a hint as to whether to call getViewableArray or getViewableIteratorvoidsetStorageClsid(ClassID clsidStorage) Sets the storage clsid for the directory entryMethods inherited from class org.docx4j.org.apache.poi.poifs.filesystem.EntryNode
delete, getName, getParent, getProperty, isDocumentEntry, isRoot, renameToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.docx4j.org.apache.poi.poifs.filesystem.Entry
delete, getName, getParent, isDocumentEntry, renameToMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
_byname
-
_entries
-
_ofilesystem
-
_nfilesystem
-
_path
-
-
Constructor Details
-
DirectoryNode
DirectoryNode(DirectoryProperty property, OPOIFSFileSystem filesystem, DirectoryNode parent) create a DirectoryNode. This method is not public by design; it is intended strictly for the internal use of this package- Parameters:
property- the DirectoryProperty for this DirectoryEntryfilesystem- the OPOIFSFileSystem we belong toparent- the parent of this entry
-
DirectoryNode
DirectoryNode(DirectoryProperty property, NPOIFSFileSystem nfilesystem, DirectoryNode parent) create a DirectoryNode. This method is not public by design; it is intended strictly for the internal use of this package- Parameters:
property- the DirectoryProperty for this DirectoryEntrynfilesystem- the NPOIFSFileSystem we belong toparent- the parent of this entry
-
DirectoryNode
private DirectoryNode(DirectoryProperty property, DirectoryNode parent, OPOIFSFileSystem ofilesystem, NPOIFSFileSystem nfilesystem)
-
-
Method Details
-
getPath
- Returns:
- this directory's path representation
-
getFileSystem
- Returns:
- the filesystem that this belongs to
-
getOFileSystem
If this is OPOIFS based, return the NPOIFSFileSystem that this belong to, otherwise Null if NPOIFS based- Returns:
- the filesystem that this belongs to
-
getNFileSystem
If this is NPOIFS based, return the NPOIFSFileSystem that this belong to, otherwise Null if OPOIFS based- 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 NDocumentInputStream
- Throws:
IOException- if the document does not exist or the name is that of a DirectoryEntry
-
createDocument
create a new DocumentEntry- Parameters:
document- the new document- Returns:
- the new DocumentEntry
- Throws:
IOException
-
createDocument
create a new DocumentEntry- Parameters:
document- the new document- Returns:
- the new DocumentEntry
- Throws:
IOException
-
changeName
Change a contained Entry's name- Parameters:
oldName- the original namenewName- the new name- Returns:
- true if the operation succeeded, else false
-
deleteEntry
Delete an entry- Parameters:
entry- the EntryNode to be deleted- Returns:
- true if the entry was deleted, else false
-
getEntries
get an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)- Specified by:
getEntriesin 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:
getEntryNamesin 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:
isEmptyin 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:
getEntryCountin interfaceDirectoryEntry- Returns:
- number of immediately (no grandchildren etc.) contained Entry instances
-
hasEntry
Description copied from interface:DirectoryEntryChecks if entry with specified name present- Specified by:
hasEntryin interfaceDirectoryEntry
-
getEntry
get a specified Entry by name- Specified by:
getEntryin 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:
createDocumentin 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 create a new DocumentEntry; the data will be provided later- Specified by:
createDocumentin 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
-
createDirectory
create a new DirectoryEntry- Specified by:
createDirectoryin interfaceDirectoryEntry- Parameters:
name- the name of the new DirectoryEntry- Returns:
- the new DirectoryEntry
- Throws:
IOException
-
getStorageClsid
Gets the storage clsid of the directory entry- Specified by:
getStorageClsidin interfaceDirectoryEntry- Returns:
- storage Class ID
-
setStorageClsid
Sets the storage clsid for the directory entry- Specified by:
setStorageClsidin interfaceDirectoryEntry- Parameters:
clsidStorage- storage Class ID
-
isDirectoryEntry
public boolean isDirectoryEntry()is this a DirectoryEntry?- Specified by:
isDirectoryEntryin interfaceEntry- Overrides:
isDirectoryEntryin classEntryNode- Returns:
- true if the Entry is a DirectoryEntry, else false
-
isDeleteOK
protected boolean isDeleteOK()extensions use this method to verify internal rules regarding deletion of the underlying store.- Specified by:
isDeleteOKin classEntryNode- Returns:
- true if it's ok to delete the underlying store, else false
-
getViewableArray
Get an array of objects, some of which may implement POIFSViewable- Specified by:
getViewableArrayin 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:
getViewableIteratorin 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:
preferArrayin 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:
getShortDescriptionin interfacePOIFSViewable- Returns:
- short description
-
iterator
Returns an Iterator over all the entries
-