• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Resource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.restlet.resource.Resource的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Resource类属于org.restlet.resource包,在下文中一共展示了Resource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public float score(Object source, Variant target, Resource resource) {
    float result = -1.0F;

    if (source instanceof Document) {
        if (target == null) {
            result = 0.5F;
        } else if (MediaType.APPLICATION_ALL_XML.isCompatible(target
                .getMediaType())) {
            result = 0.8F;
        } else if (MediaType.APPLICATION_XML.isCompatible(target
                .getMediaType())) {
            result = 0.9F;
        } else if (MediaType.TEXT_XML.isCompatible(target.getMediaType())) {
            result = 0.9F;
        } else {
            result = 0.5F;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:23,代码来源:XmlConverter.java


示例2: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public float score(Object source, Variant target, Resource resource) {
    float result = -1.0F;

    if (source != null
            && (source instanceof JaxbRepresentation<?> || isJaxbRootElementClass(source
                    .getClass()))) {
        if (target == null) {
            result = 0.8F;
        } else if (isCompatible(target.getMediaType())) {
            result = 1.0F;
        } else {
            // Allow for JAXB object to be used for JSON and other
            // representations
            result = 0.7F;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:21,代码来源:JaxbConverter.java


示例3: toObject

import org.restlet.resource.Resource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T toObject(Representation source, Class<T> target,
        Resource resource) throws IOException {
    JaxbRepresentation<?> jaxbSource = null;
    if (source instanceof JaxbRepresentation) {
        jaxbSource = (JaxbRepresentation<?>) source;
    } else {
        jaxbSource = new JaxbRepresentation<T>(source, target);
    }

    T result = null;
    if (target == null) {
        result = (T) jaxbSource.getObject();
    } else if (JaxbRepresentation.class.isAssignableFrom(target)) {
        result = target.cast(jaxbSource);
    } else if (isJaxbRootElementClass(target)) {
        result = target.cast(jaxbSource.getObject());
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:23,代码来源:JaxbConverter.java


示例4: toRepresentation

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
        Resource resource) throws IOException {

    if (source instanceof TemplateResolution) {
        Locale locale = getLocale(resource);

        TemplateRepresentation tr = new TemplateRepresentation(
                ((TemplateResolution) source).getTemplateResource().getBaseName(), locale,
                target.getMediaType());
        tr.setDataModel(resource.getRequest(), resource.getResponse());
        return tr;
    }

    return null;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:17,代码来源:ThymeleafConverter.java


示例5: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public float score(Object source, Variant target, Resource resource) {
    float result = -1.0F;

    if (source instanceof GsonRepresentation<?>) {
        result = 1.0F;
    } else {
        if (target == null) {
            result = 0.5F;
        } else if (VARIANT_JSON.isCompatible(target)) {
            result = 0.8F;
        } else {
            result = 0.5F;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:19,代码来源:GsonConverter.java


示例6: toRepresentation

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
        Resource resource) throws IOException {
    Representation result = null;

    if (source instanceof GsonRepresentation) {
        result = (GsonRepresentation<?>) source;
    } else {
        if (target.getMediaType() == null) {
            target.setMediaType(MediaType.APPLICATION_JSON);
        }

        if (VARIANT_JSON.isCompatible(target)) {
            GsonRepresentation<Object> gsonRepresentation = create(source);
            result = gsonRepresentation;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:21,代码来源:GsonConverter.java


示例7: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public float score(Object source, Variant target, Resource resource) {
    float result = -1.0F;

    if (source instanceof JacksonRepresentation<?>) {
        result = 1.0F;
    } else {
        if (target == null) {
            result = 0.5F;
        } else if (isCompatible(target)) {
            result = 0.8F;
        } else {
            result = 0.5F;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:19,代码来源:JacksonConverter.java


示例8: toObject

import org.restlet.resource.Resource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T toObject(Representation source, Class<T> target,
        Resource resource) throws IOException {
    Object result = null;

    // The source for the Jackson conversion
    JacksonRepresentation<?> jacksonSource = null;
    if (source instanceof JacksonRepresentation) {
        jacksonSource = (JacksonRepresentation<?>) source;
    } else if (isCompatible(source)) {
        jacksonSource = create(source, target);
    }

    if (jacksonSource != null) {
        // Handle the conversion
        if ((target != null)
                && JacksonRepresentation.class.isAssignableFrom(target)) {
            result = jacksonSource;
        } else {
            result = jacksonSource.getObject();
        }
    }

    return (T) result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:27,代码来源:JacksonConverter.java


示例9: toRepresentation

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
        Resource resource) {
    Representation result = null;

    if (source instanceof JacksonRepresentation) {
        result = (JacksonRepresentation<?>) source;
    } else {
        if (target.getMediaType() == null) {
            target.setMediaType(MediaType.APPLICATION_JSON);
        }
        if (isCompatible(target)) {
            result = create(target.getMediaType(), source);
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:19,代码来源:JacksonConverter.java


示例10: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public float score(Object source, Variant target, Resource resource) {
    float result = -1.0F;

    if (source instanceof FormDataSet) {
        if (target == null) {
            result = 0.5F;
        } else if (MediaType.APPLICATION_WWW_FORM.isCompatible(target
                .getMediaType())
                || MediaType.MULTIPART_FORM_DATA.isCompatible(target
                        .getMediaType())) {
            result = 1.0F;
        } else {
            result = 0.5F;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:20,代码来源:HtmlConverter.java


示例11: getBestHelper

import org.restlet.resource.Resource; //导入依赖的package包/类
/**
 * Returns the best converter helper matching the given parameters.
 * 
 * @param source
 *            The object to convert to a representation.
 * @param target
 *            The target representation variant.
 * @param resource
 *            The optional parent resource.
 * @return The matched converter helper or null.
 */
public static ConverterHelper getBestHelper(Object source, Variant target,
        Resource resource) {
    ConverterHelper result = null;
    float bestScore = -1.0F;
    float currentScore;

    for (ConverterHelper ch : Engine.getInstance()
            .getRegisteredConverters()) {
        if (ch != null) {
            try {
                currentScore = ch.score(source, target, resource);

                if (currentScore > bestScore) {
                    bestScore = currentScore;
                    result = ch;
                }
            } catch (Exception e) {
                Context.getCurrentLogger().error("Unable get the score of the " + ch
                                + " converter helper.", e);
            }
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:37,代码来源:ConverterUtils.java


示例12: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public <T> float score( Representation source, Class<T> target,
                        Resource resource
)
{
    float result = -1.0F;

    if( source instanceof JsonRepresentation<?> )
    {
        result = 1.0F;
    }
    else if( ( target != null )
             && JsonRepresentation.class.isAssignableFrom( target ) )
    {
        result = 1.0F;
    }
    else if( isCompatible( source ) )
    {
        result = 0.8F;
    }

    return result;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:PolygeneConverter.java


示例13: toRepresentation

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public Representation toRepresentation( Object source, Variant target, Resource resource )
{
    Representation result = null;

    if( source instanceof JsonRepresentation )
    {
        result = (JsonRepresentation<?>) source;
    }
    else
    {
        if( target.getMediaType() == null )
        {
            target.setMediaType( MediaType.APPLICATION_JSON );
        }
        if( isCompatible( target ) )
        {
            result = create( target.getMediaType(), source );
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:PolygeneConverter.java


示例14: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public float score(Object source, Variant target, Resource resource) {
	 float result = -1.0F;

        if (source instanceof XMLRepresentation<?>) {
            result = 1.0F;
        } else {
            if (target == null) {
                result = 0.5F;
            } else if (VARIANT_APPLICATION_ALL_XML.isCompatible(target)
                    || VARIANT_APPLICATION_XML.isCompatible(target)
                    || VARIANT_TEXT_XML.isCompatible(target)) {
                result = 1.0F;
            } else {
                result = 0.5F;
            }
        }

        return result;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:21,代码来源:XMLConverter.java


示例15: toObject

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public <T> T toObject(Representation source, Class<T> target,
		Resource resource) throws IOException {
	 Object result = null;

        // The source for the Jackson conversion
        XMLRepresentation<?> obixSource = null;

        if (source instanceof XMLRepresentation) {
        	obixSource = (XMLRepresentation<?>) source;
        } else if (VARIANT_APPLICATION_ALL_XML.isCompatible(source) || VARIANT_APPLICATION_XML.isCompatible(source) || VARIANT_TEXT_XML.isCompatible(source)) {
        	obixSource = create(source, target, resource);
        }

        if (obixSource != null) {
            // Handle the conversion
            if ((target != null)
                    && XMLRepresentation.class.isAssignableFrom(target)) {
                result = obixSource;
            } else {
                result = obixSource.getObject();
            }
        }

        return (T) result;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:27,代码来源:XMLConverter.java


示例16: toRepresentation

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
public Representation toRepresentation(Object source, Variant target,
		Resource resource) throws IOException {
	Representation result = null;

       if (source instanceof XMLRepresentation) {
           result = (XMLRepresentation<?>) source;
       } else {
           if (target.getMediaType() == null) {
               target.setMediaType(MediaType.APPLICATION_ALL_XML);
           }

           if (VARIANT_APPLICATION_ALL_XML.isCompatible(target) || VARIANT_APPLICATION_XML.isCompatible(target) ||VARIANT_TEXT_XML.isCompatible(target) ) {
           	
           	XMLRepresentation<Object> obixRepresentation = create(
                       target.getMediaType(), source, resource);
               result = obixRepresentation;
           }
       }

       return result;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:23,代码来源:XMLConverter.java


示例17: score

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
   public float score(Object source, Variant target, Resource arg2) {
float result = -1.0F;

if (source instanceof JSonRepresentation<?>) {
    result = 1.0F;
} else {
    if (target == null) {
	result = 0.5F;
    } else if (VARIANT_JSON.isCompatible(target)) {
	result = 1.0F;
    } else {
	result = 0.5F;
    }
}

return result;
   }
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:19,代码来源:JSonConverter.java


示例18: toObject

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
   public <T> T toObject(Representation source, Class<T> target, Resource resource) throws IOException {
Object result = null;

// The source for the Jackson conversion
JSonRepresentation<?> obixSource = null;

if (source instanceof JSonRepresentation) {
    obixSource = (JSonRepresentation<?>) source;
} else if (VARIANT_JSON.isCompatible(source)) {
    obixSource = create(source, target, resource);
}

if (obixSource != null) {
    // Handle the conversion
    if ((target != null) && JSonRepresentation.class.isAssignableFrom(target)) {
	result = obixSource;
    } else {
	result = obixSource.getObject();
    }
}

return (T) result;
   }
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:25,代码来源:JSonConverter.java


示例19: toRepresentation

import org.restlet.resource.Resource; //导入依赖的package包/类
@Override
   public Representation toRepresentation(Object source, Variant target, Resource resource) throws IOException {
Representation result = null;

if (source instanceof JSonRepresentation) {
    result = (JSonRepresentation<?>) source;
} else {
    if (target.getMediaType() == null) {
	target.setMediaType(MediaType.APPLICATION_JSON);
    }

    if (VARIANT_JSON.isCompatible(target)) {

	JSonRepresentation<Object> obixRepresentation = create(target.getMediaType(), source, resource);
	result = obixRepresentation;
    }
}

return result;
   }
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:21,代码来源:JSonConverter.java


示例20: findTarget

import org.restlet.resource.Resource; //导入依赖的package包/类
public Resource findTarget(Request request, Response response) {
	String workspaceName = (String) request.getAttributes().get("workspace");
	
	if (workspaceName != null && request.getMethod() == Method.GET) {
		return new WorkspaceContentsResource(getContext(), request, response, this.catalog);
	}
	
	throw new RestletException("No such workspace: " + workspaceName, Status.CLIENT_ERROR_NOT_FOUND);
}
 
开发者ID:geops,项目名称:geoserver-documentor,代码行数:10,代码来源:WorkspaceContentsFinder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DSADigestSigner类代码示例发布时间:2022-05-22
下一篇:
Java BlockGrass类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap