org.restlet
Class Transformer

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Filter
              extended by org.restlet.Transformer

public class Transformer
extends Filter

Filter that can transform XML representations by applying an XSLT transform sheet. It uses the TransformRepresentation to actually transform the XML entities.

Author:
Jerome Louvel (contact@noelios.com) Noelios Technologies

Field Summary
static int MODE_REQUEST
          Mode that transforms request entities before their handling by the attached Restlet.
static int MODE_RESPONSE
          Mode that transforms response entities after their handling by the attached Restlet.
 
Constructor Summary
Transformer(int mode, Representation transformSheet)
          Constructor.
 
Method Summary
protected  void afterHandle(Request request, Response response)
          Allows filtering after processing by the next Restlet.
protected  void beforeHandle(Request request, Response response)
          Allows filtering before processing by the next Restlet.
 int getMode()
          Returns the transformation mode.
 CharacterSet getResultCharacterSet()
          Returns the character set of the result representation.
 List<Encoding> getResultEncodings()
          Returns the encoding of the result representation.
 List<Language> getResultLanguages()
          Returns the languages of the result representation.
 MediaType getResultMediaType()
          Returns the media type of the result representation.
 Representation getTransformSheet()
          Returns the XSLT transform sheet to apply to message entities.
 void setMode(int mode)
          Sets the transformation mode.
 void setResultCharacterSet(CharacterSet resultCharacterSet)
          Sets the character set of the result representation.
 void setResultMediaType(MediaType resultMediaType)
          Sets the media type of the result representation.
 void setTransformSheet(Representation transformSheet)
          Sets the XSLT transform sheet to apply to message entities.
 Representation transform(Representation source)
          Transforms a source XML representation by applying an XSLT transform sheet to it.
 
Methods inherited from class org.restlet.Filter
doHandle, getNext, handle, hasNext, setNext, setNext
 
Methods inherited from class org.restlet.Restlet
getContext, getLogger, init, isStarted, isStopped, setContext, start, stop
 
Methods inherited from class org.restlet.Uniform
delete, delete, get, get, handle, head, head, options, options, post, post, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_REQUEST

public static final int MODE_REQUEST
Mode that transforms request entities before their handling by the attached Restlet.

See Also:
Constant Field Values

MODE_RESPONSE

public static final int MODE_RESPONSE
Mode that transforms response entities after their handling by the attached Restlet.

See Also:
Constant Field Values
Constructor Detail

Transformer

public Transformer(int mode,
                   Representation transformSheet)
Constructor.

Parameters:
mode - The transformation mode.
transformSheet - The XSLT transform sheet to apply to message entities.
Method Detail

afterHandle

protected void afterHandle(Request request,
                           Response response)
Description copied from class: Filter
Allows filtering after processing by the next Restlet. Does nothing by default.

Overrides:
afterHandle in class Filter
Parameters:
request - The request to handle.
response - The response to update.

beforeHandle

protected void beforeHandle(Request request,
                            Response response)
Description copied from class: Filter
Allows filtering before processing by the next Restlet. Does nothing by default.

Overrides:
beforeHandle in class Filter
Parameters:
request - The request to handle.
response - The response to update.

getMode

public int getMode()
Returns the transformation mode. See MODE_* constants.

Returns:
The transformation mode.

getResultCharacterSet

public CharacterSet getResultCharacterSet()
Returns the character set of the result representation. The default value is null.

Returns:
The character set of the result representation.

getResultEncodings

public List<Encoding> getResultEncodings()
Returns the encoding of the result representation. The default value is null.

Returns:
The encoding of the result representation.

getResultLanguages

public List<Language> getResultLanguages()
Returns the languages of the result representation.

Returns:
The language of the result representation.

getResultMediaType

public MediaType getResultMediaType()
Returns the media type of the result representation. The default value is MediaType.APPLICATION_XML.

Returns:
The media type of the result representation.

getTransformSheet

public Representation getTransformSheet()
Returns the XSLT transform sheet to apply to message entities.

Returns:
The XSLT transform sheet to apply to message entities.

setMode

public void setMode(int mode)
Sets the transformation mode. See MODE_* constants.

Parameters:
mode - The transformation mode.

setResultCharacterSet

public void setResultCharacterSet(CharacterSet resultCharacterSet)
Sets the character set of the result representation.

Parameters:
resultCharacterSet - The character set of the result representation.

setResultMediaType

public void setResultMediaType(MediaType resultMediaType)
Sets the media type of the result representation.

Parameters:
resultMediaType - The media type of the result representation.

setTransformSheet

public void setTransformSheet(Representation transformSheet)
Sets the XSLT transform sheet to apply to message entities.

Parameters:
transformSheet - The XSLT transform sheet to apply to message entities.

transform

public Representation transform(Representation source)
Transforms a source XML representation by applying an XSLT transform sheet to it.

Parameters:
source - The source XML representation.
Returns:
The generated result representation.


Copyright © 2005-2007 Noelios Technologies.