csdk.v1_0.runner.filesystem
Class RunnerFile

java.lang.Object
  extended by csdk.v1_0.runner.filesystem.RunnerFile
All Implemented Interfaces:
IFile

public class RunnerFile
extends Object
implements IFile

Simula um arquivo na sandbox do CSDK. Essa classe *não* deve ser usada por desenvolvedores CSDK em suas aplicações. Ela é de uso exclusivo do ambiente simulado do Runner.


Constructor Summary
RunnerFile(File file)
          Construtor.
RunnerFile(File file, String fileType)
          Construtor.
 
Method Summary
 IFileLock acquireExclusiveLock(Window window)
          
 IFileLock acquireSharedLock(Window window)
          
 boolean canExecute()
          
 boolean canRead()
          
 boolean canWrite()
          
 void close()
          Fecha o arquivo.
 void close(boolean forceQuit)
          Fecha este arquivo.
 boolean exists()
          
 String getAbsolutePath()
          Retorna o caminho para o arquivo.
 IFile[] getChildren()
          
 FileLocationType getFileLocationType()
          
 InputStream getInputStream()
          
 long getModificationDate()
          
 String getName()
          
 OutputStream getOutputStream()
          
 IFile getParent()
          
 String[] getPath()
          
 String getStringPath()
          
 String getType()
          Informa o tipo do arquivo.
 boolean isDirectory()
          Indica se este arquivo é um diretório.
 void open(boolean readOnly)
          
 long position()
          Informa a posição corrente deste arquivo.
 void position(long newPosition)
          Altera a posição corrente deste arquivo.
 int read(byte[] dst, int off, int len, long position)
          
 int read(byte[] dst, long position)
          Lê uma seqüência de bytes deste arquivo a partir da posição fornecida.
 void setType(String type)
          Define o tipo do arquivo.
 long size()
          Consulta o tamanho do arquivo.
 void write(byte[] src, int off, int len, long position)
          
 void write(byte[] src, long position)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunnerFile

public RunnerFile(File file)
Construtor.

Parameters:
file - o arquivo local associado.

RunnerFile

public RunnerFile(File file,
                  String fileType)
Construtor.

Parameters:
file - o arquivo local associado.
fileType - o tipo do arquivo.
Method Detail

getAbsolutePath

public String getAbsolutePath()
Retorna o caminho para o arquivo. Esse caminho não é relativo, ou seja, o caminho absoluto de onde o arquivo se encontra.

Returns:
caminho absoluto até o arquivo, inclusive.

setType

public void setType(String type)
Define o tipo do arquivo.

Parameters:
type - o tipo.

getType

public String getType()
Informa o tipo do arquivo.

Specified by:
getType in interface IFile
Returns:
o tipo.

isDirectory

public boolean isDirectory()
Indica se este arquivo é um diretório.

Specified by:
isDirectory in interface IFile
Returns:
verdadeiro caso seja um diretório e falso caso contrário.

position

public long position()
              throws IOException
Informa a posição corrente deste arquivo. Reflete o número de bytes a partir do início do arquivo até a posição corrente.

Specified by:
position in interface IFile
Returns:
a posição corrente do arquivo.
Throws:
IOException - se houver falha no acesso ao arquivo.

position

public void position(long newPosition)
              throws IOException
Altera a posição corrente deste arquivo. Reflete o número de bytes a partir do início do arquivo até a posição corrente.

Specified by:
position in interface IFile
Parameters:
newPosition - Nova posição corrente do arquivo.
Throws:
IOException - se houver falha no acesso ao arquivo.

close

public void close(boolean forceQuit)
           throws IOException
Fecha este arquivo. Após chamado este método, o objeto que representa o arquivo não poderá mais ser utilizado para leitura e/ou escrita.

Specified by:
close in interface IFile
Throws:
IOException - se houver falha no acesso ao arquivo.
See Also:
Channel.close()

close

public void close()
           throws IOException
Fecha o arquivo.

Throws:
IOException - em caso de erro de I/O.

size

public long size()
Consulta o tamanho do arquivo.

Specified by:
size in interface IFile
Returns:
o tamanho.

getChildren

public IFile[] getChildren()

Specified by:
getChildren in interface IFile

getInputStream

public InputStream getInputStream()
                           throws IOException

Specified by:
getInputStream in interface IFile
Throws:
IOException

getName

public String getName()

Specified by:
getName in interface IFile

getOutputStream

public OutputStream getOutputStream()
                             throws IOException

Specified by:
getOutputStream in interface IFile
Throws:
IOException

getPath

public String[] getPath()

Specified by:
getPath in interface IFile

getStringPath

public String getStringPath()

Specified by:
getStringPath in interface IFile

open

public void open(boolean readOnly)
          throws Exception

Specified by:
open in interface IFile
Throws:
Exception

getModificationDate

public long getModificationDate()

Specified by:
getModificationDate in interface IFile

read

public int read(byte[] dst,
                int off,
                int len,
                long position)
         throws Exception

Specified by:
read in interface IFile
Throws:
Exception

read

public int read(byte[] dst,
                long position)
         throws Exception
Lê uma seqüência de bytes deste arquivo a partir da posição fornecida. Veja a interface ReadableByteChannel para uma descrição completa da semântica deste método.

Specified by:
read in interface IFile
Parameters:
dst - O buffer no qual os bytes serão escritos.
position - A posição do arquivo a partir da qual os bytes serão lidos.
Returns:
O número de bytes lidos ou -1 no caso de final de arquivo.
Throws:
Exception - se houver falha no acesso ao arquivo.

write

public void write(byte[] src,
                  int off,
                  int len,
                  long position)
           throws IOException,
                  FileLockedException

Specified by:
write in interface IFile
Throws:
IOException
FileLockedException

write

public void write(byte[] src,
                  long position)
           throws IOException,
                  FileLockedException

Specified by:
write in interface IFile
Throws:
IOException
FileLockedException

getFileLocationType

public FileLocationType getFileLocationType()

Specified by:
getFileLocationType in interface IFile

getParent

public IFile getParent()

Specified by:
getParent in interface IFile

exists

public boolean exists()
               throws IOException

Specified by:
exists in interface IFile
Throws:
IOException

canRead

public boolean canRead()

Specified by:
canRead in interface IFile

canWrite

public boolean canWrite()

Specified by:
canWrite in interface IFile

canExecute

public boolean canExecute()

Specified by:
canExecute in interface IFile

acquireExclusiveLock

public IFileLock acquireExclusiveLock(Window window)
                               throws Exception

Specified by:
acquireExclusiveLock in interface IFile
Throws:
Exception

acquireSharedLock

public IFileLock acquireSharedLock(Window window)
                            throws Exception

Specified by:
acquireSharedLock in interface IFile
Throws:
Exception


Copyright © 2013–2014 Tecgraf/PUC-Rio. All rights reserved.