joperties.interpreters
Class Interpreters

java.lang.Object
  extended by joperties.interpreters.Interpreters

public class Interpreters
extends java.lang.Object

Class which holds the registered Interpreters and provides methods for accessing them.

Author:
Savvas Dalkitsis

Field Summary
private static java.util.Map<java.lang.Class<?>,AbstractInterpreter<?>> interpreters
          The map which holds the interpreters based on the class they interpret.
 
Constructor Summary
Interpreters()
           
 
Method Summary
static
<T> AbstractInterpreter<T>
getInterpreter(java.lang.Class<T> classToInterpret)
          This method will return a registered interpreter which interprets the provided class (if found).
static java.util.Collection<AbstractInterpreter<?>> getInterpreters()
          This method returns a collection (LinkedList internally) which contains all the registered interpreters.
static java.util.List<java.lang.Class<?>> getSupportedClasses()
          This method returns a list of classes that the registered interpreters interpret.
static java.util.List<java.lang.String> getSupportedClassesNames()
          This method returns a list of the names of the classes that the registered interpreters interpret.
static boolean isClassSupported(java.lang.Class<?> classToInterpret)
          This method returns true if the provided class is supported by one of the registered interpreters.
static boolean registerInterpreter(AbstractInterpreter<?> interpreter)
          This method registers an interpreter replacing any old one that interprets the same class.
static boolean registerInterpreter(AbstractInterpreter<?> interpreter, boolean replace)
          This method registers an interpreter based on the class that it interprets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interpreters

private static java.util.Map<java.lang.Class<?>,AbstractInterpreter<?>> interpreters
The map which holds the interpreters based on the class they interpret.

Constructor Detail

Interpreters

public Interpreters()
Method Detail

registerInterpreter

public static boolean registerInterpreter(AbstractInterpreter<?> interpreter,
                                          boolean replace)
This method registers an interpreter based on the class that it interprets. If the provided boolean is true and an existing interpreter already interprets the class of the provided interpreter, then this method will replace the old one with the new.

Parameters:
interpreter - The interpreter to register.
replace - If this is true then any old interpreter which interprets the same class will be replaced.
Returns:
True if the interpreter was registered.

registerInterpreter

public static boolean registerInterpreter(AbstractInterpreter<?> interpreter)
This method registers an interpreter replacing any old one that interprets the same class.

Parameters:
interpreter - The interpreter to register.
Returns:
True if the interpreter was registered.

getInterpreters

public static java.util.Collection<AbstractInterpreter<?>> getInterpreters()
This method returns a collection (LinkedList internally) which contains all the registered interpreters.

Returns:
A collection (LinkedList internally) which contains all the registered interpreters.

getInterpreter

public static <T> AbstractInterpreter<T> getInterpreter(java.lang.Class<T> classToInterpret)
                                             throws NoApropriateInterpeterFoundException
This method will return a registered interpreter which interprets the provided class (if found).

Type Parameters:
T - The Type of the class that the returned interpreter will interpret.
Parameters:
classToInterpret - The class that the returned interpreter will interpret.
Returns:
A registered interpreter which interprets the provided class (if found).
Throws:
NoApropriateInterpeterFoundException - If no interpreter is registered for the provided class.

getSupportedClasses

public static java.util.List<java.lang.Class<?>> getSupportedClasses()
This method returns a list of classes that the registered interpreters interpret.

Returns:
A list of classes that the registered interpreters interpret.

getSupportedClassesNames

public static java.util.List<java.lang.String> getSupportedClassesNames()
This method returns a list of the names of the classes that the registered interpreters interpret.

Returns:
A list of the names of the classes that the registered interpreters interpret.

isClassSupported

public static boolean isClassSupported(java.lang.Class<?> classToInterpret)
This method returns true if the provided class is supported by one of the registered interpreters.

Parameters:
classToInterpret - The class to determine if it is supported.
Returns:
True if the provided class is supported by one of the registered interpreters.