From cde86ae7901c16718485cc89152b7c04dd2c6808 Mon Sep 17 00:00:00 2001 From: AShiningRay Date: Sun, 12 Jun 2022 01:13:47 -0300 Subject: [PATCH] javax: io: Update the file/ folder. The implementations were mostly in line with the javadocs as of the previous commit. This one makes them nearly identical to the docs. --- .../io/file/ConnectionClosedException.java | 4 +- .../microedition/io/file/FileConnection.java | 71 ++++++++++--------- .../io/file/FileSystemListener.java | 8 ++- .../io/file/FileSystemRegistry.java | 14 ++-- .../io/file/IllegalModeException.java | 4 +- 5 files changed, 60 insertions(+), 41 deletions(-) diff --git a/src/javax/microedition/io/file/ConnectionClosedException.java b/src/javax/microedition/io/file/ConnectionClosedException.java index 02acd718..45b6ffc8 100644 --- a/src/javax/microedition/io/file/ConnectionClosedException.java +++ b/src/javax/microedition/io/file/ConnectionClosedException.java @@ -18,7 +18,9 @@ public class ConnectionClosedException extends RuntimeException { - public ConnectionClosedException() {} + + public ConnectionClosedException() { } public ConnectionClosedException(String detailMessage) { System.out.println("ConnectionClosedException: " + detailMessage); } + } diff --git a/src/javax/microedition/io/file/FileConnection.java b/src/javax/microedition/io/file/FileConnection.java index 9eed4ed5..f1e7b8ae 100644 --- a/src/javax/microedition/io/file/FileConnection.java +++ b/src/javax/microedition/io/file/FileConnection.java @@ -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; @@ -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(); -} \ No newline at end of file +} diff --git a/src/javax/microedition/io/file/FileSystemListener.java b/src/javax/microedition/io/file/FileSystemListener.java index c9909085..ca3d50f2 100644 --- a/src/javax/microedition/io/file/FileSystemListener.java +++ b/src/javax/microedition/io/file/FileSystemListener.java @@ -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; + } diff --git a/src/javax/microedition/io/file/FileSystemRegistry.java b/src/javax/microedition/io/file/FileSystemRegistry.java index 7f929e0c..655fff87 100644 --- a/src/javax/microedition/io/file/FileSystemRegistry.java +++ b/src/javax/microedition/io/file/FileSystemRegistry.java @@ -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); } diff --git a/src/javax/microedition/io/file/IllegalModeException.java b/src/javax/microedition/io/file/IllegalModeException.java index 52a1def2..1d2973a6 100644 --- a/src/javax/microedition/io/file/IllegalModeException.java +++ b/src/javax/microedition/io/file/IllegalModeException.java @@ -18,7 +18,9 @@ public class IllegalModeException extends RuntimeException { - public IllegalModeException() {} + + public IllegalModeException() { } public IllegalModeException(String detailMessage) { System.out.println("IllegalModeException: " + detailMessage); } + }