本文整理汇总了Java中com.fasterxml.jackson.dataformat.xml.JacksonXmlModule类的典型用法代码示例。如果您正苦于以下问题:Java JacksonXmlModule类的具体用法?Java JacksonXmlModule怎么用?Java JacksonXmlModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JacksonXmlModule类属于com.fasterxml.jackson.dataformat.xml包,在下文中一共展示了JacksonXmlModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getXmlMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
protected XmlMapper getXmlMapper() {
final XmlMapper xmlMapper = new XmlMapper(
new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(ODataClient.class, client));
xmlMapper.addHandler(new DeserializationProblemHandler() {
@Override
public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName)
throws IOException, JsonProcessingException {
// skip any unknown property
LOG.warn("Skipping unknown property {}", propertyName);
ctxt.getParser().skipChildren();
return true;
}
});
return xmlMapper;
}
示例2: getXmlMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
protected XmlMapper getXmlMapper() {
final XmlMapper xmlMapper = new XmlMapper(
new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(Boolean.class, Boolean.FALSE));
xmlMapper.addHandler(new DeserializationProblemHandler() {
@Override
public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
final com.fasterxml.jackson.databind.JsonDeserializer<?> deserializer,
final Object beanOrClass, final String propertyName)
throws IOException, JsonProcessingException {
// skip any unknown property
ctxt.getParser().skipChildren();
return true;
}
});
return xmlMapper;
}
示例3: newInstance
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
/**
* Creates properly configured Jackson XML Mapper instances.
* @return XmlMapper instance.
*/
public static XmlMapper newInstance() {
// Create new mapper
final JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper mapper = new XmlMapper(module);
// Configure it
mapper
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
.registerModule(new JodaModule())
.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
return mapper;
}
示例4: POMXmlMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
public POMXmlMapper() {
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
registerModule(xmlModule);
// registerModule(new JaxbAnnotationModule());
registerModule(new HealthTimeModule());
registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false));
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
setSerializationInclusion(JsonInclude.Include.NON_NULL);
// setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
addMixInAnnotations(IPOMObject.class, POMObjectJacksonXmlAnnotations.class);
}
示例5: exportStream
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
@Override
public void exportStream(OutputStream outputStream, Iterator<T> iterator) throws IOException, ClassNotFoundException, IllegalAccessException {
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
XmlFactory factory = new XmlFactory();
ToXmlGenerator generator = factory.createGenerator(outputStream);
generator.setCodec(xmlMapper);
generator.writeRaw("<xml>");
while (iterator.hasNext()) {
generator.writeRaw(xmlMapper.writeValueAsString(iterator.next()));
}
generator.writeRaw("</xml>");
generator.flush();
}
示例6: newXMLMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
/**
* Creates a new {@link com.fasterxml.jackson.dataformat.xml.XmlMapper} using Woodstox
* with Logback and Joda Time support.
* Also includes all {@link io.dropwizard.jackson.Discoverable} interface implementations.
*
* @return XmlMapper
*/
public static XmlMapper newXMLMapper(JacksonXmlModule jacksonXmlModule) {
final XmlFactory woodstoxFactory = new XmlFactory(new WstxInputFactory(), new WstxOutputFactory());
final XmlMapper mapper = new XmlMapper(woodstoxFactory, jacksonXmlModule);
mapper.registerModule(new GuavaModule());
mapper.registerModule(new LogbackModule());
mapper.registerModule(new GuavaExtrasModule());
mapper.registerModule(new JodaModule());
mapper.registerModule(new FuzzyEnumModule());
mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
mapper.setSubtypeResolver(new DiscoverableSubtypeResolver());
return mapper;
}
示例7: Response
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
public Response(Map<String, String> headers, int httpStatus, String payload) {
// configure the JacksonXml mapper in a cleaner way...
JacksonXmlModule module = new JacksonXmlModule();
// Check out: https://github.com/FasterXML/jackson-dataformat-xml
// setDefaultUseWrapper produces more similar output to
// the Json output. You can change that with annotations in your
// models.
module.setDefaultUseWrapper(false);
this.xmlMapper = new XmlMapper(module);
this.objectMapper = new ObjectMapper();
this.headers = headers;
this.httpStatus = httpStatus;
this.payload = payload;
}
示例8: toMetadata
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
public static Edmx toMetadata(final InputStream input) {
try {
final XmlMapper xmlMapper = new XmlMapper(
new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
xmlMapper.addHandler(new DeserializationProblemHandler() {
@Override
public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName)
throws IOException, JsonProcessingException {
// 1. special handling of AbstractAnnotatedEdm's fields
if (beanOrClass instanceof AbstractAnnotatedEdm
&& AbstractAnnotatedEdmUtils.isAbstractAnnotatedProperty(propertyName)) {
AbstractAnnotatedEdmUtils.parseAnnotatedEdm((AbstractAnnotatedEdm) beanOrClass, jp);
} // 2. skip any other unknown property
else {
ctxt.getParser().skipChildren();
}
return true;
}
});
return xmlMapper.readValue(input, Edmx.class);
} catch (Exception e) {
throw new IllegalArgumentException("Could not parse as Edmx document", e);
}
}
示例9: ResponseHandler
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
/**
* Default constructor.
*/
public ResponseHandler() {
// Create new mapper
final JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper = new XmlMapper(module);
// Configure it
mapper
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
.registerModule(new JodaModule())
.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
示例10: newInstance
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
public static UpgradeProcessorsConfig newInstance(Path configFilePath)
throws JsonParseException, JsonMappingException, IOException {
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
return xmlMapper.readValue(configFilePath.toFile(), UpgradeProcessorsConfig.class);
}
示例11: save
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
private void save()
{
saveTunerConfigurationModel();
SystemProperties props = SystemProperties.getInstance();
Path settingsFolder = props.getApplicationFolder("settings");
String settingsDefault = props.get("settings.defaultFilename",
"settings.xml");
String settingsCurrent = props.get("settings.currentFilename",
settingsDefault);
Path settingsPath = settingsFolder.resolve(settingsCurrent);
try(OutputStream out = Files.newOutputStream(settingsPath))
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
ObjectMapper objectMapper = new XmlMapper(xmlModule);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.writeValue(out, mSettings);
out.flush();
}
catch(IOException ioe)
{
mLog.error("IO error while writing the settings to a file [" + settingsPath + "]", ioe);
}
catch(Exception e)
{
mLog.error("Error while saving settings file [" + settingsPath + "]", e);
}
}
示例12: load
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
/**
* Erases current settings and loads settings from the settingsPath filename,
* if it exists.
*/
public void load(Path settingsPath)
{
mLoadingSettings = true;
if(Files.exists(settingsPath))
{
mLog.info("SettingsManager - loading settings file [" + settingsPath.toString() + "]");
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
ObjectMapper objectMapper = new XmlMapper(xmlModule);
try(InputStream in = Files.newInputStream(settingsPath))
{
mSettings = objectMapper.readValue(in, Settings.class);
}
catch(IOException ioe)
{
mLog.error("IO error while reading settings file", ioe);
}
}
else
{
mLog.info("SettingsManager - settings does not exist [" +
settingsPath.toString() + "]");
}
if(mSettings == null)
{
mSettings = new Settings();
}
loadTunerConfigurationModel();
mLoadingSettings = false;
}
示例13: Ds3SpecParserImpl
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
public Ds3SpecParserImpl() {
module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper = new XmlMapper(module);
mapper.registerModule(new GuavaModule());
final SimpleFilterProvider filterProvider = new SimpleFilterProvider().setFailOnUnknownId(false);
mapper.setFilters(filterProvider);
}
示例14: toODataErrorFromXML
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
protected XMLODataError toODataErrorFromXML(final InputStream input) {
try {
final XmlMapper xmlMapper = new XmlMapper(
new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
return xmlMapper.readValue(input, XMLODataError.class);
} catch (Exception e) {
throw new IllegalArgumentException("While deserializing XML error", e);
}
}
示例15: getObjectMapper
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入依赖的package包/类
@Override
protected ObjectMapper getObjectMapper() {
// Check out: https://github.com/FasterXML/jackson-dataformat-xml
JacksonXmlModule module = new JacksonXmlModule();
// setDefaultUseWrapper produces more similar output to
// the Json output. You can change that with annotations in your
// models.
module.setDefaultUseWrapper(false);
return new XmlMapper(module);
}