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 Object

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


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

Constructor Detail

AbstractParam

public AbstractParam(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 String getOriginalParam()
Gets the original string param

Returns:
the string

toString

public String toString()

Overrides:
toString in class Object

onError

protected javax.ws.rs.core.Response onError(String strParam,
                                            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 String getErrorMessage(String strParam,
                                 Throwable e)
Gets an error message

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

parse

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

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


Copyright © 2013 Mairie de Paris. All Rights Reserved.