public class FileArgumentType extends Object implements ArgumentType<File>
File
object. The
command-line programs traditionally accept the file path "-" as standard
input. This object supports this when
acceptSystemIn()
is used. Also there are several
convenient verification features such as checking readability or existence.Constructor and Description |
---|
FileArgumentType() |
Modifier and Type | Method and Description |
---|---|
FileArgumentType |
acceptSystemIn()
If the argument is "-", accept it as standard input.
|
File |
convert(ArgumentParser parser,
Argument arg,
String value)
Converts
value to appropriate type. |
FileArgumentType |
or()
Start a new verification group.
|
FileArgumentType |
verifyCanCreate()
Verifies that the specified path is writable.
|
FileArgumentType |
verifyCanExecute()
Verifies that the specified path is executable.
|
FileArgumentType |
verifyCanRead()
Verifies that the specified path is readable.
|
FileArgumentType |
verifyCanWrite()
Verifies that the specified path is writable.
|
FileArgumentType |
verifyCanWriteParent()
Verifies that the parent directory of the specified path is writable.
|
FileArgumentType |
verifyExists()
Verifies that the specified path exists.
|
FileArgumentType |
verifyIsAbsolute()
Verifies that the specified path is an absolute path.
|
FileArgumentType |
verifyIsDirectory()
Verifies that the specified path is a directory.
|
FileArgumentType |
verifyIsFile()
Verifies that the specified path is a regular file.
|
FileArgumentType |
verifyNotExists()
Verifies that the specified path does not exist.
|
public FileArgumentType acceptSystemIn()
public FileArgumentType verifyExists()
public FileArgumentType verifyNotExists()
public FileArgumentType verifyIsFile()
public FileArgumentType verifyIsDirectory()
public FileArgumentType verifyCanRead()
public FileArgumentType verifyCanWrite()
public FileArgumentType verifyCanWriteParent()
public FileArgumentType verifyCanCreate()
public FileArgumentType verifyCanExecute()
public FileArgumentType verifyIsAbsolute()
public FileArgumentType or()
public File convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException
ArgumentType
Converts value
to appropriate type.
If the objects derived from RuntimeException
are thrown in
conversion because of invalid input from command line, subclass must
catch these exceptions and wrap them in ArgumentParserException
and give simple error message to explain what happened briefly.
convert
in interface ArgumentType<File>
parser
- The parser.arg
- The argument this type attached to.value
- The attribute value.ArgumentParserException
- If conversion fails.Copyright © 2012–2017. All rights reserved.