com.xebialabs.deployit.hostsession
Interface HostFile

All Known Implementing Classes:
AbstractHostFile, CifsHostFile

public interface HostFile

A reference to a file on a host. This object is always associated with a HostSession.


Method Summary
 boolean canExecute()
          Tests whether the file or directory can be executed.
 boolean canRead()
          Tests whether the file or directory can be read.
 boolean canWrite()
          Tests whether the file or directory can be written.
 boolean delete()
          Deletes the host file or directory.
 boolean deleteRecursively()
          Deletes the host directory recursively, first deleting its contents and then the directory itself.
 boolean deleteRecursively(java.lang.String exclusion)
          Deprecated. Will be removed very soon.
 boolean exists()
          Tests whether the file or directory exists.
 java.io.InputStream get()
          Opens the host file for reading.
 void get(java.io.File file)
          Copies the content of the host file to a file.
 void get(java.io.OutputStream out)
          Copies the content of the host file to a stream.
 HostFile getFile(java.lang.String name)
          Returns a new HostFile with this file as its parent.
 java.lang.String getName()
          Returns the name of the host file or directory.
 java.lang.String getParent()
          Returns the path of the parent of the host file or directory.
 HostFile getParentFile()
          Returns the a new HostFile referring to the parent of the host file or directory.
 java.lang.String getPath()
          Returns the path.
 HostSession getSession()
          Returns the session this file is associated with.
 boolean isDirectory()
          Tests whether this file is a directory.
 long length()
          Returns the length of this file.
 java.util.List<java.lang.String> list()
          Returns a list of strings naming the files and directories contained by the host directory.
 java.util.List<HostFile> listFiles()
          Returns a list of HostFile objects for the files and directories contained by the host directory.
 void mkdir()
          Creates the directory on the host.
 void mkdirs()
          Creates the directory on the host, including any missing parent directories if needed.
 void moveTo(HostFile destFile)
          Moves/renames this file to the target file atomically.
 void put(java.io.File file)
          Copies the contact of a local file to the host file.
 void put(java.io.InputStream in, long length)
          Copies the contents of a stream to the host file.
 java.io.OutputStream put(long length)
          Opens the host file for writing.
 void put(org.springframework.core.io.Resource resource)
          Copies the contact of a resource to the host file.
 

Method Detail

getSession

HostSession getSession()
Returns the session this file is associated with.

Returns:
the session

getFile

HostFile getFile(java.lang.String name)
                 throws RuntimeIOException
Returns a new HostFile with this file as its parent. Identical to invoking this.getSession().getHostFile(this, name)

Parameters:
name - the name of the file in the directory
Returns:
a reference to the file in the directory
Throws:
RuntimeIOException - if an I/O error occurs

getPath

java.lang.String getPath()
Returns the path.

Returns:
the path

getName

java.lang.String getName()
Returns the name of the host file or directory.


getParent

java.lang.String getParent()
Returns the path of the parent of the host file or directory. The parent is the directory containing this file or directory. Returns the empty string if the host file or directory has no parent.


getParentFile

HostFile getParentFile()
Returns the a new HostFile referring to the parent of the host file or directory. The parent is the directory containing this file or directory. Returns null if the host file or directory has no parent.


exists

boolean exists()
               throws RuntimeIOException
Tests whether the file or directory exists.

Returns:
true if and only if the file or directory exists on the host; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

isDirectory

boolean isDirectory()
                    throws RuntimeIOException
Tests whether this file is a directory.

Returns:
true if and only if the file exists and is a directory; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

length

long length()
            throws RuntimeIOException
Returns the length of this file.

Returns:
the size of this file in bytes.
Throws:
RuntimeIOException - if an I/O error occurs

canRead

boolean canRead()
                throws RuntimeIOException
Tests whether the file or directory can be read.

Returns:
true if and only if the file or directory is readable on the host; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

canWrite

boolean canWrite()
                 throws RuntimeIOException
Tests whether the file or directory can be written.

Returns:
true if and only if the file or directory is writable on the host; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

