XML Deployment Adapters

com.exln.stylus.io
Interface StylusFile


public interface StylusFile

An abstract representation of a file in a custom file system. This class is roughly comparable to the Java class File. Just as with the File class, the constructor for this class should be fairly fast because the Stylus Studio Input/Output framework creates and destroys them frequently, even though the actual file may never be read.


Method Summary
 void close()
          Close and release any resources held by this StylusFile object.
 void copyFromFile(String fileName)
          Copy the contents of a named file to this StylusFile.
 void copyToFile(String fileName)
          Copy the contents of this StylusFile to a named file.
 InputStream getInputStream()
          Return a stream which can be used to read data from this StylusFile.
 long getModifiedTime()
          Return the time that the file denoted by this StylusFile was last modified.
 String getName()
          Return the file name of this StylusFile.
 OutputStream getOutputStream()
          Return an output stream which can be used to write data to this StylusFile.
 String getPath()
          Return the pathname of this StylusFile.
 boolean isDirectory()
          Return whether the file denoted by this StylusFile is a directory.
 boolean isDots()
          Return true if getName() would return "." or "..".
 boolean isHidden()
          Return true if this StylusFile denotes a "Hidden" file.
 boolean isLink()
          Return true if this StylusFile denotes a link or shortcut file.
 boolean isReadOnly()
          Return whether the file represented by this StylusFile is read-only.
 long length()
          Return the number of bytes in this StylusFile.
 StylusFile[] listFiles()
          Return an array of StylusFile objects denoting the files in the directory denoted by this StylusFile.
 

Method Detail

listFiles

public StylusFile[] listFiles()
Return an array of StylusFile objects denoting the files in the directory denoted by this StylusFile.


isDirectory

public boolean isDirectory()
Return whether the file denoted by this StylusFile is a directory.

Returns:
true if the file is a directory.

isReadOnly

public boolean isReadOnly()
Return whether the file represented by this StylusFile is read-only.

Returns:
true if the file is read-only.

copyFromFile

public void copyFromFile(String fileName)
                  throws IOException
Copy the contents of a named file to this StylusFile. The Stylus Studio Input/Output framework will call this method to write data to the physical file denoted by this StylusFile. Stylus Studio first creates a temp file containing the binary data to be written, then calls copyFromFile to do the final write operation. copyFromFile must read the temp file (a FileInputStream is suitable) and write the data to the physical file denoted by this StylusFile. copyFromFile must close the temp file, but the Stylus Studio Input/Output framework will take care of deleting it.

Parameters:
fileName - the name of the input file.
Throws:
IOException

copyToFile

public void copyToFile(String fileName)
                throws IOException
Copy the contents of this StylusFile to a named file. The Stylus Studio Input/Output framework will call this method to read data from the physical file denoted by this StylusFile. copyToFile must read the data from the physical file denoted by this StylusFile and write it to the named output file. The simplest way to do this is with the static helper method StylusFileHelpers.copyToFile.

Parameters:
fileName - the name of the output file.
Throws:
IOException
See Also:
StylusFileHelpers.copyToFile(StylusFile, String)

getModifiedTime

public long getModifiedTime()
Return the time that the file denoted by this StylusFile was last modified. The actual value is not significant, but when a file is modified, the getModifiedTime should increase monotonically. The value is used by Stylus Studio to detect when a file has changed.

Returns:
A long value representing the last modification time.

getInputStream

public InputStream getInputStream()
                           throws IOException
Return a stream which can be used to read data from this StylusFile. The Stylus Studio Input/Output framework will subsequently use the read methods of the returned InputStream to read the data, and will, eventually, call the close() method of the InputStream as well as StylusFile.close().

Returns:
The InputStream which will be used to read the data.
Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Return an output stream which can be used to write data to this StylusFile. The Stylus Studio Input/Output framework will subsequently write bytes to the OutputStream, which must write them to the physical file denoted by this StylusFile. After Stylus Studio has written all the data, it will call the close() method of the OutputStream as well as StylusFile.close().

Returns:
The OutputStream which will be used to write the data.
Throws:
IOException

close

public void close()
Close and release any resources held by this StylusFile object. This method may be called repeatedly for the same StylusFile object


getName

public String getName()
Return the file name of this StylusFile. This is just the last name in the pathname's name sequence.

Returns:
The name of this StylusFile.

getPath

public String getPath()
Return the pathname of this StylusFile. This is the complete pathname without the scheme:// prefix It should always begin with a /, and all \ characters (if any) should be converted to / characters.

Returns:
The pathname of this StylusFile.
See Also:
StylusFileSystem File Naming Conventions

length

public long length()
Return the number of bytes in this StylusFile.

Returns:
The number of bytes in the file.

isDots

public boolean isDots()
Return true if getName() would return "." or "..".

Returns:
true if this pathname ends with "." or "..".

isHidden

public boolean isHidden()
Return true if this StylusFile denotes a "Hidden" file.

Returns:
true if it is a hidden file.

isLink

public boolean isLink()
Return true if this StylusFile denotes a link or shortcut file.

Returns:
true if it is a link or shortcut.


XML Deployment Adapters