antlraux package
v0.2.1

antlraux.clparse
Class TypeDealer

java.lang.Object
  |
  +--antlraux.clparse.TypeDealer

public class TypeDealer
extends java.lang.Object

Conversion between Strings and java basic types is necessary along all the parsing. This static class encapsulated all the functionallity needed for doing that.

We will say that a char is valid if it represents one of the types supported by the parser. Otherwise it will be not valid.

Valid type chars are:

Strings, integers, chars and floats are directly obtained from the command line. In order to specify a boolean value the user has to write 'false' or 'true' in the command line.

Author:
Enrique José García Cota

Constructor Summary
TypeDealer()
           
 
Method Summary
static void checkCharType(char type)
          Checks if a char is valid.
static void checkStringTypes(java.lang.String paramTypes)
          Checks if a string contains only valid chars.
protected static java.lang.String getStringOfTypes(java.lang.String types, boolean commas)
          Returns a string containing the names of the classes associated to a specification string.
protected static java.lang.Class getTypeFromChar(char type)
          Given a valid class specification, it returns its class.
protected static java.lang.Class[] getTypesFromString(java.lang.String types)
          Given a String of specification, it returns its table of types associated.
static java.lang.Object objectFromString(java.lang.String source, char type)
          Tries to parse an object of the specified type from a specified String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeDealer

public TypeDealer()
Method Detail

checkStringTypes

public static void checkStringTypes(java.lang.String paramTypes)
                             throws CommandLineParserException
Checks if a string contains only valid chars.

Parameters:
paramTypes - The string to check.
Throws:
CommandLineParserException - If the string contains one not valid char at least.

checkCharType

public static void checkCharType(char type)
                          throws CommandLineParserException
Checks if a char is valid.

Parameters:
type - The char to check.
Throws:
CommandLineParserException - If type is not valid.

objectFromString

public static java.lang.Object objectFromString(java.lang.String source,
                                                char type)
                                         throws CommandLineParserException
Tries to parse an object of the specified type from a specified String.

Parameters:
source - The string to parse.
type - The type of the object that we want to parse.
Throws:
CommandLineParserException - If the parsing could not be done.

getTypeFromChar

protected static java.lang.Class getTypeFromChar(char type)
                                          throws CommandLineParserException
Given a valid class specification, it returns its class.

Returns:
The class needed.
Throws:
CommandLineParserException - If type is not valid.

getTypesFromString

protected static java.lang.Class[] getTypesFromString(java.lang.String types)
                                               throws CommandLineParserException
Given a String of specification, it returns its table of types associated.

Parameters:
types - The type specification String.
Throws:
CommandLineParserException - If types contains one not valid char.

getStringOfTypes

protected static java.lang.String getStringOfTypes(java.lang.String types,
                                                   boolean commas)
                                            throws CommandLineParserException
Returns a string containing the names of the classes associated to a specification string.

Parameters:
types - The string to check.
commas - If true, the names are separated by commas and spaces. Otherwise they are only separated by spaces.
Throws:
CommandLineParserException - If types contains one not valid char at least.

antlraux package
v0.2.1

Created by Enrique José García Cota