|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.schmant.arg.AbstractArgumentInterpretationStrategy<T>
public abstract class AbstractArgumentInterpretationStrategy<T>
Field Summary |
---|
Fields inherited from interface org.schmant.arg.ArgumentInterpretationStrategy |
---|
ALLOW_NOT_INTERPRETED, ALLOW_ONE_AND_ONLY_ONE_RESULT_OBJECT |
Constructor Summary | |
---|---|
protected |
AbstractArgumentInterpretationStrategy(int[] configuration)
Create a new argument interpreted. |
Method Summary | |
---|---|
protected static void |
checkConfiguration(int[] configuration,
int[] allowedFlags)
This method may be used by subclass constructors to validate that the configuration passed to it are valid. |
protected String |
convertBackslashesToSlashes(String s)
Convert all backslashes in the string to forward slashes. |
protected File |
getExistingFileFromCharSequence(CharSequence cs,
List<String> t)
Try to interpret the value of the CharSequence as an existing
File . |
protected File |
getParentFile(File f)
Get the file's parent directory. |
protected abstract Class<T> |
getTargetType()
Subclasses implement this to return the type that they interpret objects as. |
protected void |
trace(List<String> trace,
String msg)
Log an interpretation decision to the trace (FINEST) level and add it to the interpretation trace list. |
void |
validateResult(ArgumentInterpretationResult<T> result)
This method checks that the result is valid in respect to the values of the ArgumentInterpretationStrategy.ALLOW_NOT_INTERPRETED and
ArgumentInterpretationStrategy.ALLOW_ONE_AND_ONLY_ONE_RESULT_OBJECT
flags used when creating this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.schmant.arg.ArgumentInterpretationStrategy |
---|
interpretList |
Constructor Detail |
---|
protected AbstractArgumentInterpretationStrategy(int[] configuration)
configuration
- Configuration flags. This object understands the
flags ArgumentInterpretationStrategy.ALLOW_NOT_INTERPRETED
and
ArgumentInterpretationStrategy.ALLOW_ONE_AND_ONLY_ONE_RESULT_OBJECT
.Method Detail |
---|
protected static void checkConfiguration(int[] configuration, int[] allowedFlags) throws IllegalArgumentException
configuration
- The configuration flags that it got.allowedFlags
- The configuration flags that it understands.
IllegalArgumentException
- If it got a configuration flag that it
did not understand.protected abstract Class<T> getTargetType()
public void validateResult(ArgumentInterpretationResult<T> result) throws ArgumentInterpretationException
ArgumentInterpretationStrategy.ALLOW_NOT_INTERPRETED
and
ArgumentInterpretationStrategy.ALLOW_ONE_AND_ONLY_ONE_RESULT_OBJECT
flags used when creating this object.
validateResult
in interface ArgumentInterpretationStrategy<T>
result
- The result object.
ArgumentInterpretationException
- If the result is invalid.protected void trace(List<String> trace, String msg)
trace
- A list with trace messages that is built as they are logged.
(The logged message is appended to the list by this method.) The messages
are saved so that they can be included in the
ArgumentInterpretationException
that may be thrown if the
interpretation fails. This argument may be null
.msg
- The message to log and perhaps include in the interpretation
trace list.protected File getParentFile(File f)
f
- The file.
protected String convertBackslashesToSlashes(String s)
s
- The string to convert.
protected File getExistingFileFromCharSequence(CharSequence cs, List<String> t)
CharSequence
as an existing
File
. If the text is the path to a file, that file is returned.
If it is an URI string, the file referenced by that URI is returned.
cs
- The text to interprett
- The interpretation trace list.
null
if the text could not be interpreted as
an existing file.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |