TypeHandler
Date: 2017-04-22

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.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TypeHandler()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.Class<?>` | `createClass(java.lang.String classname)` Returns the class whose name is `classname`.
    `static java.util.Date` | `createDate(java.lang.String str)` Returns the date represented by `str`.
    `static java.io.File` | `createFile(java.lang.String str)` Returns the File represented by `str`.
    `static java.io.File[]` | `createFiles(java.lang.String str)` Returns the File[] represented by `str`.
    `static java.lang.Number` | `createNumber(java.lang.String str)` Create a number from a String.
    `static java.lang.Object` | `createObject(java.lang.String classname)` Create an Object from the classname and empty constructor.
    `static java.net.URL` | `createURL(java.lang.String str)` Returns the URL represented by `str`.
    `static java.lang.Object` | `createValue(java.lang.String str, java.lang.Class<?> clazz)` Returns the `Object` of type `clazz` with the value of `str`.
    `static java.lang.Object` | `createValue(java.lang.String str, java.lang.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 java.lang.Object createValue(java.lang.String str,
                                     java.lang.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` - if the value creation for the given object type failed

    - #### createValue

          public static java.lang.Object createValue(java.lang.String str,
                                     java.lang.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` - if the value creation for the given class failed

    - #### 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
      Throws:
        `ParseException` - if the class could not be found or the object could not be created

    - #### 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`
      Throws:
        `ParseException` - if `str` is not a number

    - #### createClass

          public static java.lang.Class<?> createClass(java.lang.String classname)
                                                throws ParseException

      Returns the class whose name is `classname`.
      Parameters:
        `classname` - the class name
      Returns:
        The class if it is found
      Throws:
        `ParseException` - if the class could not be found

    - #### createDate

          public static java.util.Date createDate(java.lang.String str)

      Returns the date represented by `str`.

      This method is not yet implemented and always throws an `UnsupportedOperationException`.

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

    - #### createURL

          public static java.net.URL createURL(java.lang.String str)
                                        throws ParseException

      Returns the URL represented by `str`.
      Parameters:
        `str` - the URL string
      Returns:
        The URL in `str` is well-formed
      Throws:
        `ParseException` - if the URL in `str` is not well-formed

    - #### createFile

          public static java.io.File createFile(java.lang.String str)

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

    - #### createFiles

          public static java.io.File[] createFiles(java.lang.String str)

      Returns the File[] represented by `str`.

      This method is not yet implemented and always throws an `UnsupportedOperationException`.

      Parameters:
        `str` - the paths to the files
      Returns:
        The File[] represented by `str`.
      Throws:
        `java.lang.UnsupportedOperationException` - always