Class FileObject

java.lang.Object
sonia.scm.repository.FileObject
All Implemented Interfaces:
Serializable, LastModifiedAware

public class FileObject extends Object implements LastModifiedAware, Serializable
The FileObject represents a file or a directory in a repository.
Since:
1.5
See Also:
  • Constructor Details

    • FileObject

      public FileObject()
  • Method Details

    • getDescription

      public Optional<String> getDescription()
      Returns the last commit message for this file. The method will return null, if the repository provider is not able to get the last commit for the path.
      Returns:
      Last commit message or null, when this value has not been computed (see isPartialResult()).
    • getLastModified

      public Long getLastModified()
      Returns the last commit date for this. The method will return null, if the repository provider is not able to get the last commit for the path or it has not been computed.
      Specified by:
      getLastModified in interface LastModifiedAware
      Returns:
      last commit date
    • getCommitDate

      public OptionalLong getCommitDate()
      Returns the last commit date for this. The method will return OptionalLong.empty(), if the repository provider is not able to get the last commit for the path or if this value has not been computed (see isPartialResult() and isComputationAborted()).
    • getLength

      public OptionalLong getLength()
      Returns the length of the file or OptionalLong.empty(), when this value has not been computed (see isPartialResult() and isComputationAborted()).
    • getName

      public String getName()
      Returns the name of the file.
    • getPath

      public String getPath()
      Returns the path of the file.
    • getParentPath

      public String getParentPath()
      Returns the parent path of the file.
      Returns:
      parent path
    • getSubRepository

      public SubRepository getSubRepository()
      Return sub repository information or null if the file is not sub repository.
      Since:
      1.10
    • isDirectory

      public boolean isDirectory()
      Returns true if the file is a directory.
    • getChildren

      public Collection<FileObject> getChildren()
      Returns the children of this file if it is a directory.
    • isPartialResult

      public boolean isPartialResult()
      If this is true, some values for this object have not been computed, yet. These values (like getLength(), getDescription() or getCommitDate()) will return Optional.empty() (or OptionalLong.empty() respectively), unless they are computed. There may be an asynchronous task running, that will set these values in the future.
      Returns:
      true, whenever some values of this object have not been computed, yet.
      Since:
      2.0.0
    • isComputationAborted

      public boolean isComputationAborted()
      If this is true, some values for this object have not been computed and will not be computed. These values (like getLength(), getDescription() or getCommitDate()) will return Optional.empty() (or OptionalLong.empty() respectively), unless they are computed.
      Returns:
      true, whenever some values of this object finally are not computed.
      Since:
      2.0.0
    • isTruncated

      public boolean isTruncated()
    • setDescription

      public void setDescription(String description)
      Sets the description of the file.
    • setDirectory

      public void setDirectory(boolean directory)
      Set to true to indicate that the file is a directory.
    • setCommitDate

      public void setCommitDate(Long commitDate)
      Sets the commit date of the file.
    • setLength

      public void setLength(Long length)
      Sets the length of the file.
    • setName

      public void setName(String name)
      Sets the name of the file.
    • setPath

      public void setPath(String path)
      Sets the path of the file.
    • setSubRepository

      public void setSubRepository(SubRepository subRepository)
      Set sub repository information for the file.
      Since:
      1.10
    • setPartialResult

      public void setPartialResult(boolean partialResult)
      Set marker, that some values for this object are not computed, yet.
      Parameters:
      partialResult - Set this to true, whenever some values of this object are not computed, yet.
      Since:
      2.0.0
    • setComputationAborted

      public void setComputationAborted(boolean computationAborted)
      Set marker, that computation of some values for this object has been aborted.
      Parameters:
      computationAborted - Set this to true, whenever some values of this object are not computed and will not be computed in the future.
      Since:
      2.0.0
    • setChildren

      public void setChildren(List<FileObject> children)
      Set the children for this file.
    • addChild

      public void addChild(FileObject child)
      Adds a child to the list of children .
      Parameters:
      child - The additional child.
    • setTruncated

      public void setTruncated(boolean truncated)