当前位置: 首页>>代码示例>>Java>>正文


Java OutputRepresentation类代码示例

本文整理汇总了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 );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:23,代码来源:EntitiesResource.java

示例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);
		}
	};
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:14,代码来源:AbstractConverter.java

示例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);
            
    }
    
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:29,代码来源:LobConverter.java


注:本文中的org.restlet.representation.OutputRepresentation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。