Class FilteringDirectoryNode

  • All Implemented Interfaces:
    java.lang.Iterable<Entry>, DirectoryEntry, Entry

    public class FilteringDirectoryNode
    extends java.lang.Object
    implements DirectoryEntry
    A DirectoryEntry filter, which exposes another DirectoryEntry less certain parts. This is typically used when copying or comparing Filesystems.
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteringDirectoryNode​(DirectoryEntry directory, java.util.Collection<java.lang.String> excludes)
      Creates a filter round the specified directory, which will exclude entries such as "MyNode" and "MyDir/IgnoreNode".
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DirectoryEntry createDirectory​(java.lang.String name)
      create a new DirectoryEntry
      DocumentEntry createDocument​(java.lang.String name, int size, POIFSWriterListener writer)
      create a new DocumentEntry; the data will be provided later
      DocumentEntry createDocument​(java.lang.String name, java.io.InputStream stream)
      create a new DocumentEntry
      boolean delete()
      Delete this Entry.
      java.util.Iterator<Entry> getEntries()
      get an iterator of the Entry instances contained directly in this instance (in other words, children only; no grandchildren etc.)
      Entry getEntry​(java.lang.String name)
      get a specified Entry by name
      int getEntryCount()
      find out how many Entry instances are contained directly within this DirectoryEntry
      java.util.Set<java.lang.String> getEntryNames()
      get the names of all the Entries contained directly in this instance (in other words, names of children only; no grandchildren etc).
      java.lang.String getName()
      get the name of the Entry
      DirectoryEntry getParent()
      get this Entry's parent (the DirectoryEntry that owns this Entry).
      ClassID getStorageClsid()
      Gets the storage clsid of the directory entry
      boolean hasEntry​(java.lang.String name)
      Checks if entry with specified name present
      boolean isDirectoryEntry()
      is this a DirectoryEntry?
      boolean isDocumentEntry()
      is this a DocumentEntry?
      boolean isEmpty()
      is this DirectoryEntry empty?
      java.util.Iterator<Entry> iterator()  
      boolean renameTo​(java.lang.String newName)
      Rename this Entry.
      void setStorageClsid​(ClassID clsidStorage)
      Sets the storage clsid for the directory entry
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • FilteringDirectoryNode

        public FilteringDirectoryNode​(DirectoryEntry directory,
                                      java.util.Collection<java.lang.String> excludes)
        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 filter
        excludes - The Entries to exclude
    • Method Detail

      • createDirectory

        public DirectoryEntry createDirectory​(java.lang.String name)
                                       throws java.io.IOException
        Description copied from interface: DirectoryEntry
        create a new DirectoryEntry
        Specified by:
        createDirectory in interface DirectoryEntry
        Parameters:
        name - the name of the new DirectoryEntry
        Returns:
        the new DirectoryEntry
        Throws:
        java.io.IOException
      • createDocument

        public DocumentEntry createDocument​(java.lang.String name,
                                            java.io.InputStream stream)
                                     throws java.io.IOException
        Description copied from interface: DirectoryEntry
        create a new DocumentEntry
        Specified by:
        createDocument in interface DirectoryEntry
        Parameters:
        name - the name of the new DocumentEntry
        stream - the InputStream from which to create the new DocumentEntry
        Returns:
        the new DocumentEntry
        Throws:
        java.io.IOException
      • createDocument

        public DocumentEntry createDocument​(java.lang.String name,
                                            int size,
                                            POIFSWriterListener writer)
                                     throws java.io.IOException
        Description copied from interface: DirectoryEntry
        create a new DocumentEntry; the data will be provided later
        Specified by:
        createDocument in interface DirectoryEntry
        Parameters:
        name - the name of the new DocumentEntry
        size - the size of the new DocumentEntry
        writer - the writer of the new DocumentEntry
        Returns:
        the new DocumentEntry
        Throws:
        java.io.IOException
      • getEntries

        public java.util.Iterator<Entry> 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 interface DirectoryEntry
        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

        public java.util.Iterator<Entry> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Entry>
      • 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 interface DirectoryEntry
        Returns:
        number of immediately (no grandchildren etc.) contained Entry instances
      • getEntryNames

        public java.util.Set<java.lang.String> 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 interface DirectoryEntry
        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 interface DirectoryEntry
        Returns:
        true if this instance contains no Entry instances
      • hasEntry

        public boolean hasEntry​(java.lang.String name)
        Description copied from interface: DirectoryEntry
        Checks if entry with specified name present
        Specified by:
        hasEntry in interface DirectoryEntry
      • getEntry

        public Entry getEntry​(java.lang.String name)
                       throws java.io.FileNotFoundException
        Description copied from interface: DirectoryEntry
        get a specified Entry by name
        Specified by:
        getEntry in interface DirectoryEntry
        Parameters:
        name - the name of the Entry to obtain.
        Returns:
        the specified Entry, if it is directly contained in this DirectoryEntry
        Throws:
        java.io.FileNotFoundException - if no Entry with the specified name exists in this DirectoryEntry
      • setStorageClsid

        public void setStorageClsid​(ClassID clsidStorage)
        Description copied from interface: DirectoryEntry
        Sets the storage clsid for the directory entry
        Specified by:
        setStorageClsid in interface DirectoryEntry
        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.
        Specified by:
        delete in interface Entry
        Returns:
        true if the Entry was successfully deleted, else false
      • renameTo

        public boolean renameTo​(java.lang.String newName)
        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.
        Specified by:
        renameTo in interface Entry
        Parameters:
        newName - the new name for this Entry
        Returns:
        true if the operation succeeded, else false
      • getName

        public java.lang.String getName()
        Description copied from interface: Entry
        get the name of the Entry
        Specified by:
        getName in interface Entry
        Returns:
        name
      • getParent

        public DirectoryEntry 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.
        Specified by:
        getParent in interface Entry
        Returns:
        this Entry's parent; null iff this is the root Entry
      • isDirectoryEntry

        public boolean isDirectoryEntry()
        Description copied from interface: Entry
        is this a DirectoryEntry?
        Specified by:
        isDirectoryEntry in interface Entry
        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 interface Entry
        Returns:
        true if the Entry is a DocumentEntry, else false