diff --git a/build.gradle b/build.gradle index 7383a5e..894132e 100755 --- a/build.gradle +++ b/build.gradle @@ -98,10 +98,17 @@ task nativeJar(type: Jar) { archiveName = 'native-platform-jni.jar' } +javadoc { + exclude '**/internal/**' +} + startScripts.classpath += nativeJar.outputs.files applicationDistribution.from(nativeJar) { into 'lib' } +applicationDistribution.from(javadoc) { + into 'javadoc' +} libraries.all { it.spec.task.dependsOn nativeHeaders diff --git a/src/main/java/net/rubygrapefruit/platform/FileSystem.java b/src/main/java/net/rubygrapefruit/platform/FileSystem.java index be33096..3679c28 100644 --- a/src/main/java/net/rubygrapefruit/platform/FileSystem.java +++ b/src/main/java/net/rubygrapefruit/platform/FileSystem.java @@ -2,12 +2,27 @@ package net.rubygrapefruit.platform; import java.io.File; +/** + * Information about a file system. This is a snapshot view and does not change. + */ public interface FileSystem { + /** + * Returns the root directory of this file system. + */ File getMountPoint(); + /** + * Returns the operating system specific name for the type of this file system. + */ String getFileSystemType(); + /** + * Returns true if this file system is a remote file system, or false if local. + */ boolean isRemote(); + /** + * Returns the operating system specific name for this file system. + */ String getDeviceName(); } diff --git a/src/main/java/net/rubygrapefruit/platform/FileSystems.java b/src/main/java/net/rubygrapefruit/platform/FileSystems.java index 2d689d0..6411fc9 100644 --- a/src/main/java/net/rubygrapefruit/platform/FileSystems.java +++ b/src/main/java/net/rubygrapefruit/platform/FileSystems.java @@ -2,6 +2,9 @@ package net.rubygrapefruit.platform; import java.util.List; +/** + * Provides access to the file systems of the current machine. + */ public interface FileSystems extends NativeIntegration { /** * Returns the set of all file systems for the current machine. diff --git a/src/main/java/net/rubygrapefruit/platform/Native.java b/src/main/java/net/rubygrapefruit/platform/Native.java index d47e6b0..9d4a957 100755 --- a/src/main/java/net/rubygrapefruit/platform/Native.java +++ b/src/main/java/net/rubygrapefruit/platform/Native.java @@ -13,12 +13,16 @@ public class Native { private static final Object lock = new Object(); private static boolean loaded; + private Native() { + } + /** * Initialises the native integration, if not already initialized. * - * @param extractDir The directory to extract native resources into. May be null. + * @param extractDir The directory to extract native resources into. May be null, in which case a default is + * selected. */ - static void init(File extractDir) { + static public void init(File extractDir) { synchronized (lock) { if (!loaded) { Platform platform = Platform.current(); @@ -56,7 +60,13 @@ public class Native { } } - static T get(Class type) { + /** + * Locates a native integration of the given type. + * + * @return The native integration. + * @throws UnsupportedOperationException if the given integration is not available. + */ + public static T get(Class type) throws UnsupportedOperationException { init(null); Platform platform = Platform.current(); T integration = platform.get(type); diff --git a/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java b/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java index 1e98644..61e1d43 100644 --- a/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java +++ b/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java @@ -1,4 +1,7 @@ package net.rubygrapefruit.platform; +/** + * A marker interface that represents a native integration. + */ public interface NativeIntegration { } diff --git a/src/main/java/net/rubygrapefruit/platform/PosixFile.java b/src/main/java/net/rubygrapefruit/platform/PosixFile.java index 88b8876..433d092 100644 --- a/src/main/java/net/rubygrapefruit/platform/PosixFile.java +++ b/src/main/java/net/rubygrapefruit/platform/PosixFile.java @@ -4,8 +4,6 @@ import java.io.File; /** * Functions to query and modify a file's POSIX meta-data. - * - * Supported on Linux, OS X */ public interface PosixFile extends NativeIntegration { /** diff --git a/src/main/java/net/rubygrapefruit/platform/SystemInfo.java b/src/main/java/net/rubygrapefruit/platform/SystemInfo.java index 9a35f50..a16912c 100644 --- a/src/main/java/net/rubygrapefruit/platform/SystemInfo.java +++ b/src/main/java/net/rubygrapefruit/platform/SystemInfo.java @@ -1,27 +1,21 @@ package net.rubygrapefruit.platform; /** - * Provides access to some system information. + * Provides access to some system information. This is a snapshot view and does not change. */ public interface SystemInfo extends NativeIntegration { /** * Returns the name of the kernel for the current operating system. - * - * @throws NativeException on failure. */ - String getKernelName() throws NativeException; + String getKernelName(); /** * Returns the version of the kernel for the current operating system. - * - * @throws NativeException on failure. */ - String getKernelVersion() throws NativeException; + String getKernelVersion(); /** * Returns the machine architecture, as reported by the operating system. - * - * @throws NativeException on failure. */ - String getMachineArchitecture() throws NativeException; + String getMachineArchitecture(); } diff --git a/src/main/java/net/rubygrapefruit/platform/Terminal.java b/src/main/java/net/rubygrapefruit/platform/Terminal.java index bc87614..d7230f0 100644 --- a/src/main/java/net/rubygrapefruit/platform/Terminal.java +++ b/src/main/java/net/rubygrapefruit/platform/Terminal.java @@ -6,6 +6,9 @@ package net.rubygrapefruit.platform; * Supported on Linux, OS X, Windows. */ public interface Terminal { + /** + * Colors supported by a terminal. + */ enum Color { Black, Red, Green, Yellow, Blue, Magenta, Cyan, White } diff --git a/src/main/java/net/rubygrapefruit/platform/TerminalSize.java b/src/main/java/net/rubygrapefruit/platform/TerminalSize.java index 99ce742..e9bb74f 100644 --- a/src/main/java/net/rubygrapefruit/platform/TerminalSize.java +++ b/src/main/java/net/rubygrapefruit/platform/TerminalSize.java @@ -1,7 +1,16 @@ package net.rubygrapefruit.platform; +/** + * The size of a terminal. This is a snapshot view and does not change. + */ public interface TerminalSize { + /** + * Returns the number of character columns in the terminal. + */ public int getCols(); + /** + * Returns the number of character rows in the terminal. + */ public int getRows(); } diff --git a/src/main/java/net/rubygrapefruit/platform/Terminals.java b/src/main/java/net/rubygrapefruit/platform/Terminals.java index 76ea3c9..3c82711 100644 --- a/src/main/java/net/rubygrapefruit/platform/Terminals.java +++ b/src/main/java/net/rubygrapefruit/platform/Terminals.java @@ -6,6 +6,9 @@ package net.rubygrapefruit.platform; * Supported on Linux, OS X, Windows. */ public interface Terminals extends NativeIntegration { + /** + * System outputs. + */ enum Output {Stdout, Stderr} /** diff --git a/src/main/java/net/rubygrapefruit/platform/package-info.java b/src/main/java/net/rubygrapefruit/platform/package-info.java new file mode 100644 index 0000000..4ce0c7a --- /dev/null +++ b/src/main/java/net/rubygrapefruit/platform/package-info.java @@ -0,0 +1,4 @@ +/** + * The native integrations. Use {@link net.rubygrapefruit.platform.Native#get(Class)} to access a native integration. + */ +package net.rubygrapefruit.platform; \ No newline at end of file