Interface Element
-
- All Known Subinterfaces:
ZipElement
- All Known Implementing Classes:
FileSystemBrowser.DirectoryElement
,FileSystemBrowser.FileElement
public interface Element
Represents an abstract element in a browsable tree, e.g. a file or a directory.It is strongly recommended to implement
equals()
andhashCode()
methods, sinceElement
s are actively used in hash containers.- Since:
- 6.0
- Author:
- Maxim Podkolzine (maxim.podkolzine@jetbrains.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Browser
getBrowser()
java.lang.Iterable<Element>
getChildren()
Returns the ordered list of element's children.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.default java.util.Date
getLastModifiedTimestamp()
Returns the last modification timestamp of the element when availablejava.lang.String
getName()
Returns the element's name.long
getSize()
Returns the size of the element content.boolean
isContentAvailable()
Returns whether the content is available for the element.boolean
isLeaf()
Returns whether the element is a leaf, i.e.
-
-
-
Method Detail
-
getName
@NotNull java.lang.String getName()
Returns the element's name.- Returns:
- name
-
getFullName
@NotNull java.lang.String getFullName()
Returns the unique full name of the element (relative to the root).- Returns:
- full element name
-
isLeaf
boolean isLeaf()
Returns whether the element is a leaf, i.e. cannot have child nodes.- Returns:
- true if the element is a leaf
-
getChildren
@Nullable java.lang.Iterable<Element> getChildren() throws BrowserException
Returns the ordered list of element's children. Method should returnnull
for a leaf element, and a notnull
instance for other elements. List can be empty. All children's names are different.- Returns:
- the list of children, or null
- Throws:
BrowserException
- in case of an error
-
isContentAvailable
boolean isContentAvailable()
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 callgetInputStream()
method will result in exception.- Returns:
- true iff the content is available
- Since:
- 7.0
-
getInputStream
@NotNull java.io.InputStream getInputStream() throws java.lang.IllegalStateException, java.io.IOException, BrowserException
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
isContentAvailable()
), an exception is thrown.- Returns:
- content input stream
- Throws:
java.lang.IllegalStateException
- if the content is not availablejava.io.IOException
- if the input cannot be provided due to I/O errorBrowserException
- indicates a general error occurred during input stream opening- Since:
- 7.0
-
getSize
long getSize()
Returns the size of the element content.If the content is not available for the element (see
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.- Returns:
- content size or negative value when unavailable
- Since:
- 7.0
-
getBrowser
@NotNull Browser getBrowser()
- Returns:
- browser created this element
- Since:
- 8.1
-
getLastModifiedTimestamp
@Nullable default java.util.Date getLastModifiedTimestamp()
Returns the last modification timestamp of the element when available- 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 - Since:
- 2021.1.1
-
-