Top Description Fields Constructors Methods
org.apache.poi.poifs.filesystem

public Class DirectoryNode

extends EntryNode
implements DirectoryEntry, POIFSViewable, Iterable<Entry>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, org.apache.poi.poifs.dev.POIFSViewable, org.apache.poi.poifs.filesystem.DirectoryEntry, org.apache.poi.poifs.filesystem.Entry
Imports
java.io.FileNotFoundException, .IOException, .InputStream, java.util.ArrayList, .Collections, .HashMap, .HashSet, .Iterator, .List, .Locale, .Map, .Set, .Spliterator, org.apache.poi.hpsf.ClassID, org.apache.poi.poifs.dev.POIFSViewable, org.apache.poi.poifs.property.DirectoryProperty, .DocumentProperty, .Property

Simple implementation of DirectoryEntry

Field Summary

Modifier and TypeField and Description
private final Map<String, Entry>
private final Map<String, Entry>
private final ArrayList<Entry>
private final POIFSFileSystem
private final POIFSDocumentPath

Constructor Summary

AccessConstructor and Description
pack-priv
DirectoryNode(final DirectoryProperty
the DirectoryProperty for this DirectoryEntry
property
,
final POIFSFileSystem
the POIFSFileSystem we belong to
filesystem
,
final DirectoryNode
the parent of this entry
parent
)

create a DirectoryNode.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean

Returns:

true if the operation succeeded, else false
changeName
(final String
the original name
oldName
,
final String
the new name
newName
)

Change a contained Entry's name

public DirectoryEntry

Returns:

the new DirectoryEntry
createDirectory
(final String
the name of the new DirectoryEntry
name
)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.createDirectory.

create a new DirectoryEntry

pack-priv DocumentEntry

Returns:

the new DocumentEntry
createDocument
(final POIFSDocument
the new document
document
)

create a new DocumentEntry

public DocumentEntry

Returns:

the new DocumentEntry
createDocument
(final String
the name of the new DocumentEntry
name
,
final InputStream
the InputStream from which to create the new DocumentEntry
stream
)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.createDocument.

create a new DocumentEntry

public DocumentEntry

Returns:

the new DocumentEntry
createDocument
(final String
the name of the new DocumentEntry
name
,
final int
the size of the new DocumentEntry
size
,
final POIFSWriterListener
the writer of the new DocumentEntry
writer
)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.createDocument.

create a new DocumentEntry; the data will be provided later

public DocumentInputStream

Returns:

a newly opened DocumentInputStream
createDocumentInputStream
(final String
the name of the document to be opened
documentName
)

open a document in the directory's entry's list of entries

public DocumentInputStream

Returns:

a newly opened DocumentInputStream or DocumentInputStream
createDocumentInputStream
(final Entry
the document to be opened
document
)

open a document in the directory's entry's list of entries

public DocumentEntry

Returns:

the new or updated DocumentEntry
createOrUpdateDocument
(final String
the name of the new or existing DocumentEntry
name
,
final InputStream
the InputStream from which to populate the DocumentEntry
stream
)

Set the contents of a document, creating if needed, otherwise updating.

pack-priv boolean

Returns:

true if the entry was deleted, else false
deleteEntry
(final EntryNode
the EntryNode to be deleted
entry
)

Delete an entry

public Iterator<Entry>

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.
getEntries
()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntries.

get an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)

public Entry

Returns:

the specified Entry, if it is directly contained in this DirectoryEntry
getEntry
(final String
the name of the Entry to obtain.
name
)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntry.

get a specified Entry by name, case sensitive

public Entry

Returns:

the specified Entry, if it is directly contained in this DirectoryEntry
getEntryCaseInsensitive
(final String
the name of the Entry to obtain.
name
)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntryCaseInsensitive.

get a specified Entry by name, case-insensitive

public int

Returns:

number of immediately (no grandchildren etc.) contained Entry instances
getEntryCount
()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntryCount.

find out how many Entry instances are contained directly within this DirectoryEntry

public Set<String>

Returns:

