|
Restlet Framework 2.2.1 OSGi Environments |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.service.Service
org.restlet.service.ConverterService
public class ConverterService
Application service converting between representation and regular Java
objects. The conversion can work in both directions. Actual converters can be
plugged into the engine to support this service.
Root object classes used for conversion shouldn't be generic classes
otherwise important contextual type information will be missing at runtime
due to Java type erasure mechanism. If needed, create a fully resolved
subclasses and/or a container classes.
Constructor Summary | |
---|---|
ConverterService()
Constructor. |
|
ConverterService(boolean enabled)
Constructor. |
Method Summary | ||
---|---|---|
Representation |
applyPatch(Representation initial,
Representation patch)
Applies a patch representation to an initial representation in order to obtain a modified one. |
|
Representation |
createPatch(Representation initial,
Representation modified)
Creates a patch representation by calculating a diff between initial and modified representations. |
|
List<Class<?>> |
getObjectClasses(Variant source)
Returns the list of object classes that can be converted from a given variant. |
|
List<MediaType> |
getPatchTypes(MediaType representationType)
Returns the list of patch media types available for the given representation types. |
|
List<? extends Variant> |
getVariants(Class<?> source,
Variant target)
Returns the list of variants that can be converted from a given object class. |
|
Representation |
revertPatch(Representation modified,
Representation patch)
Reverts a patch representation from a modified representation in order to obtain the initial one. |
|
Object |
toObject(Representation source)
Converts a Representation into a regular Java object. |
|
|
toObject(Representation source,
Class<T> target,
Resource resource)
Converts a Representation into a regular Java object. |
|
Representation |
toRepresentation(Object source)
Converts a regular Java object into a Representation. |
|
Representation |
toRepresentation(Object source,
Variant target,
Resource resource)
Converts a regular Java object into a Representation. |
|
void |
updatePreferences(List<Preference<MediaType>> preferences,
Class<?> entity)
Updates the media type preferences with available conversion capabilities for the given entity class. |
Methods inherited from class org.restlet.service.Service |
---|
createInboundFilter, createOutboundFilter, getContext, isEnabled, isStarted, isStopped, setContext, setEnabled, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConverterService()
public ConverterService(boolean enabled)
enabled
- True if the service has been enabled.Method Detail |
---|
public Representation applyPatch(Representation initial, Representation patch) throws IOException
ConverterService
to be able to process it.
initial
- The initial representation on which the patch must be applied.patch
- The patch representation to apply.
IOException
public Representation createPatch(Representation initial, Representation modified) throws IOException
initial
- The initial representation.modified
- The modified representation.
IOException
public List<Class<?>> getObjectClasses(Variant source)
source
- The source variant.
public List<MediaType> getPatchTypes(MediaType representationType)
representationType
- The representation media type or null for all supported patch
types.
public List<? extends Variant> getVariants(Class<?> source, Variant target) throws IOException
source
- The source class.target
- The expected representation metadata.
IOException
public Representation revertPatch(Representation modified, Representation patch) throws IOException
ConverterService
to be able to process it.
modified
- The modified representation from which the patch must be
reverted.patch
- The patch representation to revert.
IOException
public Object toObject(Representation source) throws IOException
source
- The source representation to convert.
IOException
public <T> T toObject(Representation source, Class<T> target, Resource resource) throws IOException
T
- The expected class of the Java object.source
- The source representation to convert.target
- The target class of the Java object.resource
- The parent resource.
IOException
public Representation toRepresentation(Object source) throws IOException
source
- The source object to convert.
IOException
public Representation toRepresentation(Object source, Variant target, Resource resource) throws IOException
source
- The source object to convert.target
- The target representation variant.resource
- The parent resource.
IOException
public void updatePreferences(List<Preference<MediaType>> preferences, Class<?> entity)
preferences
- The media type preferences.entity
- The entity class to convert.
|
Restlet Framework 2.2.1 OSGi Environments |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |