public abstract class Script
extends java.lang.Object
Script
class is mainly used as an extension point for functionality that are, or are supposed to be, a part of the core program itself.
As this project matures, other extension point mechanisms are likely to be added in the future.
Modifier | Constructor and Description |
---|---|
protected |
Script()
Constructs a new
Script instance. |
Modifier and Type | Method and Description |
---|---|
static void |
copy(java.io.File file,
java.io.File directory)
Copies
file to directory . |
static void |
copy(java.io.File file,
java.io.OutputStream outputStream)
Copies
file to outputStream . |
static void |
copy(java.io.InputStream inputStream,
java.io.File file)
Copies the data from
inputStream to file . |
static void |
copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Copies the data from
inputStream to outputStream . |
static boolean |
delete(java.io.File file)
Deletes the file or directory denoted by the abstract pathname provided by
file . |
static boolean |
delete(java.lang.String pathname)
Deletes the file or directory denoted by the abstract pathname provided by
pathname . |
static java.util.List<java.io.File> |
empty(java.io.File directory)
Returns a
List with the File s that were deleted, as a result of emptying directory . |
static java.util.List<java.io.File> |
empty(java.lang.String directoryPath)
Returns a
List with the File s that were deleted, as a result of emptying the directory given by directoryPath . |
static java.util.List<java.io.File> |
getDirectoriesFromDirectory(java.io.File root)
Adds all
File s that are direct or indirect children to root and file.isDirectory() returns true , to a List , starting from root . |
static java.util.List<java.io.File> |
getDirectoriesFromDirectory(java.io.File root,
java.util.List<java.io.File> directories)
Adds all
File s that are direct or indirect children to root and file.isDirectory() returns true , to directories , starting from root . |
static java.util.List<java.io.File> |
getFilesFromDirectory(java.io.File root)
Adds all
File s that are direct or indirect children to root and file.isFile() returns true , to a List , starting from root . |
static java.util.List<java.io.File> |
getFilesFromDirectory(java.io.File root,
java.util.List<java.io.File> files)
Adds all
File s that are direct or indirect children to root and file.isFile() returns true , to files , starting from root . |
static java.util.List<java.io.File> |
getFilesFromDirectory(java.lang.String root)
Adds all
File s that are direct or indirect children to root and file.isFile() returns true , to a List , starting from root . |
static boolean |
javac(java.io.File classOutput,
java.io.File[] classPath,
java.io.File[] sourcePath,
java.io.File[] sourceFiles) |
static boolean |
javac(java.io.File classOutput,
java.util.List<java.io.File> classPath,
java.util.List<java.io.File> sourcePath,
java.util.List<java.io.File> sourceFiles) |
static boolean |
javac(java.lang.String classOutput,
java.util.List<java.io.File> classPath,
java.util.List<java.io.File> sourcePath,
java.util.List<java.io.File> sourceFiles) |
static boolean |
javac(java.lang.String classOutput,
java.lang.String[] classPath,
java.lang.String[] sourcePath,
java.lang.String[] sourceFiles) |
static boolean |
mkdir(java.io.File directory)
Creates the directory named by the abstract pathname provided by
directory . |
static boolean |
mkdir(java.lang.String directoryPath)
Creates the directory named by the abstract pathname provided by
directoryPath . |
static boolean |
mkdirs(java.io.File directory)
Creates the directory named by the abstract pathname provided by
directory , including any necessary but nonexistent parent directories. |
static boolean |
mkdirs(java.lang.String directoryPath)
Creates the directory named by the abstract pathname provided by
directoryPath , including any necessary but nonexistent parent directories. |
static void |
unzip(java.io.File file,
java.io.File directory)
Unzips
file to directory . |
static void |
zip(java.io.File directory,
java.io.File file)
Zips
directory to file . |
public static boolean delete(java.io.File file)
file
.
Returns true
if, and only if, the file or directory was deleted, false
otherwise.
If file
is null
, a NullPointerException
will be thrown.
file
- a File
true
if, and only if, the file or directory was deleted, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, file
is null
public static boolean delete(java.lang.String pathname)
pathname
.
Returns true
if, and only if, the file or directory was deleted, false
otherwise.
If pathname
is null
, a NullPointerException
will be thrown.
pathname
- a String
with the abstract pathnametrue
if, and only if, the file or directory was deleted, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, pathname
is null
public static boolean javac(java.io.File classOutput, java.io.File[] classPath, java.io.File[] sourcePath, java.io.File[] sourceFiles) throws java.io.IOException
java.io.IOException
public static boolean javac(java.io.File classOutput, java.util.List<java.io.File> classPath, java.util.List<java.io.File> sourcePath, java.util.List<java.io.File> sourceFiles) throws java.io.IOException
java.io.IOException
public static boolean javac(java.lang.String classOutput, java.util.List<java.io.File> classPath, java.util.List<java.io.File> sourcePath, java.util.List<java.io.File> sourceFiles) throws java.io.IOException
java.io.IOException
public static boolean javac(java.lang.String classOutput, java.lang.String[] classPath, java.lang.String[] sourcePath, java.lang.String[] sourceFiles) throws java.io.IOException
java.io.IOException
public static boolean mkdir(java.io.File directory)
directory
.
Returns true
if, and only if, the directory was created, false
otherwise.
If directory
is null
, a NullPointerException
will be thrown.
directory
- a File
true
if, and only if, the directory was created, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, directory
is null
public static boolean mkdir(java.lang.String directoryPath)
directoryPath
.
Returns true
if, and only if, the directory was created, false
otherwise.
If directoryPath
is null
, a NullPointerException
will be thrown.
directoryPath
- a String
with the abstract pathnametrue
if, and only if, the directory was created, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, directoryPath
is null
public static boolean mkdirs(java.io.File directory)
directory
, including any necessary but nonexistent parent directories.
Returns true
if, and only if, the directory was created, along with all necessary parent directories, false
otherwise.
If directory
is null
, a NullPointerException
will be thrown.
directory
- a File
true
if, and only if, the directory was created, along with all necessary parent directories, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, directory
is null
public static boolean mkdirs(java.lang.String directoryPath)
directoryPath
, including any necessary but nonexistent parent directories.
Returns true
if, and only if, the directory was created, along with all necessary parent directories, false
otherwise.
If directoryPath
is null
, a NullPointerException
will be thrown.
directoryPath
- a String
with the abstract pathnametrue
if, and only if, the directory was created, along with all necessary parent directories, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, directoryPath
is null
public static java.util.List<java.io.File> empty(java.io.File directory) throws java.io.IOException
List
with the File
s that were deleted, as a result of emptying directory
.
If directory
is null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
directory
- the directory to emptyList
with the File
s that were deleted, as a result of emptying directory
java.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, directory
is null
public static java.util.List<java.io.File> empty(java.lang.String directoryPath) throws java.io.IOException
List
with the File
s that were deleted, as a result of emptying the directory given by directoryPath
.
If directoryPath
is null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
directoryPath
- the path to the directory to emptyList
with the File
s that were deleted, as a result of emptying the directory given by directoryPath
java.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, directoryPath
is null
public static java.util.List<java.io.File> getDirectoriesFromDirectory(java.io.File root)
File
s that are direct or indirect children to root
and file.isDirectory()
returns true
, to a List
, starting from root
.
Returns a List
of File
s denoting directories.
Calling this method is equivalent to calling getDirectoriesFromDirectory(root, new ArrayList<>())
.
If root
is null
, a NullPointerException
will be thrown.
If root.isDirectory()
returns false
, an empty List
will be returned.
root
- the root directoryList
of File
s denoting directoriesjava.lang.NullPointerException
- thrown if, and only if, root
is null
public static java.util.List<java.io.File> getDirectoriesFromDirectory(java.io.File root, java.util.List<java.io.File> directories)
File
s that are direct or indirect children to root
and file.isDirectory()
returns true
, to directories
, starting from root
.
Returns directories
.
If either root
or directories
are null
, a NullPointerException
will be thrown.
If root.isDirectory()
returns false
, directories
will be returned, in its initial state.
root
- the root directorydirectories
- the List
to add to and returndirectories
java.lang.NullPointerException
- thrown if, and only if, either root
or directories
are null
public static java.util.List<java.io.File> getFilesFromDirectory(java.io.File root)
File
s that are direct or indirect children to root
and file.isFile()
returns true
, to a List
, starting from root
.
Returns a List
of File
s denoting files.
Calling this method is equivalent to calling getFilesFromDirectory(root, new ArrayList<>())
.
If root
is null
, a NullPointerException
will be thrown.
If root.isDirectory()
returns false
, an empty List
will be returned.
root
- the root directoryList
of File
s denoting filesjava.lang.NullPointerException
- thrown if, and only if, root
is null
public static java.util.List<java.io.File> getFilesFromDirectory(java.io.File root, java.util.List<java.io.File> files)
File
s that are direct or indirect children to root
and file.isFile()
returns true
, to files
, starting from root
.
Returns files
.
If either root
or files
are null
, a NullPointerException
will be thrown.
If root.isDirectory()
returns false
, files
will be returned, in its initial state.
root
- the root directoryfiles
- the List
to add to and returnfiles
java.lang.NullPointerException
- thrown if, and only if, either root
or files
are null
public static java.util.List<java.io.File> getFilesFromDirectory(java.lang.String root)
File
s that are direct or indirect children to root
and file.isFile()
returns true
, to a List
, starting from root
.
Returns a List
of File
s denoting files.
Calling this method is equivalent to calling getFilesFromDirectory(new File(root), new ArrayList<>())
.
If root
is null
, a NullPointerException
will be thrown.
If new File(root).isDirectory()
returns false
, an empty List
will be returned.
root
- the root directoryList
of File
s denoting filesjava.lang.NullPointerException
- thrown if, and only if, root
is null
public static void copy(java.io.File file, java.io.File directory) throws java.io.IOException
file
to directory
.
If either file
or directory
are null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
file
- the file to copydirectory
- the directory to copy the file tojava.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, either file
or directory
are null
public static void copy(java.io.File file, java.io.OutputStream outputStream) throws java.io.IOException
file
to outputStream
.
If either file
or outputStream
are null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
file
- the file to copyoutputStream
- the OutputStream
to copy the file tojava.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, either file
or outputStream
are null
public static void copy(java.io.InputStream inputStream, java.io.File file) throws java.io.IOException
inputStream
to file
.
If either inputStream
or file
are null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
inputStream
- the InputStream
to read the data to be copied fromfile
- the file to copy tojava.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, either inputStream
or file
are null
public static void copy(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
inputStream
to outputStream
.
If either inputStream
or outputStream
are null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
inputStream
- the InputStream
to read the data to be copied fromoutputStream
- the OutputStream
to copy the data tojava.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, either inputStream
or outputStream
are null
public static void unzip(java.io.File file, java.io.File directory) throws java.io.IOException
file
to directory
.
If either file
or directory
are null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
file
- the file to unzipdirectory
- the directory to unzip the file tojava.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, either file
or directory
are null
public static void zip(java.io.File directory, java.io.File file) throws java.io.IOException
directory
to file
.
If either directory
or file
are null
, a NullPointerException
will be thrown.
If some I/O-related error occurs, an IOException
will be thrown.
directory
- the directory to zipfile
- the file to zip the directory tojava.io.IOException
- thrown if, and only if, some I/O-related error occursjava.lang.NullPointerException
- thrown if, and only if, either directory
or file
are null