the names of all the entries that may be retrieved with getEntry(String), which may be empty (if this DirectoryEntry is empty)
getEntryNames
()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntryNames.

get the literal, case-sensitive names of all the Entries contained directly in this instance (in other words, names of children only; no grandchildren etc).

public POIFSFileSystem

Returns:

the filesystem that this belongs to
getFileSystem
()

public POIFSDocumentPath

Returns:

this directory's path representation
getPath
()

public String

Returns:

short description
getShortDescription
()

Implements org.apache.poi.poifs.dev.POIFSViewable.getShortDescription.

Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.

public ClassID

Returns:

storage Class ID
getStorageClsid
()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getStorageClsid.

Gets the storage clsid of the directory entry

public Object[]

Returns:

an array of Object; may not be null, but may be empty
getViewableArray
()

Implements org.apache.poi.poifs.dev.POIFSViewable.getViewableArray.

Get an array of objects, some of which may implement POIFSViewable

public Iterator<Object>

Returns:

an Iterator; may not be null, but may have an empty back end store
getViewableIterator
()

Implements org.apache.poi.poifs.dev.POIFSViewable.getViewableIterator.

Get an Iterator of objects, some of which may implement POIFSViewable

public boolean

Returns:

whether or not an entry exists for that name (case-sensitive)
hasEntry
(String name)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.hasEntry.

Checks for a specific entry in a case-sensitive way.

public boolean

Returns:

whether or not an entry exists for that name (case-insensitive)
hasEntryCaseInsensitive
(String name)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.hasEntryCaseInsensitive.

Checks for a specific entry in a case-insensitive way.

protected boolean

Returns:

true if it's ok to delete the underlying store, else false
isDeleteOK
()

Implements abstract org.apache.poi.poifs.filesystem.EntryNode.isDeleteOK.

extensions use this method to verify internal rules regarding deletion of the underlying store.

public boolean

Returns:

true if the Entry is a DirectoryEntry, else false
isDirectoryEntry
()

Overrides org.apache.poi.poifs.filesystem.EntryNode.isDirectoryEntry.

Implements org.apache.poi.poifs.filesystem.Entry.isDirectoryEntry.

is this a DirectoryEntry?

public boolean

Returns:

true if this instance contains no Entry instances
isEmpty
()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.isEmpty.

is this DirectoryEntry empty?

public Iterator<Entry>
iterator()

Implements java.lang.Iterable.iterator.

Returns an Iterator over all the entries

public boolean

Returns:

true if a viewer should call getViewableArray, false if a viewer should call getViewableIterator
preferArray
()

Implements org.apache.poi.poifs.dev.POIFSViewable.preferArray.

Give viewers a hint as to whether to call getViewableArray or getViewableIterator

public void
setStorageClsid(ClassID
storage Class ID
clsidStorage
)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.setStorageClsid.

Sets the storage clsid for the directory entry

public Spliterator<Entry>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Returns a Spliterator over all the entries

Inherited from org.apache.poi.poifs.filesystem.EntryNode:
deletegetNamegetParentgetPropertyisDocumentEntryisRootrenameTo

Field Detail

_bynameback to summary
private final Map<String, Entry> _byname
_byUCNameback to summary
private final Map<String, Entry> _byUCName
_entriesback to summary
private final ArrayList<Entry> _entries
_filesystemback to summary
private final POIFSFileSystem _filesystem
_pathback to summary
private final POIFSDocumentPath _path

Constructor Detail

