|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.jini.system.CommandLine
public abstract class CommandLine
CommandLine
is a base class for command line parsing
classes. It provides several useful methods for the implementor
of the subclass and for the programmer. It also defines exceptions
that can be generated during parsing commands.
CommandLine
provides you several methods to get input
streams from the command line. If these do not suffice for your
particular needs, you can get the argument as a String
and do your own processing.
You can use these methods to parse your own operand arguments. For
example, if your operands are integers, you may want to use
parseInt
to parse them to provide consistency to the
user.
POSIXCommandLine
,
MultiCommandLine
Nested Class Summary | |
---|---|
static class |
CommandLine.BadInvocationException
Signal that the user specified an option in an improper way. |
static class |
CommandLine.HelpOnlyException
Signal that this was a "help only" invocation. |
static class |
CommandLine.ProgrammingException
Signal that the programmer has invoked a method out of order. |
Constructor Summary | |
---|---|
CommandLine()
|
Method Summary | |
---|---|
static double |
parseDouble(String str,
double defaultValue)
Return the result of parsing the given double from
the command line. |
static InputStream |
parseInputStream(String path,
InputStream defaultValue)
Return a InputStream that is the result of creating
a new FileInputStream object for the file named by
the given path . |
static InputStream |
parseInputStream(String path,
String defaultPath)
Return a InputStream that is the result of creating
a new FileInputStream object for the file named by
the given path . |
static int |
parseInt(String str,
int defaultValue)
Return the result of parsing the given int from the
command line. |
static long |
parseLong(String str,
long defaultValue)
Return the result of parsing the given long from
the command line. |
static OutputStream |
parseOutputStream(String path,
OutputStream defaultValue)
Return a OutputStream that is the result of
creating a new FileOutputStream object for the file
named by the given path . |
static OutputStream |
parseOutputStream(String path,
String defaultPath)
Return a InputStream that is the result of creating
a new FileInputStream object for the file named by
the given path . |
static RandomAccessFile |
parseRandomAccessFile(String path,
RandomAccessFile defaultValue,
String mode)
Return a RandomAccessFile that is the result of
creating a new RandomAccessFile object for the file
named by the given path , using the given
mode . |
static RandomAccessFile |
parseRandomAccessFile(String path,
String defaultPath,
String mode)
Return a RandomAccessFile that is the result of
creating a new RandomAccessFile object for the file
named by the given path , using the given
mode . |
static Reader |
parseReader(String path,
Reader defaultValue)
Return a Reader that is the result of creating a
new FileReader object for the file named by the
given path . |
static Reader |
parseReader(String path,
String defaultPath)
Return a Reader that is the result of creating a
new FileReader object for the file named by the
given path . |
static String |
parseString(String str,
String defaultValue)
Return the result of parsing the given string from the command line. |
static Writer |
parseWriter(String path,
String defaultPath)
Return a Writer that is the result of creating a
new FileWriter object for the file named by the
given path . |
static Writer |
parseWriter(String path,
Writer defaultValue)
Return a Writer that is the result of creating a
new FileWriter object for the file named by the
given path . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CommandLine()
Method Detail |
---|
public static String parseString(String str, String defaultValue)
str
is null
, return
defaultValue
.
public static int parseInt(String str, int defaultValue) throws NumberFormatException
int
from the
command line. If str
is null
, return
defaultValue
. The value is parsed using to
understand leading 0x
or #
to
introduce a hexidecimal number, leading 0
to
introduce an octal number, and anything else to be a decimal
number.
NumberFormatException
public static long parseLong(String str, long defaultValue) throws NumberFormatException
long
from
the command line. If str
is null
,
return defaultValue
. The value is parsed using to
understand leading 0x
or #
to
introduce a hexidecimal number, leading 0
to
introduce an octal number, and anything else to be a decimal
number.
NumberFormatException
public static double parseDouble(String str, double defaultValue) throws NumberFormatException
double
from
the command line. If str
is null
,
return defaultValue
. The value is parsed using
Double.value
.
NumberFormatException
public static Writer parseWriter(String path, Writer defaultValue) throws IOException
Writer
that is the result of creating a
new FileWriter
object for the file named by the
given path
. If the argument is `-
' then
an OutputStreamWriter
for System.out
is returned. If path
is null
, return
defaultValue
.
IOException
public static Writer parseWriter(String path, String defaultPath) throws IOException
Writer
that is the result of creating a
new FileWriter
object for the file named by the
given path
. If the argument is `-
' then
an OutputStreamWriter
for System.out
is returned. If path
is null
, the
string path
is used as the file name.
IOException
public static Reader parseReader(String path, Reader defaultValue) throws IOException
Reader
that is the result of creating a
new FileReader
object for the file named by the
given path
. If the argument is `-
' then
an InputStreamReader
for System.in
is
returned. If path
is null
, return
defaultValue
.
IOException
public static Reader parseReader(String path, String defaultPath) throws IOException
Reader
that is the result of creating a
new FileReader
object for the file named by the
given path
. If the argument is `-
' then
an InputStreamReader
for System.in
is
returned. If path
is null
, the string
path
is used as the file name.
IOException
public static OutputStream parseOutputStream(String path, OutputStream defaultValue) throws IOException
OutputStream
that is the result of
creating a new FileOutputStream
object for the file
named by the given path
. If the argument is
`-
' then System.out
is returned. If
path
is null
, return
defaultValue
.
IOException
public static OutputStream parseOutputStream(String path, String defaultPath) throws IOException
InputStream
that is the result of creating
a new FileInputStream
object for the file named by
the given path
. If the argument is `-
'
then System.in
is returned. If path
is null
, the string path
is used as
the file name.
IOException
public static InputStream parseInputStream(String path, InputStream defaultValue) throws IOException
InputStream
that is the result of creating
a new FileInputStream
object for the file named by
the given path
. If the argument is `-
'
then System.in
is returned. If path
is null
, return defaultValue
.
IOException
public static InputStream parseInputStream(String path, String defaultPath) throws IOException
InputStream
that is the result of creating
a new FileInputStream
object for the file named by
the given path
. If the argument is `-
'
then System.in
is returned. If path
is null
, the string path
is used as
the file name.
IOException
public static RandomAccessFile parseRandomAccessFile(String path, RandomAccessFile defaultValue, String mode) throws IOException
RandomAccessFile
that is the result of
creating a new RandomAccessFile
object for the file
named by the given path
, using the given
mode
. If path
is null
,
return defaultValue
.
IOException
public static RandomAccessFile parseRandomAccessFile(String path, String defaultPath, String mode) throws IOException
RandomAccessFile
that is the result of
creating a new RandomAccessFile
object for the file
named by the given path
, using the given
mode
. If path
is null
,
the string path
is used as the file name.
IOException
|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |