Package org.apache.commons.cli
Class TypeHandler
- java.lang.Object
-
- org.apache.commons.cli.TypeHandler
-
public class TypeHandler extends java.lang.Object
This is a temporary implementation. TypeHandler will handle the pluggableness of OptionTypes and it will direct all of these types of conversion functionalities to ConvertUtils component in Commons already. BeanUtils I think.- Version:
- $Revision: 741425 $, $Date: 2009-02-05 22:10:54 -0800 (Thu, 05 Feb 2009) $
-
-
Constructor Summary
Constructors Constructor Description TypeHandler()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ClasscreateClass(java.lang.String classname)Returns the class whose name isclassname.static java.util.DatecreateDate(java.lang.String str)Returns the date represented bystr.static java.io.FilecreateFile(java.lang.String str)Returns the File represented bystr.static java.io.File[]createFiles(java.lang.String str)Returns the File[] represented bystr.static java.lang.NumbercreateNumber(java.lang.String str)Create a number from a String.static java.lang.ObjectcreateObject(java.lang.String classname)Create an Object from the classname and empty constructor.static java.net.URLcreateURL(java.lang.String str)Returns the URL represented bystr.static java.lang.ObjectcreateValue(java.lang.String str, java.lang.Class clazz)Returns theObjectof typeclazzwith the value ofstr.static java.lang.ObjectcreateValue(java.lang.String str, java.lang.Object obj)Returns theObjectof typeobjwith the value ofstr.
-
-
-
Constructor Detail
-
TypeHandler
public TypeHandler()
-
-
Method Detail
-
createValue
public static java.lang.Object createValue(java.lang.String str, java.lang.Object obj) throws ParseException
Returns theObjectof typeobjwith the value ofstr.- Parameters:
str- the command line valueobj- the type of argument- Returns:
- The instance of
objinitialised with the value ofstr. - Throws:
ParseException
-
createValue
public static java.lang.Object createValue(java.lang.String str, java.lang.Class clazz) throws ParseException
Returns theObjectof typeclazzwith the value ofstr.- Parameters:
str- the command line valueclazz- the type of argument- Returns:
- The instance of
clazzinitialised with the value ofstr. - Throws:
ParseException
-
createObject
public static java.lang.Object createObject(java.lang.String classname) throws ParseException
Create an Object from the classname and empty constructor.- Parameters:
classname- the argument value- Returns:
- the initialised object, or null if it couldn't create the Object.
- Throws:
ParseException
-
createNumber
public static java.lang.Number createNumber(java.lang.String str) throws ParseException
Create a number from a String. If a . is present, it creates a Double, otherwise a Long.- Parameters:
str- the value- Returns:
- the number represented by
str, ifstris not a number, null is returned. - Throws:
ParseException
-
createClass
public static java.lang.Class createClass(java.lang.String classname) throws ParseException
Returns the class whose name isclassname.- Parameters:
classname- the class name- Returns:
- The class if it is found, otherwise return null
- Throws:
ParseException
-
createDate
public static java.util.Date createDate(java.lang.String str) throws ParseException
Returns the date represented bystr.- Parameters:
str- the date string- Returns:
- The date if
stris a valid date string, otherwise return null. - Throws:
ParseException
-
createURL
public static java.net.URL createURL(java.lang.String str) throws ParseException
Returns the URL represented bystr.- Parameters:
str- the URL string- Returns:
- The URL is
stris well-formed, otherwise return null. - Throws:
ParseException
-
createFile
public static java.io.File createFile(java.lang.String str) throws ParseException
Returns the File represented bystr.- Parameters:
str- the File location- Returns:
- The file represented by
str. - Throws:
ParseException
-
createFiles
public static java.io.File[] createFiles(java.lang.String str) throws ParseException
Returns the File[] represented bystr.- Parameters:
str- the paths to the files- Returns:
- The File[] represented by
str. - Throws:
ParseException
-
-