DirectoryNodeback to summary
pack-priv DirectoryNode(final DirectoryProperty property, final POIFSFileSystem filesystem, final 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:DirectoryProperty

the DirectoryProperty for this DirectoryEntry

filesystem:POIFSFileSystem

the POIFSFileSystem we belong to

parent:DirectoryNode

the parent of this entry

Method Detail

changeNameback to summary
pack-priv boolean changeName(final String oldName, final String newName)

Change a contained Entry's name

Parameters
oldName:String

the original name

newName:String

the new name

Returns:boolean

true if the operation succeeded, else false

createDirectoryback to summary
public DirectoryEntry createDirectory(final String name) throws IOException

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.createDirectory.

create a new DirectoryEntry

Parameters
name:String

the name of the new DirectoryEntry

Returns:DirectoryEntry

the new DirectoryEntry

Annotations
@Override
Exceptions
IOException:
if the directory can't be created
createDocumentback to summary
pack-priv DocumentEntry createDocument(final POIFSDocument document) throws IOException

create a new DocumentEntry

Parameters
document:POIFSDocument

the new document

Returns:DocumentEntry

the new DocumentEntry

Exceptions
IOException:
if the document can't be created
createDocumentback to summary
public DocumentEntry createDocument(final String name, final InputStream stream) throws IOException

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.createDocument.

create a new DocumentEntry

Parameters
name:String

the name of the new DocumentEntry

stream:InputStream

the InputStream from which to create the new DocumentEntry

Returns:DocumentEntry

the new DocumentEntry

Annotations
@Override
Exceptions
IOException:
if the document can't be created
createDocumentback to summary
public DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer) throws IOException

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.createDocument.

create a new DocumentEntry; the data will be provided later

Parameters
name:String

the name of the new DocumentEntry

size:int

the size of the new DocumentEntry

writer:POIFSWriterListener

the writer of the new DocumentEntry

Returns:DocumentEntry

the new DocumentEntry

Annotations
@Override
Exceptions
IOException:
if the document can't be created
createDocumentInputStreamback to summary
public DocumentInputStream createDocumentInputStream(final String documentName) throws IOException

open a document in the directory's entry's list of entries

Parameters
documentName:String

the name of the document to be opened

Returns:DocumentInputStream

a newly opened DocumentInputStream

Exceptions
IOException:
if the document does not exist or the name is that of a DirectoryEntry
createDocumentInputStreamback to summary
public DocumentInputStream createDocumentInputStream(final Entry document) throws IOException

open a document in the directory's entry's list of entries

Parameters
document:Entry

the document to be opened

Returns:DocumentInputStream

a newly opened DocumentInputStream or DocumentInputStream

Exceptions
IOException:
if the document does not exist or the name is that of a DirectoryEntry
createOrUpdateDocumentback to summary
public DocumentEntry createOrUpdateDocument(final String name, final InputStream stream) throws IOException

Set the contents of a document, creating if needed, otherwise updating. Returns the created / updated DocumentEntry

Parameters
name:String

the name of the new or existing DocumentEntry

stream:InputStream

the InputStream from which to populate the DocumentEntry

Returns:DocumentEntry

the new or updated DocumentEntry

Annotations
@SuppressWarnings:WeakerAccess
Exceptions
IOException:
if the document can't be created or its content be replaced
deleteEntryback to summary
pack-priv boolean deleteEntry(final EntryNode entry)

Delete an entry

Parameters
entry:EntryNode

the EntryNode to be deleted

Returns:boolean

true if the entry was deleted, else false

getEntriesback to summary
public Iterator<Entry> getEntries()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntries.

get an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)

Returns:Iterator<Entry>

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.

Annotations
@Override
getEntryback to summary
public Entry getEntry(final String name) throws FileNotFoundException

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntry.

get a specified Entry by name, case sensitive

Parameters
name:String

the name of the Entry to obtain.

Returns:Entry

the specified Entry, if it is directly contained in this DirectoryEntry

Annotations
@Override
Exceptions
FileNotFoundException:
if no Entry with the specified name exists in this DirectoryEntry
getEntryCaseInsensitiveback to summary
public Entry getEntryCaseInsensitive(final String name) throws FileNotFoundException

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntryCaseInsensitive.

get a specified Entry by name, case-insensitive

Parameters
name:String

the name of the Entry to obtain.

Returns:Entry

the specified Entry, if it is directly contained in this DirectoryEntry

Annotations
@Override
Exceptions
FileNotFoundException:
if no Entry with the specified name exists in this DirectoryEntry
getEntryCountback to summary
public int getEntryCount()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntryCount.

find out how many Entry instances are contained directly within this DirectoryEntry

Returns:int

number of immediately (no grandchildren etc.) contained Entry instances

