本文整理汇总了Java中org.codehaus.jackson.map.ser.impl.SimpleFilterProvider类的典型用法代码示例。如果您正苦于以下问题:Java SimpleFilterProvider类的具体用法?Java SimpleFilterProvider怎么用?Java SimpleFilterProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleFilterProvider类属于org.codehaus.jackson.map.ser.impl包,在下文中一共展示了SimpleFilterProvider类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: jsonToStringIgnoreSpecialFields
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的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.impl.SimpleFilterProvider; //导入依赖的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.impl.SimpleFilterProvider; //导入依赖的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.impl.SimpleFilterProvider; //导入依赖的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.impl.SimpleFilterProvider; //导入依赖的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.impl.SimpleFilterProvider; //导入依赖的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.impl.SimpleFilterProvider; //导入依赖的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: getLogDataAppJson
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的package包/类
/**
* Helper, converts an logData object into Json for POSTs
*/
private static String getLogDataAppJson(LogData logData) {
try{
ObjectMapper mapper = new ObjectMapper();
SimpleFilterProvider filters = new SimpleFilterProvider().addFilter("privateView",new ManagedAppTestFilter());
// and then serialize using that filter provider:
return mapper.writer(filters).writeValueAsString(logData);
} catch(Exception e) {
fail("JSON Serialization failed." + e);
return null;
}
}
开发者ID:leeclarke,项目名称:homePi,代码行数:15,代码来源:DeviceRestServiceIT.java
示例9: getProfileJson
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的package包/类
/**
* Helper, Get PiProfile as JSON.
* @param profile
* @return
*/
private static String getProfileJson(PiProfile profile) {
try{
ObjectMapper mapper = new ObjectMapper();
SimpleFilterProvider filters = new SimpleFilterProvider().addFilter("privateView",new PiProfileTestFilter());
// and then serialize using that filter provider:
return mapper.writer(filters).writeValueAsString(profile);
} catch(Exception e) {
fail("JSON Serialization failed." + e);
return null;
}
}
开发者ID:leeclarke,项目名称:homePi,代码行数:17,代码来源:HomePiRestServiceIT.java
示例10: getManagedAppJson
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的package包/类
private static String getManagedAppJson(ManagedApp ma) {
try{
ObjectMapper mapper = new ObjectMapper();
SimpleFilterProvider filters = new SimpleFilterProvider().addFilter("privateView",new ManagedAppTestFilter());
// and then serialize using that filter provider:
return mapper.writer(filters).writeValueAsString(ma);
} catch(Exception e) {
fail("JSON Serialization failed." + e);
return null;
}
}
开发者ID:leeclarke,项目名称:homePi,代码行数:12,代码来源:HomePiRestServiceIT.java
示例11: getUserJson
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的package包/类
/**
* Helper, Get HomePiUser as JSON.
* @param user
* @return
*/
private static String getUserJson(HomePiUser user) {
try{
ObjectMapper mapper = new ObjectMapper();
SimpleFilterProvider filters = new SimpleFilterProvider().addFilter("privateView",new HomePiUserTestFilter());
// and then serialize using that filter provider:
return mapper.writer(filters).writeValueAsString(user);
} catch(Exception e) {
fail("JSON Serialization failed." + e);
return null;
}
}
开发者ID:leeclarke,项目名称:homePi,代码行数:17,代码来源:UserSerivceIT.java
示例12: getConfiguredMapper
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的package包/类
private ObjectMapper getConfiguredMapper(){
ObjectMapper mapper = new ObjectMapper();
SerializationConfig serConfig = mapper.getSerializationConfig();
SimpleFilterProvider fp = new SimpleFilterProvider();
fp.addFilter("privateView", new HomePiPrivateFilter());
mapper.setSerializationConfig(serConfig.withFilters(fp));
mapper.setFilters(fp);
return mapper;
}
开发者ID:leeclarke,项目名称:homePi,代码行数:13,代码来源:HomePiPrivateFilterTest.java
示例13: JacksonConfigurator
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider; //导入依赖的package包/类
public JacksonConfigurator() {
SerializationConfig serConfig = mapper.getSerializationConfig();
SimpleFilterProvider fp = new SimpleFilterProvider();
//Add filters here! TODO: Extract to properties and inject
fp.addFilter("privateView", new HomePiPrivateFilter());
mapper.setSerializationConfig(serConfig.withFilters(fp));
mapper.setFilters(fp);
}
开发者ID:leeclarke,项目名称:homePi,代码行数:13,代码来源:JacksonConfigurator.java
注:本文中的org.codehaus.jackson.map.ser.impl.SimpleFilterProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论