|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcmdline.AbstractParameter
jcmdline.PdfFileParam
public class PdfFileParam
Encapsulate a command line parameter whose value will be the name of a pdf document amd its password (Ex. file.pdf:pwd). Attributes, such as whether it must be readable, etc, may be specified and will be validated.
Usage:
public static void main(String[] args) { PdfFileParam filesArg = new PdfFileParam("file", "a file to be processed - defaults to stdin", PdfFileParam.IS_READABLE, PdfFileParam.OPTIONAL, PdfFileParam.MULTI_VALUED); }
CmdLineParser
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_FILE_OPTION_LABEL
the default label that will represent option values for this Parameter. |
static int |
EXISTS
indicates that a file specified as a value for this PdfFileParam must exist |
static int |
IS_READABLE
indicates that a value specified for this PdfFileParam must name an existing file for which the caller has read access |
static int |
IS_WRITEABLE
indicates that a value specified for this PdfFileParam must name an existing file for which the caller has write access |
static int |
NO_ATTRIBUTES
indicates that no file/dir attributes are required or will be checked |
Fields inherited from class jcmdline.AbstractParameter |
---|
acceptableValues, desc, hidden, ignoreRequired, multiValued, optional, optionLabel, set, tag, values |
Fields inherited from interface jcmdline.Parameter |
---|
HIDDEN, MULTI_VALUED, OPTIONAL, PUBLIC, REQUIRED, SINGLE_VALUED |
Constructor Summary | |
---|---|
PdfFileParam(java.lang.String tag,
java.lang.String desc)
constructor - creates single-valued, optional, public parameter which accepts any valid file name as its value |
|
PdfFileParam(java.lang.String tag,
java.lang.String desc,
boolean optional)
constructor - creates single-valued, public parameter which accepts any valid file name as its value and is optional or required, as specified. |
|
PdfFileParam(java.lang.String tag,
java.lang.String desc,
int attributes)
constructor - creates a single-valued, optional, public, parameter accepts a file name with the specified attributes. |
|
PdfFileParam(java.lang.String tag,
java.lang.String desc,
int attributes,
boolean optional)
constructor - creates a single-valued, public, parameter that accepts a file name with the specified attributes, and which is required or optional, as specified. |
|
PdfFileParam(java.lang.String tag,
java.lang.String desc,
int attributes,
boolean optional,
boolean multiValued)
constructor - creates a public parameter that accepts a file name with the specified attributes, and which is required or optional and/or multi-valued, as specified. |
|
PdfFileParam(java.lang.String tag,
java.lang.String desc,
int attributes,
boolean optional,
boolean multiValued,
boolean hidden)
constructor - creates a parameter that accepts a file name with the specified attributes, and which is required or optional and/or multi-valued or hidden, as specified. |
Method Summary | |
---|---|
boolean |
attrSpecified(int attr)
Indicates whether an attribute has been specified for this FileParam. |
int |
getAttributes()
gets the value of attributes |
PdfFile |
getPdfFile()
Gets the value of the PdfFileParam as a PdfFileParam object. |
java.util.Collection |
getPdfFiles()
Gets the values of the PdfFileParam as a Collection of PdfFile objects. |
void |
setAttributes(int attributes)
Sets the value of attributes. |
void |
validateValue(java.lang.String val)
Validates a prospective value for the PdfFileParam - called by add/setValue(s)(). |
Methods inherited from class jcmdline.AbstractParameter |
---|
addValue, getAcceptableValues, getDesc, getIgnoreRequired, getOptionLabel, getTag, getValue, getValues, isHidden, isMultiValued, isOptional, isSet, setAcceptableValues, setAcceptableValues, setDesc, setHidden, setIgnoreRequired, setMultiValued, setOptional, setOptionLabel, setTag, setValue, setValues, setValues |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_ATTRIBUTES
setAttributes()
,
Constant Field Valuespublic static final int EXISTS
setAttributes()
,
Constant Field Valuespublic static final int IS_READABLE
setAttributes()
,
Constant Field Valuespublic static final int IS_WRITEABLE
setAttributes()
,
Constant Field Valuespublic static final java.lang.String DEFAULT_FILE_OPTION_LABEL
out <file> the output file
setOptionLabel()
,
"PdfFileParam.defaultFileOptionLabel in 'strings' properties
file"Constructor Detail |
---|
public PdfFileParam(java.lang.String tag, java.lang.String desc)
tag
- a unique identifier for this parameterdesc
- a description of the parameter, suitable for display
in a usage statement
java.lang.IllegalArgumentException
- if tag
or setTag()
,
setDesc()
public PdfFileParam(java.lang.String tag, java.lang.String desc, boolean optional)
tag
- a unique identifier for this parameterdesc
- a description of the parameter, suitable for display
in a usage statementoptional
- OPTIONAL
if
optional,
REQUIRED
if required
java.lang.IllegalArgumentException
- if any of the specified
parameters are invalid.setTag()
,
setDesc()
,
OPTIONAL
,
REQUIRED
public PdfFileParam(java.lang.String tag, java.lang.String desc, int attributes)
tag
- a unique identifier for this parameterdesc
- a description of the parameter, suitable for display
in a usage statementattributes
- the attributes that must apply to a file or
directory specified as a value to this FileParam
java.lang.IllegalArgumentException
- if any parameter is
invalid.setTag()
,
setDesc()
,
setAttributes()
public PdfFileParam(java.lang.String tag, java.lang.String desc, int attributes, boolean optional)
tag
- a unique identifier for this parameterdesc
- a description of the parameter, suitable for display
in a usage statementattributes
- the attributes that must apply to a file or
directory specified as a value to this FileParamoptional
- OPTIONAL
if
optional,
REQUIRED
if required
java.lang.IllegalArgumentException
- if any parameter is
invalid.setTag()
,
setDesc()
,
setAttributes()
,
OPTIONAL
,
REQUIRED
public PdfFileParam(java.lang.String tag, java.lang.String desc, int attributes, boolean optional, boolean multiValued)
tag
- a unique identifier for this parameterdesc
- a description of the parameter, suitable for display
in a usage statementattributes
- the attributes that must apply to a file or
directory specified as a value to this FileParamoptional
- OPTIONAL
if
optional,
REQUIRED
if requiredmultiValued
- MULTI_VALUED
if
the parameter can accept multiple values,
SINGLE_VALUED
if the parameter can contain only a single value
java.lang.IllegalArgumentException
- if any parameter is
invalid.setTag()
,
setDesc()
,
setAttributes()
,
OPTIONAL
,
REQUIRED
,
SINGLE_VALUED
,
MULTI_VALUED
public PdfFileParam(java.lang.String tag, java.lang.String desc, int attributes, boolean optional, boolean multiValued, boolean hidden)
If the IS_DIR
attribute is specified, the option label for
this FileParam will be set to #DEFAULT_DIR_OPTION_LABEL
,
else it will be DEFAULT_FILE_OPTION_LABEL
.
tag
- a unique identifier for this parameterdesc
- a description of the parameter, suitable for display
in a usage statementattributes
- the attributes that must apply to a file or
directory specified as a value to this FileParamoptional
- OPTIONAL
if
optional,
REQUIRED
if requiredmultiValued
- MULTI_VALUED
if
the parameter can accept multiple values,
SINGLE_VALUED
if the parameter can contain only a single valuehidden
- HIDDEN
if parameter is
not to be listed in the usage,
PUBLIC
otherwise.
java.lang.IllegalArgumentException
- if any parameter is
invalid.setTag()
,
setDesc()
,
setOptionLabel()
,
setAttributes()
,
OPTIONAL
,
REQUIRED
,
SINGLE_VALUED
,
MULTI_VALUED
,
HIDDEN
,
PUBLIC
Method Detail |
---|
public PdfFile getPdfFile()
java.lang.RuntimeException
- if the value of the FileParam
has not been set.Parameter.isSet()
public java.util.Collection getPdfFiles()
Parameter.isSet()
public void validateValue(java.lang.String val) throws CmdLineException
validateValue
in interface Parameter
validateValue
in class AbstractParameter
val
- the value to validate
CmdLineException
- if value
is not valid.setAttributes()
public boolean attrSpecified(int attr)
attr
- one of NO_ATTRIBUTES
, EXISTS
,
IS_READABLE
, or
IS_WRITEABLE
true
if the attribute is set,
false
if the attribute is not set or
attr
is not a valid attributepublic void setAttributes(int attributes)
FileParam fp = new FileParam("tempDir", "a directory in which temporary files can be stored", FileParam.IS_DIR & FileParam.IS_WRITEABLE);In this case, a valid parameter value would have to be both a directory and writeable.
Specify NO_ATTRIBUTES
if none of the other attributes is
required.
attributes
- a combination of NO_ATTRIBUTES
,
EXISTS
,
IS_READABLE
, and IS_WRITEABLE
java.lang.IllegalArgumentException
- if the attributes value
is invalid.getAttributes()
public int getAttributes()
setAttributes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |