com.xebialabs.deployit.hostsession.common
Class AbstractHostFile

java.lang.Object
  extended by com.xebialabs.deployit.hostsession.common.AbstractHostFile
All Implemented Interfaces:
HostFile
Direct Known Subclasses:
CifsHostFile

public abstract class AbstractHostFile
extends java.lang.Object
implements HostFile

Abstract base class with common methods used by actual implementations of HostFile.


Field Summary
protected  HostSession session
           
 
Constructor Summary
AbstractHostFile(HostSession session)
           
 
Method Summary
 boolean deleteRecursively()
          Deletes the host directory recursively, first deleting its contents and then the directory itself.
 boolean deleteRecursively(java.lang.String exclusion)
          Similar to deleteRecursively(), except that any filename matching exclusion.
 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.
 HostFile getParentFile()
          Returns the a new HostFile referring to the parent of the host file or directory.
 HostSession getSession()
          Returns the session this file is associated with.
 java.util.List<HostFile> listFiles()
          Returns a list of HostFile objects for the files and directories contained by the host directory.
 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.
 void put(org.springframework.core.io.Resource resource)
          Copies the contact of a resource to the host file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.xebialabs.deployit.hostsession.HostFile
canExecute, canRead, canWrite, delete, exists, get, getName, getParent, getPath, isDirectory, length, list, mkdir, mkdirs, moveTo, put
 

Field Detail

session

protected HostSession session
Constructor Detail

AbstractHostFile

public AbstractHostFile(HostSession session)
Method Detail

getSession

public HostSession getSession()
Description copied from interface: HostFile
Returns the session this file is associated with.

Specified by:
getSession in interface HostFile
Returns:
the session

getFile

public HostFile getFile(java.lang.String name)
Description copied from interface: HostFile
Returns a new HostFile with this file as its parent. Identical to invoking this.getSession().getHostFile(this, name)

Specified by:
getFile in interface HostFile
Parameters:
name - the name of the file in the directory
Returns:
a reference to the file in the directory

getParentFile

public HostFile getParentFile()
Description copied from interface: HostFile
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.

Specified by:
getParentFile in interface HostFile

listFiles

public java.util.List<HostFile> listFiles()
                                   throws RuntimeIOException
Description copied from interface: HostFile
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.

Specified by:
listFiles in interface HostFile
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.

deleteRecursively

public boolean deleteRecursively()
                          throws RuntimeIOException
Description copied from interface: HostFile
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 HostFile.delete() method. If the directory does not exists on the host, false is returned.

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

deleteRecursively

public boolean deleteRecursively(java.lang.String exclusion)
                          throws RuntimeIOException
Description copied from interface: HostFile
Similar to deleteRecursively(), except that any filename matching exclusion.

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

get

public void get(java.io.OutputStream out)
         throws RuntimeIOException
Description copied from interface: HostFile
Copies the content of the host file to a stream.

Specified by:
get in interface HostFile
Parameters:
out - the stream to copy to
Throws:
RuntimeIOException - if an I/O error occurs

get

public void get(java.io.File file)
         throws RuntimeIOException
Description copied from interface: HostFile
Copies the content of the host file to a file.

Specified by:
get in interface HostFile
Parameters:
file - the file to copy to
Throws:
RuntimeIOException - if an I/O error occurs

put

public void put(java.io.InputStream in,
                long length)
         throws RuntimeIOException
Description copied from interface: HostFile
Copies the contents of a stream to the host file.

Specified by:
put in interface HostFile
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

public void put(java.io.File file)
         throws RuntimeIOException
Description copied from interface: HostFile
Copies the contact of a local file to the host file.

Specified by:
put in interface HostFile
Parameters:
file - the file to copy from
Throws:
RuntimeIOException - if an I/O error occurs

put

public void put(org.springframework.core.io.Resource resource)
         throws RuntimeIOException
Description copied from interface: HostFile
Copies the contact of a resource to the host file.

Specified by:
put in interface HostFile
Parameters:
resource - the resource to copy
Throws:
RuntimeIOException - if an I/O error occurs


Copyright © 2010. All Rights Reserved.