org.crsh.cli.type
Class ValueType<V>

java.lang.Object
  extended by org.crsh.cli.type.ValueType<V>
Type Parameters:
V - the generic value type

public abstract class ValueType<V>
extends Object

Defines a type for values, this is used for transforming a textual value into a type, for command argument and options. A value type defines:


Field Summary
static ValueType<Boolean> BOOLEAN
          Boolean.
protected  Class<? extends Completer> completer
          .
static ValueType<Enum> ENUM
          Any Java enum.
static ValueType<File> FILE
          A value type for files.
static ValueType<Integer> INTEGER
          Integer.
static ValueType<ObjectName> OBJECT_NAME
          A JMX object name value type.
static ValueType<Properties> PROPERTIES
          Properties as semi colon separated values.
static ValueType<String> STRING
          Identity.
static ValueType<Thread> THREAD
          A value type for threads.
protected  Class<V> type
          .
 
Constructor Summary
protected ValueType(Class<V> type)
           
protected ValueType(Class<V> type, Class<? extends Completer> completer)
           
 
Method Summary
 boolean equals(Object obj)
           
 Class<? extends Completer> getCompleter()
           
(package private)  int getDistance(Class<?> clazz)
           
 Class<V> getType()
           
 int hashCode()
           
abstract
<S extends V>
S
parse(Class<S> type, String s)
          Parse the s argument into a value of type S that is a subclass of the generic value type V.
 V parse(String s)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING

public static final ValueType<String> STRING
Identity.


INTEGER

public static final ValueType<Integer> INTEGER
Integer.


BOOLEAN

public static final ValueType<Boolean> BOOLEAN
Boolean.


ENUM

public static final ValueType<Enum> ENUM
Any Java enum.


PROPERTIES

public static final ValueType<Properties> PROPERTIES
Properties as semi colon separated values.


OBJECT_NAME

public static final ValueType<ObjectName> OBJECT_NAME
A JMX object name value type.


THREAD

public static final ValueType<Thread> THREAD
A value type for threads.


FILE

public static final ValueType<File> FILE
A value type for files.


type

protected final Class<V> type
.


completer

protected final Class<? extends Completer> completer
.

Constructor Detail

ValueType

protected ValueType(Class<V> type,
                    Class<? extends Completer> completer)
             throws NullPointerException
Throws:
NullPointerException

ValueType

protected ValueType(Class<V> type)
             throws NullPointerException
Throws:
NullPointerException
Method Detail

getDistance

final int getDistance(Class<?> clazz)

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

getCompleter

public Class<? extends Completer> getCompleter()

getType

public final Class<V> getType()

parse

public final V parse(String s)
              throws Exception
Throws:
Exception

parse

public abstract <S extends V> S parse(Class<S> type,
                                      String s)
                           throws Exception
Parse the s argument into a value of type S that is a subclass of the generic value type V.

Type Parameters:
S - the generic type of the converted value
Parameters:
type - the target type of the value
s - the string to convert
Returns:
the converted value
Throws:
Exception - any exception that would prevent the conversion to happen


Copyright © 2015 eXo Platform SAS. All Rights Reserved.