org.restlet.representation.OutputRepresentation Java Examples
The following examples show how to use
org.restlet.representation.OutputRepresentation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntitiesResource.java From attic-polygene-java with Apache License 2.0 | 6 votes |
private Representation representJson() throws ResourceException { try { final Iterable<EntityReference> query = entityFinder.findEntities( EntityComposite.class, null, null, null, null, Collections.emptyMap() ) .collect( toList() ); return new OutputRepresentation( MediaType.APPLICATION_JSON ) { @Override public void write( OutputStream outputStream ) throws IOException { stateSerialization.serialize( new OutputStreamWriter( outputStream ), query ); } }; } catch( Exception e ) { throw new ResourceException( e ); } }
Example #2
Source File: AbstractConverter.java From ontopia with Apache License 2.0 | 5 votes |
@Override public Representation toRepresentation(final Object source, final Variant target, Resource resource) throws IOException { return new OutputRepresentation(target.getMediaType()) { @Override public void write(OutputStream outputStream) throws IOException { CharacterSet characterSet = target.getCharacterSet(); if (characterSet == null) { characterSet = CharacterSet.UTF_8; } writeFragment(outputStream, source, characterSet); } }; }