OpenAPI 1.0

com.aquafold.openapi.project
Interface AQProjectFile


public interface AQProjectFile

Represents a file-like object within a project. Much like File, a file corresponding to an instance of AQProjectFile may or may exist in the file system.

For example, to create a folder named "FOLDER" in the project's "User Files" directory one needs to create an instance of AQProjectFile first, then call createFolder():

    var f = aqua.project.getUserFile("FOLDER");
    f.createFolder();
 


Method Summary
 AQProjectFile[] collectFilesRecursively()
          Recursively collects files in a project folder and its descendant folders, excluding system and hidden files.
 AQProjectFile[] collectFilesRecursively(String filter)
          Recursively collects files in a project folder and its descendant folders.
 boolean createFolder()
          Creates a folder corresponding to this file object.
 boolean exists()
          Returns true if the file exists.
 int getLength()
          Returns the file length in bytes.
 File getLocalFile()
          Returns the local java.io.File object representation of the AQProjectFile
 String getName()
          Returns the file name.
 String getPath()
          Returns the file path.
 boolean isFile()
          Returns true if the underlying storage element is a file.
 boolean isFolder()
          Returns true if the underlying element is a folder.
 AQProjectFile[] list()
          Returns an array of files and folders in a project folder.
 AQProjectFile[] list(String filter)
          Returns an array of files and folders in a project folder, satisfying the specified file name filter.
 String read()
          Reads the file content into a string assuming UTF-8 encoding.
 String read(String encoding)
          Reads the file content into a string using the specified encoding.
 byte[] readBytes()
          Reads the file content into a byte array.
 boolean remove()
          Deletes an underlying file object.
 void write(byte[] bytes)
          Writes the byte array to a file.
 void write(String text)
          Writes the text string to a file using UTF-8 encoding.
 void write(String text, String encoding)
          Writes the text string to a file using the specified encoding.
 

Method Detail

getName

String getName()
Returns the file name.


getLocalFile

File getLocalFile()
Returns the local java.io.File object representation of the AQProjectFile


getPath

String getPath()
Returns the file path.


getLength

int getLength()
Returns the file length in bytes.


exists

boolean exists()
Returns true if the file exists.


isFile

boolean isFile()
Returns true if the underlying storage element is a file.


isFolder

boolean isFolder()
Returns true if the underlying element is a folder.


list

AQProjectFile[] list()
Returns an array of files and folders in a project folder. Returns an empty array if the underlying object is not a folder, or does not exist.


list

AQProjectFile[] list(String filter)
Returns an array of files and folders in a project folder, satisfying the specified file name filter. The file name filter supports standard wildcard characters * and ?.

Parameters:
filter - File filter specification string.

collectFilesRecursively

AQProjectFile[] collectFilesRecursively()
Recursively collects files in a project folder and its descendant folders, excluding system and hidden files. Returns an array of files.

If this project file object does not denote a directory, then this method returns null.


collectFilesRecursively

AQProjectFile[] collectFilesRecursively(String filter)
Recursively collects files in a project folder and its descendant folders. The file name filter supports standard wildcard characters * and ?. A null filter is equivalent to a filter which excludes system and hidden files. Returns an array of files.

If this project file object does not denote a directory, then this method returns null.

Parameters:
filter - File filter specification string.

remove

boolean remove()
Deletes an underlying file object. Returns true if the file has been successfully deleted. The method is called 'remove' due to the fact that 'delete' is a javascript operator.


read

String read()
            throws Exception
Reads the file content into a string assuming UTF-8 encoding. This method removes the Byte Order Mark (BOM) if it exists.

Throws:
Exception

read

String read(String encoding)
            throws Exception
Reads the file content into a string using the specified encoding. This method removes the Byte Order Mark (BOM) if it exists.

Parameters:
encoding - Character encoding.
Throws:
Exception

readBytes

byte[] readBytes()
                 throws Exception
Reads the file content into a byte array.

Throws:
Exception

write

void write(String text)
           throws Exception
Writes the text string to a file using UTF-8 encoding. No Byte Order Mark (BOM) is written.

Parameters:
text -
Throws:
Exception

write

void write(String text,
           String encoding)
           throws Exception
Writes the text string to a file using the specified encoding. Accepted encodings are those supported by Charset class. Example:
    write("text\n", "EUC-JP");
 

Parameters:
text -
encoding -
Throws:
Exception

write

void write(byte[] bytes)
           throws Exception
Writes the byte array to a file.

Parameters:
bytes -
Throws:
Exception

createFolder

boolean createFolder()
Creates a folder corresponding to this file object. This method throws an exception if the file path is outside of permitted area. For example, attempt to create a user file named "../../folder" will fail.


OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.