Class FileSystemBrowser.FileElement

    • Constructor Summary

      Constructors 
      Constructor Description
      FileElement​(Browser browser, java.io.File file, java.io.File root)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      Browser getBrowser()  
      java.lang.Iterable<Element> getChildren()
      Returns the ordered list of element's children.
      java.io.File getFile()  
      java.lang.String getFullName()
      Returns the unique full name of the element (relative to the root).
      java.io.InputStream getInputStream()
      Returns the input stream of the element content.
      java.util.Date getLastModifiedTimestamp()
      Returns the last modification timestamp of the element when available
      java.lang.String getName()
      Returns the element's name.
      long getSize()
      Returns the size of the element content.
      int hashCode()  
      boolean isContentAvailable()
      Returns whether the content is available for the element.
      boolean isLeaf()
      Returns whether the element is a leaf, i.e.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FileElement

        public FileElement​(@NotNull
                           Browser browser,
                           @NotNull
                           java.io.File file,
                           @NotNull
                           java.io.File root)
    • Method Detail

      • getName

        @NotNull
        public java.lang.String getName()
        Description copied from interface: Element
        Returns the element's name.
        Specified by:
        getName in interface Element
        Returns:
        name
      • getFullName

        @NotNull
        public java.lang.String getFullName()
        Description copied from interface: Element
        Returns the unique full name of the element (relative to the root).
        Specified by:
        getFullName in interface Element
        Returns:
        full element name
      • isLeaf

        public boolean isLeaf()
        Description copied from interface: Element
        Returns whether the element is a leaf, i.e. cannot have child nodes.
        Specified by:
        isLeaf in interface Element
        Returns:
        true if the element is a leaf
      • getChildren

        public java.lang.Iterable<Element> getChildren()
        Description copied from interface: Element
        Returns the ordered list of element's children. Method should return null for a leaf element, and a not null instance for other elements. List can be empty. All children's names are different.
        Specified by:
        getChildren in interface Element
        Returns:
        the list of children, or null
      • getFile

        @NotNull
        public java.io.File getFile()
      • isContentAvailable

        public boolean isContentAvailable()
        Description copied from interface: Element
        Returns whether the content is available for the element. The content is usually available for leaf elements and not available for non-leaf ones. If it's not, the call getInputStream() method will result in exception.
        Specified by:
        isContentAvailable in interface Element
        Returns:
        true iff the content is available
      • getInputStream

        @NotNull
        public java.io.InputStream getInputStream()
                                           throws java.lang.IllegalStateException,
                                                  java.io.IOException
        Description copied from interface: Element
        Returns the input stream of the element content. The caller is responsible for closing the stream at the end.

        If the content is not available for the element (see Element.isContentAvailable()), an exception is thrown.

        Specified by:
        getInputStream in interface Element
        Returns:
        content input stream
        Throws:
        java.lang.IllegalStateException - if the content is not available
        java.io.IOException - if the input cannot be provided due to I/O error
      • getSize

        public long getSize()
                     throws java.lang.IllegalStateException
        Description copied from interface: Element
        Returns the size of the element content.

        If the content is not available for the element (see Element.isContentAvailable()) or due to performance reasons a negative value may be returned. Though some implementations can provide the content size, while the content is not available.

        Specified by:
        getSize in interface Element
        Returns:
        content size or negative value when unavailable
        Throws:
        java.lang.IllegalStateException
      • getBrowser

        @NotNull
        public Browser getBrowser()
        Specified by:
        getBrowser in interface Element
        Returns:
        browser created this element
      • getLastModifiedTimestamp

        @Nullable
        public java.util.Date getLastModifiedTimestamp()
        Description copied from interface: Element
        Returns the last modification timestamp of the element when available
        Specified by:
        getLastModifiedTimestamp in interface Element
        Returns:
        last modification timestamp of the element or null if the underlying resource doesn't exist or the underlying resource doesn't provide the modification timestamps
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object