本文整理汇总了Java中org.codehaus.jackson.map.SerializationConfig.Feature类的典型用法代码示例。如果您正苦于以下问题:Java Feature类的具体用法?Java Feature怎么用?Java Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Feature类属于org.codehaus.jackson.map.SerializationConfig包,在下文中一共展示了Feature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatBean
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
@Override
protected void formatBean(Object objBean) throws Exception {
IdentityHashMap identityHashMap = new IdentityHashMap();
// root object
Map<String, Object> json = new HashMap<String, Object>();
// set desc and type on root
Class<?> clazz = objBean.getClass();
ManagedResource mr = clazz.getAnnotation(ManagedResource.class);
String strHelp = mr == null ? null : mr.description();
if (strHelp != null)
json.put("description", strHelp);
json.put("bean", clazz.getName());
identityHashMap.put(objBean, Boolean.TRUE);
// add properties and operations, recursively as needed
format(objBean, json, identityHashMap);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false);
// Output
getWriter().print(mapper.writeValueAsString(json));
}
示例2: _constructWriter
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
protected BeanPropertyWriter _constructWriter(SerializationConfig paramSerializationConfig, TypeBindings paramTypeBindings, PropertyBuilder paramPropertyBuilder, boolean paramBoolean, String paramString, AnnotatedMember paramAnnotatedMember)
throws JsonMappingException
{
if (paramSerializationConfig.isEnabled(SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS))
paramAnnotatedMember.fixAccess();
JavaType localJavaType = paramAnnotatedMember.getType(paramTypeBindings);
BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType, paramPropertyBuilder.getClassAnnotations(), paramAnnotatedMember);
JsonSerializer localJsonSerializer = findSerializerFromAnnotation(paramSerializationConfig, paramAnnotatedMember, localStd);
boolean bool = ClassUtil.isCollectionMapOrArray(localJavaType.getRawClass());
TypeSerializer localTypeSerializer = null;
if (bool)
localTypeSerializer = findPropertyContentTypeSerializer(localJavaType, paramSerializationConfig, paramAnnotatedMember, localStd);
BeanPropertyWriter localBeanPropertyWriter = paramPropertyBuilder.buildWriter(paramString, localJavaType, localJsonSerializer, findPropertyTypeSerializer(localJavaType, paramSerializationConfig, paramAnnotatedMember, localStd), localTypeSerializer, paramAnnotatedMember, paramBoolean);
localBeanPropertyWriter.setViews(paramSerializationConfig.getAnnotationIntrospector().findSerializationViews(paramAnnotatedMember));
return localBeanPropertyWriter;
}
示例3: serialize
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public void serialize(LocalDateTime paramLocalDateTime, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
if (paramSerializerProvider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS))
{
paramJsonGenerator.writeStartArray();
paramJsonGenerator.writeNumber(paramLocalDateTime.year().get());
paramJsonGenerator.writeNumber(paramLocalDateTime.monthOfYear().get());
paramJsonGenerator.writeNumber(paramLocalDateTime.dayOfMonth().get());
paramJsonGenerator.writeNumber(paramLocalDateTime.hourOfDay().get());
paramJsonGenerator.writeNumber(paramLocalDateTime.minuteOfHour().get());
paramJsonGenerator.writeNumber(paramLocalDateTime.secondOfMinute().get());
paramJsonGenerator.writeNumber(paramLocalDateTime.millisOfSecond().get());
paramJsonGenerator.writeEndArray();
return;
}
paramJsonGenerator.writeString(printLocalDateTime(paramLocalDateTime));
}
示例4: serialize
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
@Override
public void serialize(List<Map<Term, String>> value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
if ((value == null || value.isEmpty()) && provider.getConfig().isEnabled(Feature.WRITE_EMPTY_JSON_ARRAYS)) {
jgen.writeStartArray();
jgen.writeEndArray();
} else {
jgen.writeStartArray();
for (Map<Term, String> extension : value) {
jgen.writeStartObject();
for (Entry<Term, String> entry : extension.entrySet()) {
jgen.writeStringField(entry.getKey().qualifiedName(), entry.getValue());
}
jgen.writeEndObject();
}
jgen.writeEndArray();
}
}
示例5: wrapAndThrow
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public void wrapAndThrow(SerializerProvider paramSerializerProvider, Throwable paramThrowable, Object paramObject, int paramInt)
{
for (Throwable localThrowable = paramThrowable; ((localThrowable instanceof InvocationTargetException)) && (localThrowable.getCause() != null); localThrowable = localThrowable.getCause());
if ((localThrowable instanceof Error))
throw ((Error)localThrowable);
if ((paramSerializerProvider == null) || (paramSerializerProvider.isEnabled(SerializationConfig.Feature.WRAP_EXCEPTIONS)));
for (int i = 1; (localThrowable instanceof IOException); i = 0)
{
if ((i != 0) && ((localThrowable instanceof JsonMappingException)))
break label112;
throw ((IOException)localThrowable);
}
if ((i == 0) && ((localThrowable instanceof RuntimeException)))
throw ((RuntimeException)localThrowable);
label112: throw JsonMappingException.wrapWithPath(localThrowable, paramObject, paramInt);
}
示例6: createObjectMapper
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
private ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
mapper.setSerializationInclusion(Inclusion.NON_NULL);
mapper.configure(Feature.CLOSE_CLOSEABLE, false);
return mapper;
}
示例7: getObjectMapper
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
private ObjectMapper getObjectMapper() {
if(mapper == null){
mapper = new ObjectMapper();
mapper.configure(Feature.SORT_PROPERTIES_ALPHABETICALLY , true);
mapper.configure(Feature.WRITE_DATES_AS_TIMESTAMPS, false);
}
return mapper;
}
示例8: createDefaultMapper
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
private static ObjectMapper createDefaultMapper() {
final ObjectMapper result = new ObjectMapper();
//To make things look pretty when it gets converted
result.configure(Feature.INDENT_OUTPUT, true);
return result;
}
示例9: createObjectMapper
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
private ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
mapper.setSerializationInclusion(Inclusion.NON_NULL);
mapper.configure(Feature.CLOSE_CLOSEABLE, false);
mapper.configure(Feature.FLUSH_AFTER_WRITE_VALUE, false);
return mapper;
}
示例10: createMapper
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
private static ObjectMapper createMapper() {
final ObjectMapper mapper = new ObjectMapper();
mapper.configure(Feature.INDENT_OUTPUT, true);
mapper.configure(Feature.WRITE_NULL_MAP_VALUES, false);
// the next piece is from http://wiki.fasterxml.com/JacksonFAQDateHandling
mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.setSerializationConfig(mapper.getSerializationConfig().withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL));
return mapper;
}
示例11: JacksonMsgConverter
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public JacksonMsgConverter(boolean failOnUnknowProperties) {
configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
failOnUnknowProperties);
configure(Feature.WRITE_DATES_AS_TIMESTAMPS, false);
SimpleDateFormat format = new SimpleDateFormat(FULLTIME_FORMAT);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
setDateFormat(format);
}
示例12: serialize
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public void serialize(char[] paramArrayOfChar, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
if (paramSerializerProvider.isEnabled(SerializationConfig.Feature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS))
{
paramJsonGenerator.writeStartArray();
_writeArrayContents(paramJsonGenerator, paramArrayOfChar);
paramJsonGenerator.writeEndArray();
return;
}
paramJsonGenerator.writeString(paramArrayOfChar, 0, paramArrayOfChar.length);
}
示例13: serializeWithType
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public void serializeWithType(char[] paramArrayOfChar, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, TypeSerializer paramTypeSerializer)
throws IOException, JsonGenerationException
{
if (paramSerializerProvider.isEnabled(SerializationConfig.Feature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS))
{
paramTypeSerializer.writeTypePrefixForArray(paramArrayOfChar, paramJsonGenerator);
_writeArrayContents(paramJsonGenerator, paramArrayOfChar);
paramTypeSerializer.writeTypeSuffixForArray(paramArrayOfChar, paramJsonGenerator);
return;
}
paramTypeSerializer.writeTypePrefixForScalar(paramArrayOfChar, paramJsonGenerator);
paramJsonGenerator.writeString(paramArrayOfChar, 0, paramArrayOfChar.length);
paramTypeSerializer.writeTypeSuffixForScalar(paramArrayOfChar, paramJsonGenerator);
}
示例14: resolve
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public void resolve(SerializerProvider paramSerializerProvider)
throws JsonMappingException
{
if ((this._valueSerializer == null) && ((paramSerializerProvider.isEnabled(SerializationConfig.Feature.USE_STATIC_TYPING)) || (Modifier.isFinal(this._accessorMethod.getReturnType().getModifiers()))))
{
JavaType localJavaType = paramSerializerProvider.constructType(this._accessorMethod.getGenericReturnType());
this._valueSerializer = paramSerializerProvider.findTypedValueSerializer(localJavaType, false, this._property);
this._forceTypeInformation = isNaturalTypeWithStdHandling(localJavaType, this._valueSerializer);
}
}
示例15: wrapAndThrow
import org.codehaus.jackson.map.SerializationConfig.Feature; //导入依赖的package包/类
public void wrapAndThrow(SerializerProvider paramSerializerProvider, Throwable paramThrowable, Object paramObject, int paramInt)
throws IOException
{
while (((paramThrowable instanceof InvocationTargetException)) && (paramThrowable.getCause() != null))
paramThrowable = paramThrowable.getCause();
if ((paramThrowable instanceof Error))
throw ((Error)paramThrowable);
int i;
if ((paramSerializerProvider == null) || (paramSerializerProvider.isEnabled(SerializationConfig.Feature.WRAP_EXCEPTIONS)))
i = 1;
while (true)
if ((paramThrowable instanceof IOException))
{
if ((i != 0) && ((paramThrowable instanceof JsonMappingException)))
break;
throw ((IOException)paramThrowable);
i = 0;
continue;
}
else
{
if ((i != 0) || (!(paramThrowable instanceof RuntimeException)))
break;
throw ((RuntimeException)paramThrowable);
}
throw JsonMappingException.wrapWithPath(paramThrowable, paramObject, paramInt);
}