canExecute

boolean canExecute()
                   throws RuntimeIOException
Tests whether the file or directory can be executed.

Returns:
true if and only if the file or directory is executable on the host; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

list

java.util.List<java.lang.String> list()
                                      throws RuntimeIOException
Returns a list of strings naming the files and directories contained by the host directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

Returns:
An list of strings naming the files and directories in the host directory. The list will be empty if the directory is empty.
Throws:
RuntimeIOException - if an I/O error occurs or this file does not denote a directory.

listFiles

java.util.List<HostFile> listFiles()
                                   throws RuntimeIOException
Returns a list of HostFile objects for the files and directories contained by the host directory. HostFile objects denoting the directory itself and the directory's parent directory are not included in the result.

Returns:
An list of HostFile objects for the files and directories in the host directory. The list will be empty if the directory is empty.
Throws:
RuntimeIOException - if an I/O error occurs or this file does not denote a directory.

mkdir

void mkdir()
           throws RuntimeIOException
Creates the directory on the host.

Throws:
RuntimeIOException - if an I/O error occurs

mkdirs

void mkdirs()
            throws RuntimeIOException
Creates the directory on the host, including any missing parent directories if needed.

Throws:
RuntimeIOException - if an I/O error occurs

moveTo

void moveTo(HostFile destFile)
Moves/renames this file to the target file atomically.

Parameters:
destFile - the destination file.
Throws:
RuntimeIOException - if an I/O error occurs or the underlying implementation cannot move/rename the file.

delete

boolean delete()
               throws RuntimeIOException
Deletes the host file or directory. If the file or directory does not exists on the host, false is returned.

Returns:
true if the host file or directory existed before the deletion; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

deleteRecursively

boolean deleteRecursively()
                          throws RuntimeIOException
Deletes the host directory recursively, first deleting its contents and then the directory itself. If the host directory is actually a file, invoking this method is identical to invoking the delete() method. If the directory does not exists on the host, false is returned.

Returns:
true if the host file or directory existed before the deletion; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

deleteRecursively

boolean deleteRecursively(java.lang.String exclusion)
                          throws RuntimeIOException
Deprecated. Will be removed very soon.

Similar to deleteRecursively(), except that any filename matching exclusion.

Returns:
true if the host file or directory existed before the deletion; false otherwise
Throws:
RuntimeIOException - if an I/O error occurs

get

java.io.InputStream get()
                        throws RuntimeIOException
Opens the host file for reading.

Returns:
the InputStream connected to the file.
Throws:
RuntimeIOException - if an I/O error occurs

get

void get(java.io.OutputStream out)
         throws RuntimeIOException
Copies the content of the host file to a stream.

Parameters:
out - the stream to copy to
Throws:
RuntimeIOException - if an I/O error occurs

get

void get(java.io.File file)
         throws RuntimeIOException
Copies the content of the host file to a file.

Parameters:
file - the file to copy to
Throws:
RuntimeIOException - if an I/O error occurs

put

java.io.OutputStream put(long length)
                         throws RuntimeIOException
Opens the host file for writing.

Parameters:
length - the number of bytes that will be written to the stream
Returns:
the OutputStream connected to the file.
Throws:
RuntimeIOException - if an I/O error occurs

put

void put(java.io.InputStream in,
         long length)
         throws RuntimeIOException
Copies the contents of a stream to the host file.

Parameters:
in - the stream to copy from
length - the number of bytes that will be written to the stream
Throws:
RuntimeIOException - if an I/O error occurs

put

void put(java.io.File file)
         throws RuntimeIOException
Copies the contact of a local file to the host file.

Parameters:
file - the file to copy from
Throws:
RuntimeIOException - if an I/O error occurs

put

void put(org.springframework.core.io.Resource resource)
         throws RuntimeIOException
Copies the contact of a resource to the host file.

Parameters:
resource - the resource to copy
Throws:
RuntimeIOException - if an I/O error occurs


Copyright © 2010. All Rights Reserved.