本文整理汇总了Java中org.restlet.representation.OutputRepresentation类的典型用法代码示例。如果您正苦于以下问题:Java OutputRepresentation类的具体用法?Java OutputRepresentation怎么用?Java OutputRepresentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OutputRepresentation类属于org.restlet.representation包,在下文中一共展示了OutputRepresentation类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: representJson
import org.restlet.representation.OutputRepresentation; //导入依赖的package包/类
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 );
}
}
示例2: toRepresentation
import org.restlet.representation.OutputRepresentation; //导入依赖的package包/类
@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);
}
};
}
示例3: convert
import org.restlet.representation.OutputRepresentation; //导入依赖的package包/类
public Representation convert(final LobHandler handler, final CcLob data) throws Exception {
if (data.getValue() == null) {
return new EmptyRepresentation();
}
switch (handler.getMdColumn().getType()) {
case BLOB:
return new OutputRepresentation(handler.getMediaType()) {
@Override
public void write(OutputStream out) throws IOException {
out.write(data.getValue());
}
};
case CLOB:
return new StringRepresentation(new String(data.getValue()), handler.getMediaType());
default:
throw new ClientErrorException(Status.CLIENT_ERROR_BAD_REQUEST);
}
}