fr.paris.lutece.plugins.rest.service.param
Class AbstractParam<V>

java.lang.Object
  extended by fr.paris.lutece.plugins.rest.service.param.AbstractParam<V>
Type Parameters:
V - the real object class

public abstract class AbstractParam<V>
extends java.lang.Object

Provides simple param parsing. Implementations have to override parse(String) to transform the String to a concrete V object.


Constructor Summary
AbstractParam(java.lang.String strParam)
          Builds this param and calls parse(String)
 
Method Summary
protected  java.lang.String getErrorMessage(java.lang.String strParam, java.lang.Throwable e)
          Gets an error message
 java.lang.String getOriginalParam()
          Gets the original string param
 V getValue()
          The value of the string getOriginalParam()
protected  javax.ws.rs.core.Response onError(java.lang.String strParam, java.lang.Throwable e)
          Builds a reponse when an error occurs with Response.Status.BAD_REQUEST as http status.
protected abstract  V parse(java.lang.String strParam)
          Parse the string to its real value
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractParam

public AbstractParam(java.lang.String strParam)
              throws javax.ws.rs.WebApplicationException
Builds this param and calls parse(String)

Parameters:
strParam - the param to parse
Throws:
javax.ws.rs.WebApplicationException - if an exception occured, with preconfigured message getErrorMessage(String, Throwable)
Method Detail

getValue

public V getValue()
The value of the string getOriginalParam()

Returns:
the object value

getOriginalParam

public java.lang.String getOriginalParam()
Gets the original string param

Returns:
the string

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

onError

protected javax.ws.rs.core.Response onError(java.lang.String strParam,
                                            java.lang.Throwable e)
Builds a reponse when an error occurs with Response.Status.BAD_REQUEST as http status.

Parameters:
strParam - the string causing the error
e - the exception
Returns:
th reponse

getErrorMessage

protected java.lang.String getErrorMessage(java.lang.String strParam,
                                           java.lang.Throwable e)
Gets an error message

Parameters:
strParam - string to parse
e - error to handle
Returns:
error message

parse

protected abstract V parse(java.lang.String strParam)
                    throws java.lang.Throwable
Parse the string to its real value

Parameters:
strParam - the string to parse
Returns:
real object value
Throws:
java.lang.Throwable - if occurs


Copyright © 2011 Mairie de Paris. All Rights Reserved.