jetbrains.buildServer.util.browser
Interface Element

All Known Subinterfaces:
ZipAwareBrowser.InsideZipElement
All Known Implementing Classes:
FileSystemBrowser.DirectoryElement, FileSystemBrowser.FileElement, ZipAwareBrowser.ZipAwareElement

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() and hashCode() methods, since Elements are actively used in hash containers.

Since:
6.0
Author:
Maxim Podkolzine (maxim.podkolzine@jetbrains.com)

Method Summary
 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 (from the root).
 java.io.InputStream getInputStream()
          Returns the input stream of the element content.
 java.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 (from the root).

Returns:
full element name

isLeaf

boolean isLeaf()
Returns whether the element is a leaf, i.e. cannot have child nodes.

Returns:
true iff the element is a leaf

getChildren

@Nullable
java.lang.Iterable<Element> getChildren()
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.

Returns:
the list of children, or null

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 call getInputStream() 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
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 available
java.io.IOException - if the input cannot be provided due to I/O error
Since:
7.0

getSize

long getSize()
             throws java.lang.IllegalStateException
Returns the size of the element content.

If the content is not available for the element (see isContentAvailable()), an exception may be thrown, 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
Throws:
java.lang.IllegalStateException - if the content size is not available
Since:
7.0