joperties.interpreters
Class CollectionInterpreter<T>

java.lang.Object
  extended by joperties.interpreters.AbstractInterpreter<java.util.Collection<T>>
      extended by joperties.interpreters.CollectionInterpreter<T>

public class CollectionInterpreter<T>
extends AbstractInterpreter<java.util.Collection<T>>

This is a Collection Interpreter which is a special kind of interpreter since it is generic. Generic interpreters cannot be registered since the type of their collection contents are erased at runtime. Therefore these interpreters must be called manually.

Author:
Savvas Dalkitsis

Field Summary
private  java.lang.Class<T> classInCollection
          This serves as a place holder for the type T so that it's possible to return a class of type Class at runtime.
private  java.lang.String COLLECTION_SEPERATOR
           
private  java.util.Collection<T> internal
          This serves as a place holder for the type T so that it's possible to return a class of type Class> at runtime.
 
Constructor Summary
CollectionInterpreter(java.lang.Class<T> classInCollection)
          This constructor takes a class as a parameter to act as a place holder for the type T so that it's possible to return a class of type Class at runtime.
 
Method Summary
 java.lang.String encode(java.util.Collection<T> obj)
          This method encodes the provided object to a string.
 java.lang.Class<java.util.Collection<T>> getClassType()
          This method returns the class that this interpreted handles.
 java.lang.String getCollectionSeperator()
          This method returns the String used as the separator for items in a collection.
 java.lang.String getDescription()
          This method returns a description of the way this interpreter interprets and encodes the objects.
 java.util.Collection<T> interpret(java.lang.String string)
          This method will interpret the provided string as an object.
 void setCollectionSeperator(java.lang.String seperator)
          This method sets the String used as the separator for items in a collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLLECTION_SEPERATOR

private java.lang.String COLLECTION_SEPERATOR

internal

private java.util.Collection<T> internal
This serves as a place holder for the type T so that it's possible to return a class of type Class> at runtime.


classInCollection

private java.lang.Class<T> classInCollection
This serves as a place holder for the type T so that it's possible to return a class of type Class at runtime.

Constructor Detail

CollectionInterpreter

public CollectionInterpreter(java.lang.Class<T> classInCollection)
This constructor takes a class as a parameter to act as a place holder for the type T so that it's possible to return a class of type Class at runtime.

Parameters:
classInCollection - The class of the objects that are placed in the collection.
Method Detail

encode

public java.lang.String encode(java.util.Collection<T> obj)
                        throws EncodingException,
                               NoApropriateInterpeterFoundException
Description copied from class: AbstractInterpreter
This method encodes the provided object to a string.

Specified by:
encode in class AbstractInterpreter<java.util.Collection<T>>
Parameters:
obj - The object to encode as a string.
Returns:
The encoded string which corresponds to the provided object.
Throws:
EncodingException - If there was an error encoding the string.
NoApropriateInterpeterFoundException - If the method needs to call on other interpreters and none is found.

getClassType

public java.lang.Class<java.util.Collection<T>> getClassType()
Description copied from class: AbstractInterpreter
This method returns the class that this interpreted handles.

Specified by:
getClassType in class AbstractInterpreter<java.util.Collection<T>>
Returns:
The class that this interpreted handles.

getDescription

public java.lang.String getDescription()
Description copied from class: AbstractInterpreter
This method returns a description of the way this interpreter interprets and encodes the objects. Used as reference.

Specified by:
getDescription in class AbstractInterpreter<java.util.Collection<T>>
Returns:
A description of the way this interpreter interprets and encodes the objects. Used as reference.

interpret

public java.util.Collection<T> interpret(java.lang.String string)
                                  throws InterpretationException,
                                         NoApropriateInterpeterFoundException
Description copied from class: AbstractInterpreter
This method will interpret the provided string as an object.

Specified by:
interpret in class AbstractInterpreter<java.util.Collection<T>>
Parameters:
string - The string to interpret as an object.
Returns:
An object which corresponds to the provided string.
Throws:
InterpretationException - If there was an error interpreting the string.
NoApropriateInterpeterFoundException - If the method needs to call on other interpreters and none is found.

setCollectionSeperator

public void setCollectionSeperator(java.lang.String seperator)
This method sets the String used as the separator for items in a collection.

Parameters:
seperator - The String used as the separator for items in a collection.

getCollectionSeperator

public java.lang.String getCollectionSeperator()
This method returns the String used as the separator for items in a collection.

Returns:
The String used as the separator for items in a collection.