Class FilteringDirectoryNode

  • All Implemented Interfaces:
    Iterable<Entry>, DirectoryEntry, Entry

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

      • FilteringDirectoryNode

        public FilteringDirectoryNode​(DirectoryEntry directory,
                                      Collection<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
        Throws:
        IllegalArgumentException - if directory is null
    • Method Detail

      • getEntries

        public 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.
      • 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 Set<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​(String name)
        Description copied from interface: DirectoryEntry
        Checks if entry with specified name present, case sensitive
        Specified by:
        hasEntry in interface DirectoryEntry
      • getEntry

        public Entry getEntry​(String name)
                       throws FileNotFoundException
        Description copied from interface: DirectoryEntry
        get a specified Entry by name, case sensitive
        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:
        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​(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 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