Annotations
@Override
getEntryNamesback to summary
public Set<String> getEntryNames()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getEntryNames.

get the literal, case-sensitive names of all the Entries contained directly in this instance (in other words, names of children only; no grandchildren etc).

Returns:Set<String>

the names of all the entries that may be retrieved with getEntry(String), which may be empty (if this DirectoryEntry is empty)

Annotations
@Override
getFileSystemback to summary
public POIFSFileSystem getFileSystem()
Returns:POIFSFileSystem

the filesystem that this belongs to

getPathback to summary
public POIFSDocumentPath getPath()
Returns:POIFSDocumentPath

this directory's path representation

getShortDescriptionback to summary
public String getShortDescription()

Implements org.apache.poi.poifs.dev.POIFSViewable.getShortDescription.

Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.

Returns:String

short description

Annotations
@Override
getStorageClsidback to summary
public ClassID getStorageClsid()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.getStorageClsid.

Gets the storage clsid of the directory entry

Returns:ClassID

storage Class ID

Annotations
@Override
getViewableArrayback to summary
public Object[] getViewableArray()

Implements org.apache.poi.poifs.dev.POIFSViewable.getViewableArray.

Get an array of objects, some of which may implement POIFSViewable

Returns:Object[]

an array of Object; may not be null, but may be empty

Annotations
@Override
getViewableIteratorback to summary
public Iterator<Object> getViewableIterator()

Implements org.apache.poi.poifs.dev.POIFSViewable.getViewableIterator.

Get an Iterator of objects, some of which may implement POIFSViewable

Returns:Iterator<Object>

an Iterator; may not be null, but may have an empty back end store

Annotations
@Override
hasEntryback to summary
public boolean hasEntry(String name)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.hasEntry.

Checks for a specific entry in a case-sensitive way.

Returns:boolean

whether or not an entry exists for that name (case-sensitive)

Annotations
@Override
hasEntryCaseInsensitiveback to summary
public boolean hasEntryCaseInsensitive(String name)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.hasEntryCaseInsensitive.

Checks for a specific entry in a case-insensitive way.

Returns:boolean

whether or not an entry exists for that name (case-insensitive)

Annotations
@Override
isDeleteOKback to summary
protected boolean isDeleteOK()

Implements abstract org.apache.poi.poifs.filesystem.EntryNode.isDeleteOK.

extensions use this method to verify internal rules regarding deletion of the underlying store.

Returns:boolean

true if it's ok to delete the underlying store, else false

Annotations
@Override
isDirectoryEntryback to summary
public boolean isDirectoryEntry()

Overrides org.apache.poi.poifs.filesystem.EntryNode.isDirectoryEntry.

Implements org.apache.poi.poifs.filesystem.Entry.isDirectoryEntry.

is this a DirectoryEntry?

Returns:boolean

true if the Entry is a DirectoryEntry, else false

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.isEmpty.

is this DirectoryEntry empty?

Returns:boolean

true if this instance contains no Entry instances

Annotations
@Override
iteratorback to summary
public Iterator<Entry> iterator()

Implements java.lang.Iterable.iterator.

Returns an Iterator over all the entries

Returns:Iterator<Entry>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
preferArrayback to summary
public boolean preferArray()

Implements org.apache.poi.poifs.dev.POIFSViewable.preferArray.

Give viewers a hint as to whether to call getViewableArray or getViewableIterator

Returns:boolean

true if a viewer should call getViewableArray, false if a viewer should call getViewableIterator

Annotations
@Override
setStorageClsidback to summary
public void setStorageClsid(ClassID clsidStorage)

Implements org.apache.poi.poifs.filesystem.DirectoryEntry.setStorageClsid.

Sets the storage clsid for the directory entry

Parameters
clsidStorage:ClassID

storage Class ID

Annotations
@Override
spliteratorback to summary
public Spliterator<Entry> spliterator()

Overrides default java.lang.Iterable.spliterator.

Returns a Spliterator over all the entries

Returns:Spliterator<Entry>

Doc from java.lang.Iterable.spliterator.

a Spliterator over the elements described by this Iterable.

Annotations
@Override
Since
POI 5.2.0