当前位置: 首页>>代码示例>>Java>>正文


Java JacksonXmlModule类代码示例

本文整理汇总了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;
}
 
开发者ID:ashank,项目名称:Office-365-SDK-for-Android,代码行数:20,代码来源:AbstractODataDeserializer.java

示例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;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ClientODataDeserializerImpl.java

示例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;
}
 
开发者ID:Crim,项目名称:pardot-java-client,代码行数:20,代码来源:JacksonFactory.java

示例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);
    }
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:POMXmlMapper.java

示例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();
}
 
开发者ID:robeio,项目名称:robe,代码行数:20,代码来源:XMLExporter.java

示例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;
}
 
开发者ID:yunspace,项目名称:dropwizard-xml,代码行数:23,代码来源:JacksonXML.java

示例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;

    }
 
开发者ID:r10r-org,项目名称:doctester,代码行数:19,代码来源:Response.java

示例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);
    }
}
 
开发者ID:mkostin,项目名称:ODataJClient,代码行数:30,代码来源:Deserializer.java

示例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"));
}
 
开发者ID:Crim,项目名称:pardot-java-client,代码行数:17,代码来源:ResponseHandler.java

示例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);
}
 
开发者ID:hgadre,项目名称:solr-upgrade-tool,代码行数:9,代码来源:UpgradeProcessorsConfigFactory.java

示例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);
    }
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:35,代码来源:SettingsManager.java

示例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;
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:41,代码来源:SettingsManager.java

示例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);
}
 
开发者ID:SpectraLogic,项目名称:ds3_autogen,代码行数:9,代码来源:Ds3SpecParserImpl.java

示例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);
    }
}
 
开发者ID:ashank,项目名称:Office-365-SDK-for-Android,代码行数:10,代码来源:AbstractODataDeserializer.java

示例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);
}
 
开发者ID:decebals,项目名称:pippo,代码行数:11,代码来源:JacksonXmlEngine.java


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