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

Java FilterProvider类代码示例

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

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



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

示例1: jsonToStringIgnoreSpecialFields

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
/**
 * jsonToString exclude null data end edit fields
 *
 * @param model - model data to String
 * @return - model data with json format
 */
public static String jsonToStringIgnoreSpecialFields(RestModel model) {
    String[] ExcludedFieldsFromView = getExcludedFields(model);
    ObjectMapper specialMapper = new ObjectMapper();
    specialMapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
    String data = null;
    FilterProvider filters = new SimpleFilterProvider()
            .addFilter("exclude fields",
                    SimpleBeanPropertyFilter.serializeAllExcept(
                            (ExcludedFieldsFromView)));
    ObjectWriter writer = specialMapper.writer(filters);
    try {
        data = writer.writeValueAsString(model);
    } catch (IOException e) {
        log.debug(e.getMessage());
    }
    return data;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:24,代码来源:JsonUtil.java


示例2: testSerializeComment

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
@Test
public void testSerializeComment() throws IOException
{
    final Comment aComment = new Comment();
    aComment.setContent("<b>There it is</b>");
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    jsonHelper.withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {
            FilterProvider fp = new SimpleFilterProvider().addFilter(
                        JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
            objectMapper.writer(fp).writeValue(generator, aComment);
        }
    });
    assertTrue(out.toString().contains("{\"content\":\"<b>There it is</b>\""));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:JsonJacksonTests.java


示例3: testNullInComment

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
@Test
public void testNullInComment() throws IOException
{
    final Comment aComment = new Comment();
    aComment.setContent(null);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    jsonHelper.withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {
            FilterProvider fp = new SimpleFilterProvider().addFilter(
                        JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
            objectMapper.writer(fp).writeValue(generator, aComment);
        }
    });
    assertEquals("Null values should not be output.", "{\"canEdit\":false,\"canDelete\":false}",
                out.toString());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:22,代码来源:JsonJacksonTests.java


示例4: getInclusiveObjectWriter

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
/**
 * Get an inclusive jackson object writer for writing a set of named fields of an object
 * 
 * @param includeFieldNames fields that should be serialized	
 * @param filterName filter name. This needs to match the @JsonFilter("filterName") annotation for a bean
 * 
 * @return a Jackson ObjectWriter
 * @throws Exception
 */
public static ObjectWriter getInclusiveObjectWriter(String[] includeFieldNames, String filterName) 
throws Exception {
	
	if (includeFieldNames == null)
		throw new Exception("includeFieldNames can't be null");
	
	if (filterName == null)
		throw new Exception("filterName can't be null");
	
	ObjectMapper mapper = new ObjectMapper();  
    FilterProvider filters = new SimpleFilterProvider()  
      .addFilter(filterName,   
          SimpleBeanPropertyFilter.filterOutAllExcept(includeFieldNames));  
    return mapper.writer(filters);  
	
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:26,代码来源:ViewFilterUtil.java


示例5: getExclusivObjectWriter

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
/**
 * Get an exclusive jackson object writer for serializing an object without a set of named fields
 * 
 * @param excludeFieldNames fields that should be excluded for serialization
 * @param filterName filter name. This needs to match the @JsonFilter("filterName") annotation for a bean
 * 
 * @return a Jackson ObjectWriter
 * @throws Exception
 */
public static ObjectWriter getExclusivObjectWriter(String[] excludeFieldNames, String filterName) 
		throws Exception {
	if (excludeFieldNames == null)
		throw new Exception("includeFieldNames can't be null");
	
	if (filterName == null)
		throw new Exception("filterName can't be null");
	
	ObjectMapper mapper = new ObjectMapper();  
    FilterProvider filters = new SimpleFilterProvider()  
      .addFilter(filterName,   
          SimpleBeanPropertyFilter.serializeAllExcept(excludeFieldNames));  
    return mapper.writer(filters);  
	
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:25,代码来源:ViewFilterUtil.java


示例6: serialize

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
/**
 * Serialize to a JSON representation using 
 * {@link ObjectMapper#writeValue(java.io.Writer, Object)}
 * 
 * @return a JSON representation
 * @throws IOException
 */
public String serialize() throws IOException
{
  ObjectMapper mapper = new ObjectMapper();
  FilterProvider filters = new SimpleFilterProvider().addFilter(
      "savedForm1Properties",
      SimpleBeanPropertyFilter.filterOutAllExcept(
          "plates",
          "assayPlateSize",
          "outputFileName",
          "outputFormat",
          "assayPositiveControls",
          "assayNegativeControls",
          "assayOtherControls",
          "libraryControls"));
  return mapper.writer(filters).writeValueAsString(this);
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:24,代码来源:PlateReaderRawDataTransformer.java


示例7: testSerializeMultipleObjects

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
@Test
public void testSerializeMultipleObjects() throws IOException
{
    final Collection<Comment> allComments = new ArrayList<Comment>();
    Comment aComment = new Comment();
    aComment.setContent("<b>There it is</b>");
    allComments.add(aComment);
    aComment = new Comment();
    aComment.setContent("<p>I agree with the author</p>");
    allComments.add(aComment);

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    jsonHelper.withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {
            FilterProvider fp = new SimpleFilterProvider().addFilter(
                        JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
            objectMapper.writer(fp).writeValue(generator, allComments);
        }
    });
    assertTrue(out.toString().contains("content\":\"<b>There it is</b>"));
    assertTrue(out.toString().contains("content\":\"<p>I agree with the author</p>"));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:28,代码来源:JsonJacksonTests.java


示例8: findFilter

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
/**
 * Helper method used to locate filter that is needed, based on filter id
 * this serializer was constructed with.
 * 
 * @since 1.7
 */
protected BeanPropertyFilter findFilter(SerializerProvider provider)
    throws JsonMappingException
{
    final Object filterId = _propertyFilterId;
    FilterProvider filters = provider.getFilterProvider();
    // Not ok to miss the provider, if a filter is declared to be needed.
    if (filters == null) {
        throw new JsonMappingException("Can not resolve BeanPropertyFilter with id '"+filterId+"'; no FilterProvider configured");
    }
    BeanPropertyFilter filter = filters.findFilter(filterId);
    // But whether unknown ids are ok just depends on filter provider; if we get null that's fine
    return filter;
}
 
开发者ID:sumeetchhetri,项目名称:test-html-generator-plugin,代码行数:20,代码来源:BeanSerializerBase.java


示例9: SerializationConfig

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
protected SerializationConfig(SerializationConfig paramSerializationConfig, FilterProvider paramFilterProvider)
{
  super(paramSerializationConfig);
  this._featureFlags = paramSerializationConfig._featureFlags;
  this._serializationInclusion = paramSerializationConfig._serializationInclusion;
  this._serializationView = paramSerializationConfig._serializationView;
  this._filterProvider = paramFilterProvider;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:9,代码来源:SerializationConfig.java


示例10: findFilter

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
protected BeanPropertyFilter findFilter(SerializerProvider paramSerializerProvider)
{
  Object localObject = this._propertyFilterId;
  FilterProvider localFilterProvider = paramSerializerProvider.getFilterProvider();
  if (localFilterProvider == null)
    throw new JsonMappingException("Can not resolve BeanPropertyFilter with id '" + localObject + "'; no FilterProvider configured");
  return localFilterProvider.findFilter(localObject);
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:9,代码来源:BeanSerializerBase.java


示例11: getFilterProvider

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
public FilterProvider getFilterProvider()
{
  return this._filterProvider;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:5,代码来源:SerializationConfig.java


示例12: withFilters

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
public SerializationConfig withFilters(FilterProvider paramFilterProvider)
{
  return new SerializationConfig(this, paramFilterProvider);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:5,代码来源:SerializationConfig.java


示例13: filteredWriter

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
public ObjectWriter filteredWriter(FilterProvider paramFilterProvider)
{
  return new ObjectWriter(this, copySerializationConfig().withFilters(paramFilterProvider));
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:5,代码来源:ObjectMapper.java


示例14: setFilters

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
public void setFilters(FilterProvider paramFilterProvider)
{
  this._serializationConfig = this._serializationConfig.withFilters(paramFilterProvider);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:5,代码来源:ObjectMapper.java


示例15: getFilterProvider

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
public final FilterProvider getFilterProvider()
{
  return this._config.getFilterProvider();
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:5,代码来源:SerializerProvider.java


示例16: withFilters

import org.codehaus.jackson.map.ser.FilterProvider; //导入依赖的package包/类
public ObjectWriter withFilters(FilterProvider paramFilterProvider)
{
  if (paramFilterProvider == this._config.getFilterProvider())
    return this;
  return new ObjectWriter(this, this._config.withFilters(paramFilterProvider));
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:7,代码来源:ObjectWriter.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java READDIRPLUS3Response类代码示例发布时间:2022-05-22
下一篇:
Java Hit类代码示例发布时间: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