/** * Returns the application's converter service or create a new one. * * @return The converter service. */ public org.restlet.service.ConverterService getConverterService() { org.restlet.service.ConverterService result = null; result = getApplication().getConverterService(); if (result == null) { result = new org.restlet.service.ConverterService(); } return result; }
/** * Constructor. */ public ConverterProvider() { Application application = Application.getCurrent(); if (application != null) { this.converterService = application.getConverterService(); } if (this.converterService == null) { this.converterService = new ConverterService(); } }
/** * Returns the converter service. * * @return The converter service. * @deprecated Since 1.1, the ConverterService is deprecated, with no * replacement as it doesn't fit well with content negotiation. * Most users prefer to handle those conversion in Resource * subclasses. */ @Deprecated private org.restlet.service.ConverterService getConverterService() { org.restlet.service.ConverterService result = null; final Application application = Application.getCurrent(); if (application != null) { result = application.getConverterService(); } else { result = new org.restlet.service.ConverterService(); } return result; }
private String getRepresentationAsText(Object value) { Class<? extends Object> clazz = value.getClass(); boolean isPrimitiveOrWrapped = clazz.isPrimitive() || ClassUtils.wrapperToPrimitive(clazz) != null; if (isPrimitiveOrWrapped || clazz == String.class) { return String.valueOf(value); } String representationAsText = null; try { Representation representation = clientResource.getApplication() .getConverterService().toRepresentation(value); representationAsText = representation.getText(); } catch (IOException e) { throw new WebApplicationException(e); } return representationAsText; }
try { response.setEntity(application.getConverterService().toRepresentation(items, variant, null)); } catch (IOException e) { throw new ServerException(e.getMessage());
if (getConverterService() != null) { getConverterService().start();
if (getConverterService() != null) { getConverterService().stop();