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


Java JacksonXmlModule.setDefaultUseWrapper方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.dataformat.xml.JacksonXmlModule.setDefaultUseWrapper方法的典型用法代码示例。如果您正苦于以下问题:Java JacksonXmlModule.setDefaultUseWrapper方法的具体用法?Java JacksonXmlModule.setDefaultUseWrapper怎么用?Java JacksonXmlModule.setDefaultUseWrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.dataformat.xml.JacksonXmlModule的用法示例。


在下文中一共展示了JacksonXmlModule.setDefaultUseWrapper方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

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

示例8: 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

示例9: 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

示例10: 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

示例11: registerModules

import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
@Override
protected void registerModules(ObjectMapper mapper) {
	JacksonXmlModule module = new JacksonXmlModule();
	module.setDefaultUseWrapper(false);
	mapper.registerModule(module);
}
 
开发者ID:minnal,项目名称:minnal,代码行数:7,代码来源:DefaultXmlSerializer.java

示例12: testGetAndPostArticleViaXml

import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; //导入方法依赖的package包/类
@Test
public void testGetAndPostArticleViaXml() throws Exception {

    // /////////////////////////////////////////////////////////////////////
    // Test initial data:
    // /////////////////////////////////////////////////////////////////////
    String response = ninjaTestBrowser.makeXmlRequest(getServerAddress()
            + "api/[email protected]/articles.xml");
    System.out.println("response xml: " + response);
    
    JacksonXmlModule module = new JacksonXmlModule();
    // and then configure, for example:
    module.setDefaultUseWrapper(false);
    XmlMapper xmlMapper = new XmlMapper(module);
    

    ArticlesDto articlesDto = xmlMapper.readValue(response, ArticlesDto.class);

    assertEquals(3, articlesDto.articles.size());

    // /////////////////////////////////////////////////////////////////////
    // Post new article:
    // /////////////////////////////////////////////////////////////////////
    ArticleDto articleDto = new ArticleDto();
    articleDto.content = "contentcontent";
    articleDto.title = "new title new title";

    response = ninjaTestBrowser.postXml(getServerAddress()
            + "api/[email protected]/article.xml", articleDto);

    assertTrue(response.contains("Error. Forbidden."));

    doLogin();

    response = ninjaTestBrowser.postXml(getServerAddress()
            + "api/[email protected]/article.xml", articleDto);

    assertFalse(response.contains("Error. Forbidden."));

    // /////////////////////////////////////////////////////////////////////
    // Fetch articles again => assert we got a new one ...
    // /////////////////////////////////////////////////////////////////////
    response = ninjaTestBrowser.makeXmlRequest(getServerAddress()
            + "api/[email protected]/articles.xml");

    articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
    // one new result:
    assertEquals(4, articlesDto.articles.size());

}
 
开发者ID:mysu,项目名称:jade4ninja,代码行数:51,代码来源:ApiControllerTest.java


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