Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.cli
Class TypeHandler

    java.lang.Object
      org.apache.commons.cli.TypeHandler

    public class TypeHandler

extends 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
`TypeHandler()`

Method Summary
`static Class` | `createClass(String classname)` Returns the class whose name is `classname`.
`static Date` | `createDate(String str)` Returns the date represented by `str`.
`static File` | `createFile(String str)` Returns the File represented by `str`.
`static File[]` | `createFiles(String str)` Returns the File[] represented by `str`.
`static Number` | `createNumber(String str)` Create a number from a String.
`static Object` | `createObject(String classname)` Create an Object from the classname and empty constructor.
`static URL` | `createURL(String str)` Returns the URL represented by `str`.
`static Object` | `createValue(String str, Class clazz)` Returns the `Object` of type `clazz` with the value of `str`.
`static Object` | `createValue(String str, Object obj)` Returns the `Object` of type `obj` with the value of `str`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TypeHandler

    public TypeHandler()

Method Detail

### createValue

    public static Object createValue(String str,
                                     Object obj)
                              throws ParseException

  Returns the `Object` of type `obj` with the value of `str`.

  Parameters:
    `str` - the command line value
    `obj` - the type of argument
  Returns:
    The instance of `obj` initialised with the value of `str`.
  Throws:
    `ParseException`

### createValue

    public static Object createValue(String str,
                                     Class clazz)
                              throws ParseException

  Returns the `Object` of type `clazz` with the value of `str`.

  Parameters:
    `str` - the command line value
    `clazz` - the type of argument
  Returns:
    The instance of `clazz` initialised with the value of `str`.
  Throws:
    `ParseException`

### createObject

    public static Object createObject(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 Number createNumber(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`, if `str` is not a number, null is returned.
  Throws:
    `ParseException`

### createClass

    public static Class createClass(String classname)
                             throws ParseException

  Returns the class whose name is `classname`.

  Parameters:
    `classname` - the class name
  Returns:
    The class if it is found, otherwise return null
  Throws:
    `ParseException`

### createDate

    public static Date createDate(String str)
                           throws ParseException

  Returns the date represented by `str`.

  Parameters:
    `str` - the date string
  Returns:
    The date if `str` is a valid date string, otherwise return null.
  Throws:
    `ParseException`

### createURL

    public static URL createURL(String str)
                         throws ParseException

  Returns the URL represented by `str`.

  Parameters:
    `str` - the URL string
  Returns:
    The URL is `str` is well-formed, otherwise return null.
  Throws:
    `ParseException`

### createFile

    public static File createFile(String str)
                           throws ParseException

  Returns the File represented by `str`.

  Parameters:
    `str` - the File location
  Returns:
    The file represented by `str`.
  Throws:
    `ParseException`

### createFiles

    public static File[] createFiles(String str)
                              throws ParseException

  Returns the File[] represented by `str`.

  Parameters:
    `str` - the paths to the files
  Returns:
    The File[] represented by `str`.
  Throws:
    `ParseException`

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2009 The Apache Software Foundation. All Rights Reserved.