Skip to content

Commit

Permalink
javax: io: Update the file/ folder.
Browse files Browse the repository at this point in the history
The implementations were mostly in line with the javadocs as of
the previous commit. This one makes them nearly identical to the
docs.
  • Loading branch information
AShiningRay committed Sep 20, 2024
1 parent f010c28 commit cde86ae
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

public class ConnectionClosedException extends RuntimeException
{
public ConnectionClosedException() {}

public ConnectionClosedException() { }

public ConnectionClosedException(String detailMessage) { System.out.println("ConnectionClosedException: " + detailMessage); }

}
71 changes: 39 additions & 32 deletions src/javax/microedition/io/file/FileConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package javax.microedition.io.file;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
Expand All @@ -26,65 +27,71 @@

public interface FileConnection extends StreamConnection
{
public long availableSize();

public boolean canRead();
long availableSize() throws SecurityException, IllegalModeException, ConnectionClosedException;

public boolean canWrite();
boolean canRead() throws SecurityException, IllegalModeException, ConnectionClosedException;

public void create();
boolean canWrite() throws SecurityException, IllegalModeException, ConnectionClosedException;

public void delete();
void create() throws IOException, SecurityException, IllegalModeException;

public long directorySize(boolean includeSubDirs);
void delete() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public boolean exists();
long directorySize(boolean includeSubDirs) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public long fileSize();
boolean exists() throws SecurityException, IllegalModeException, ConnectionClosedException;

public String getName();
long fileSize() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public String getPath();
String getName();

public String getURL();
String getPath();

public boolean isDirectory();
String getURL();

public boolean isHidden();
boolean isDirectory() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public boolean isOpen();
boolean isHidden() throws SecurityException, IllegalModeException, ConnectionClosedException;

boolean isOpen();

public long lastModified();
long lastModified() throws SecurityException, IllegalModeException, ConnectionClosedException;

Enumeration list() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public Enumeration list();
Enumeration list(String filter, boolean includeHidden) throws NullPointerException, IllegalArgumentException, IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public Enumeration list(String filter, boolean includeHidden);
void mkdir() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public void mkdir();
@Override
DataInputStream openDataInputStream() throws SecurityException, IllegalModeException;

public DataInputStream openDataInputStream();
@Override
DataOutputStream openDataOutputStream() throws SecurityException, IllegalModeException;

public DataOutputStream openDataOutputStream();
@Override
InputStream openInputStream() throws SecurityException, IllegalModeException;

public InputStream openInputStream();
@Override
OutputStream openOutputStream() throws SecurityException, IllegalModeException;

public OutputStream openOutputStream();
OutputStream openOutputStream(long byteOffset) throws IOException, SecurityException, IllegalModeException, IllegalArgumentException;

public OutputStream openOutputStream(long byteOffset);
void rename(String newName) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException, NullPointerException, IllegalArgumentException;

public void rename();
void setFileConnection(String fileName) throws IOException, SecurityException, NullPointerException, IllegalArgumentException;

public void setFileConnection(String fileName);
void setHidden(boolean hidden) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public void setHidden(boolean hidden);
void setReadable(boolean readable) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public void setReadable(boolean readable);
void setWritable(boolean writable) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException;

public void setWritable(boolean writable);
long totalSize() throws SecurityException, IllegalModeException, ConnectionClosedException;

public long totalSize();
void truncate(long byteOffset) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException, IllegalArgumentException;

public void truncate(long byteOffset);
long usedSize() throws SecurityException, IllegalModeException, ConnectionClosedException;

public long usedSize();
}
}
8 changes: 5 additions & 3 deletions src/javax/microedition/io/file/FileSystemListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

public interface FileSystemListener
{
public static final int ROOT_ADDED = 1;

static final int ROOT_ADDED = 0;

public static final int ROOT_REMOVED = 0;
static final int ROOT_REMOVED = 1;

public abstract void rootChanged(int state, String rootName);
void rootChanged(int state, String rootName) throws NullPointerException, IllegalArgumentException;

}
14 changes: 10 additions & 4 deletions src/javax/microedition/io/file/FileSystemRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@

import java.util.Enumeration;

public abstract class FileSystemRegistry
public class FileSystemRegistry extends Object
{
public abstract boolean addFileSystemListener(FileSystemListener listener);

Enumeration roots; /* A zero-length Enumeration to be used below */

public abstract Enumeration listRoots();
/* Returns true if the fileSystemListener was added. */
public static boolean addFileSystemListener(FileSystemListener listener) throws SecurityException, NullPointerException { return false; }

public Enumeration listRoots() { return roots; }; /*If no roots are found, or it's not supported, return a zero-len enum*/

/* Returns true if the fileSystemListener was removed. */
public static boolean removeFileSystemListener(FileSystemListener listener) throws NullPointerException { return false; };

public abstract boolean removeFileSystemListener(FileSystemListener listener);
}
4 changes: 3 additions & 1 deletion src/javax/microedition/io/file/IllegalModeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

public class IllegalModeException extends RuntimeException
{
public IllegalModeException() {}

public IllegalModeException() { }

public IllegalModeException(String detailMessage) { System.out.println("IllegalModeException: " + detailMessage); }

}

0 comments on commit cde86ae

Please sign in to comment.