| com.sun.midp.io.j2me.file.Protocol
Protocol | public class Protocol extends ConnectionBaseAdapter implements FileConnection(Code) | | This class implements the necessary functionality
for a File connection.
|
Constructor Summary | |
public | Protocol() Constructor for file connection implementation. |
Method Summary | |
public long | availableSize() | public boolean | canRead() | public boolean | canWrite() | final protected void | checkReadPermission() Checks that the application has permission to read. | final protected void | checkRootReadPermission() Checks that the application has permission to read the root path. | final protected void | checkWritePermission() Checks that the application has permission to write. | protected void | closeInputStream() Called once by each child input stream. | protected void | closeOutputStream() Called once by each child output stream. | protected void | connect(String name, int mode, boolean timeouts) Establishes the connection. | public void | create() | public void | delete() | public long | directorySize(boolean includeSubDirs) | protected void | disconnect() Free up the connection resources. | protected void | ensureConnected() Checks that the connection is already open. | protected void | ensureOpenAndConnected() Checks that the connection is already open and connected. | public boolean | exists() | public long | fileSize() | protected void | flush() Forces any buffered output bytes to be written out. | public String | getName() | public String | getPath() | public String | getURL() | public boolean | isDirectory() | public boolean | isHidden() | public boolean | isOpen() | public long | lastModified() | public Enumeration | list() | public Enumeration | list(String filter, boolean includeHidden) | public static Vector | listRoots() Gets an array of file system roots. | public void | mkdir() | public InputStream | openInputStream() Open and return an input stream for a connection. | public OutputStream | openOutputStream() Open and return an output stream for a connection. | public OutputStream | openOutputStream(long byteOffset) | public Connection | openPrim(String name, int mode, boolean timeouts) Opens the file connection. | public Connection | openPrim(SecurityToken token, String name) Opens the file connection and receive security token. | public Connection | openPrim(SecurityToken token, String name, int mode) Opens the file connection and receive security token. | protected int | readBytes(byte b, int off, int len) Reads up to len bytes of data from the input stream into
an array of bytes, blocks until at least one byte is available.
Parameters: b - the buffer into which the data is read. Parameters: off - the start offset in array b at which the data is written. Parameters: len - the maximum number of bytes to read. | public void | rename(String newName) | public void | setFileConnection(String fileName) | public void | setHidden(boolean hidden) | public void | setReadable(boolean readable) | public void | setWritable(boolean writable) | public long | totalSize() | public void | truncate(long byteOffset) | public long | usedSize() | protected int | writeBytes(byte b, int off, int len) Writes len bytes from the specified byte array
starting at offset off to this output stream.
Polling the native code is done here to allow for simple
asynchronous native code to be written. |
Protocol | public Protocol()(Code) | | Constructor for file connection implementation.
|
availableSize | public long availableSize()(Code) | | |
canRead | public boolean canRead()(Code) | | |
canWrite | public boolean canWrite()(Code) | | |
closeInputStream | protected void closeInputStream() throws IOException(Code) | | Called once by each child input stream.
If the input stream is marked open, it will be marked closed and
the if the connection and output stream are closed the disconnect
method will be called.
exception: IOException - if the subclass throws one |
closeOutputStream | protected void closeOutputStream() throws IOException(Code) | | Called once by each child output stream.
If the output stream is marked open, it will be marked closed and
the if the connection and input stream are closed the disconnect
method will be called.
exception: IOException - if the subclass throws one |
connect | protected void connect(String name, int mode, boolean timeouts) throws IOException(Code) | | Establishes the connection.
Parameters: name - URL path fragment Parameters: mode - access mode Parameters: timeouts - flag to indicate that timeouts allowed throws: IOException - if an error occurs |
directorySize | public long directorySize(boolean includeSubDirs) throws IOException(Code) | | |
disconnect | protected void disconnect() throws IOException(Code) | | Free up the connection resources.
exception: IOException - if an I/O error occurs. |
ensureConnected | protected void ensureConnected() throws IOException(Code) | | Checks that the connection is already open.
throws: IOException - if the connection is closed |
ensureOpenAndConnected | protected void ensureOpenAndConnected() throws IOException(Code) | | Checks that the connection is already open and connected.
throws: ConnectionClosedException - if the connection is closed throws: IOException - if any error occurs while connecting |
exists | public boolean exists()(Code) | | |
flush | protected void flush() throws IOException(Code) | | Forces any buffered output bytes to be written out.
The general contract of flush is
that calling it is an indication that, if any bytes previously
written that have been buffered by the connection,
should immediately be written to their intended destination.
The flush method of ConnectionBaseAdapter
does nothing.
exception: IOException - if an I/O error occurs. |
isDirectory | public boolean isDirectory()(Code) | | |
isHidden | public boolean isHidden()(Code) | | |
isOpen | public boolean isOpen()(Code) | | |
lastModified | public long lastModified()(Code) | | |
listRoots | public static Vector listRoots()(Code) | | Gets an array of file system roots.
up-to-date array of file system roots;empty array is returned if there are no roots available. |
openInputStream | public InputStream openInputStream() throws IOException(Code) | | Open and return an input stream for a connection. The connection's
target must already exist and be accessible for the input stream to be
created.
An open input stream exception: IOException - if an I/O error occurs, if the method is invokedon a directory, if the connection's target does notyet exist, or the connection's target is not accessible. exception: IllegalModeException - if the application does have readaccessto the connection's target but has opened the connection inConnector.WRITE mode. exception: SecurityException - If the application is not granted readaccess to the connection's target. |
openOutputStream | public OutputStream openOutputStream() throws IOException(Code) | | Open and return an output stream for a connection. The output stream
is positioned at the start of the file. Writing data to the output
stream overwrites the contents of the files (i.e. does not insert data).
Writing data to output streams beyond the current end of file
automatically extends the file size. The connection's target must
already exist and be accessible for the output stream to be created.
Protocol.openOutputStream(long) should be used to position an output
stream to a different position in the file.
Changes made to a file through an output stream may not be immediately
made to the actual file residing on the file system because
platform and implementation specific use of caching and buffering of the
data. Stream contents and file length extensions are not necessarily
visible outside of the application immediately unless
flush() is called on the stream.? The returned output
stream is automatically and synchronously flushed when it is closed.
An open output stream exception: IOException - If an I/O error occurs, if the method isinvoked ona directory, the file does not yet exist, or the connection'starget is not accessible. exception: IllegalModeException - if the application does have writeaccessto the connection's target but has opened the connection inConnector.READ mode. exception: SecurityException - If the application is not granted writeaccess to the connection's target. See Also: Protocol.openOutputStream(long) |
openPrim | public Connection openPrim(String name, int mode, boolean timeouts) throws IOException(Code) | | Opens the file connection.
Parameters: name - URL path fragment Parameters: mode - access mode Parameters: timeouts - flag to indicate that timeouts allowed an opened Connection throws: IOException - if some other kind of I/O error occurs. |
openPrim | public Connection openPrim(SecurityToken token, String name) throws IOException(Code) | | Opens the file connection and receive security token.
Parameters: token - security token from PIM Parameters: name - URL path fragment an opened Connection throws: IOException - if some other kind of I/O error occurs. |
openPrim | public Connection openPrim(SecurityToken token, String name, int mode) throws IOException(Code) | | Opens the file connection and receive security token.
Parameters: token - security token from PIM Parameters: name - URL path fragment Parameters: mode - access mode an opened Connection throws: IOException - if some other kind of I/O error occurs. |
readBytes | protected int readBytes(byte b, int off, int len) throws IOException(Code) | | Reads up to len bytes of data from the input stream into
an array of bytes, blocks until at least one byte is available.
Parameters: b - the buffer into which the data is read. Parameters: off - the start offset in array b at which the data is written. Parameters: len - the maximum number of bytes to read. the total number of bytes read into the buffer, or-1 if there is no more data because the end ofthe stream has been reached. exception: IOException - if an I/O error occurs. |
totalSize | public long totalSize()(Code) | | |
usedSize | public long usedSize()(Code) | | |
writeBytes | protected int writeBytes(byte b, int off, int len) throws IOException(Code) | | Writes len bytes from the specified byte array
starting at offset off to this output stream.
Polling the native code is done here to allow for simple
asynchronous native code to be written. Not all implementations
work this way (they block in the native code) but the same
Java code works for both.
Parameters: b - the data. Parameters: off - the start offset in the data. Parameters: len - the number of bytes to write. number of bytes written exception: IOException - if an I/O error occurs. In particular,an IOException is thrown if the outputstream is closed. |
|
|