org.astrogrid.acr.file
Interface Manager


public interface Manager

Read, Write, and Navigate Filesystems.

See Also:
Name, Info, Systems
Since:
1.2.3
Service Name
file.manager

Method Summary
 void append(URI dest, String content)
          Append to a file.
 void appendBinary(URI dest, byte[] content)
          Append binary data to a file.
 void copy(URI src, URI dest)
          Copy a file, and all it's descendants, to another location.
 void createFile(URI uri)
          Create a file, if it does not exist.
 void createFolder(URI uri)
          Create a folder, if it does not exist.
 boolean delete(URI uri)
          Delete a file and all it's descendants.
 String[] listChildren(URI uri)
          List the names of the children of a folder.
 URI[] listChildUris(URI uri)
          List the URI of the children of a folder.
 void move(URI src, URI dest)
          Move a file (and all it's descendants) to another location.
 String read(URI src)
          Read the contents of a file.
 byte[] readBinary(URI src)
          Read the contents of a file as binary data.
 void refresh(URI uri)
          Resynchronize the information about a file with the remote filesystem.
 void write(URI dest, String content)
          Write to a file.
 void writeBinary(URI dest, byte[] content)
          Write binary data to a file.
 

Method Detail

createFile

void createFile(URI uri)
                throws ACRException
Create a file, if it does not exist. Also creates any ancestor folders which do not exist. This method does nothing if the file already exists and is a file.

Parameters:
uri - the filepath to create
Throws:
ACRException - If the file already exists with the wrong type, or the parent folder is read-only, or on error creating this file or one of its ancestors.

createFolder

void createFolder(URI uri)
                  throws ACRException
Create a folder, if it does not exist. Also creates any ancestor folders which do not exist. Does nothing if the folder already exists.

Parameters:
uri - the folderpath to create
Throws:
ACRException - If the folder already exists with the wrong type, or the parent folder is read-only, or on error creating this folder or one of its ancestors.

refresh

void refresh(URI uri)
             throws ACRException
Resynchronize the information about a file with the remote filesystem. May be necessary in cases when another client is writing to this file

Throws:
ACRException

delete

boolean delete(URI uri)
               throws ACRException
Delete a file and all it's descendants. Does nothing if this file does not exist.

Parameters:
uri - filepath to delete
Returns:
true if the file was deleted.
Throws:
ACRException

listChildren

String[] listChildren(URI uri)
                      throws ACRException
List the names of the children of a folder.

Parameters:
uri - the folder to list
Returns:
An array containing the names of the children of this folder. The array is unordered. If the file does not have any children, a zero-length array is returned. This method never returns null.
Throws:
ACRException - If this file does not exist, or is not a folder, or on error listing this file's children.

listChildUris

URI[] listChildUris(URI uri)
                    throws ACRException
List the URI of the children of a folder.

Parameters:
uri - the folder to list
Returns:
An array containing the URIs of the children of this folder. The array is unordered. If the file does not have any children, a zero-length array is returned. This method never returns null.
Throws:
ACRException - If this file does not exist, or is not a folder, or on error listing this file's children.

read

String read(URI src)
            throws ACRException
Read the contents of a file.

Parameters:
src - the file to read from
Returns:
the contents of the file. An empty file will return an empty string, never NULL
Throws:
ACRException - if the file is not readable, or a folder, or an error occurs when reading.

write

void write(URI dest,
           String content)
           throws ACRException
Write to a file.

Parameters:
dest - the file to write to
content - the contents to write to the file.
Throws:
ACRException - if the file is read-only, or a folder, or an error occurs when writing.

readBinary

byte[] readBinary(URI src)
                  throws ACRException
Read the contents of a file as binary data.

Parameters:
src - the file to read from
Returns:
the contents of the file. Never NULL - an empty file will produce a zero-length array.
Throws:
ACRException - if the file is not readable, or a folder, or an error occurs when reading.

writeBinary

void writeBinary(URI dest,
                 byte[] content)
                 throws ACRException
Write binary data to a file.

Parameters:
dest - the file to write to
content - the contents to write to the file.
Throws:
ACRException - if the file is read-only, or a folder, or an error occurs when writing.

append

void append(URI dest,
            String content)
            throws ACRException
Append to a file.

Parameters:
dest - the file to write to
content - the contents to append to the file.
Throws:
ACRException - if the file is read-only, or a folder, or an error occurs when writing.

appendBinary

void appendBinary(URI dest,
                  byte[] content)
                  throws ACRException
Append binary data to a file.

Parameters:
dest - the file to write to
content - the contents to append to the file.
Throws:
ACRException - if the file is read-only, or a folder, or an error occurs when writing.

copy

void copy(URI src,
          URI dest)
          throws ACRException
Copy a file, and all it's descendants, to another location.

Parameters:
src - the source file / folder
dest - the destination to copy to. The destination may be on a different filesystem to src
Throws:
ACRException

move

void move(URI src,
          URI dest)
          throws ACRException
Move a file (and all it's descendants) to another location.

Parameters:
src - the file to move
dest - the destination to move to. This may be on a different filesystem to src
Throws:
ACRException


Copyright © 2002-2010 AstroGrid. All Rights Reserved.