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


Java XmlMapper.readValue方法代码示例

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


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

示例1: testParseSiteMap

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

	InputStream stream = getClass().getClassLoader().getResourceAsStream("xml/footer.xml");
	XmlMapper xmlMapper = new XmlMapper();
	Footer footer = xmlMapper.readValue(stream, Footer.class);
	assertEquals(7, footer.getMenuset().size());
	SiteMap frSiteMap = footer.getMenuset().get(0);
	assertEquals("fr", frSiteMap.getLanguage());
	assertEquals(13, frSiteMap.getEntries().size());
	assertEquals("/fr/association", frSiteMap.getEntries().get(0).getUrl());
	assertEquals("Association", frSiteMap.getEntries().get(0).getLabel());

	SiteMap enSiteMap = footer.getMenuset().get(1);
	assertEquals("en", enSiteMap.getLanguage());
	assertEquals(13, enSiteMap.getEntries().size());
}
 
开发者ID:ozwillo,项目名称:ozwillo-portal,代码行数:18,代码来源:SiteMapFooterParserTest.java

示例2: adaptXMLLine

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
private ObjectNode adaptXMLLine(String line)
{
  XmlMapper mapper = new XmlMapper();
  ObjectNode objNode = null;
  try
  {
    objNode = mapper.readValue(line, ObjectNode.class);
    objNode.put("_id", objNode.get("Id").asText());
    objNode.remove("Id");
  } catch (Exception e)
  {
    e.printStackTrace();
  }

  return objNode;
}
 
开发者ID:catedrasaes-umu,项目名称:NoSQLDataEngineering,代码行数:17,代码来源:SOF2Db.java

示例3: testParseHeaderSiteMap

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

	InputStream stream = getClass().getClassLoader().getResourceAsStream("xml/header.xml");
	XmlMapper xmlMapper = new XmlMapper();
	HeaderMenuSet header = xmlMapper.readValue(stream, HeaderMenuSet.class);

	validateMenuSet(header);

	List<SiteMapMenuItem> siteMapMenuItems = header.getMenuset().get(0).getItems();
	assertEquals("/static/img/logo.png", siteMapMenuItems.get(0).getImgUrl());

	SiteMapMenuItem catalogMenuItem = siteMapMenuItems.get(5);
	assertEquals("https://portal.ozwillo.com/fr/store", catalogMenuItem.getUrl());
	assertEquals("/static/img/icone-catalogue-color.png", catalogMenuItem.getImgUrl());
	assertEquals("Catalogue", catalogMenuItem.getLabel());

	assertEquals(3, siteMapMenuItems.get(2).getItems().size());
	SiteMapMenuItem offerDataMenuItem = siteMapMenuItems.get(2).getItems().get(0);
	assertEquals("/fr/offre-donnees", offerDataMenuItem.getUrl());
	assertEquals("menu", offerDataMenuItem.getType());
	assertEquals("Données", offerDataMenuItem.getLabel());
}
 
开发者ID:ozwillo,项目名称:ozwillo-portal,代码行数:24,代码来源:SiteMapHeaderParserTest.java

示例4: toMetadata

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的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

示例5: getManufacturingParameters

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public List<ManufacturingParameters> getManufacturingParameters() {
  List<ManufacturingParameters> manufacturingParameters = newArrayList();
  try {
    for (DatabasePage page : getPages()) {
      ByteArrayInputStream inputStream = new ByteArrayInputStream(page.getPageData());
      DataInput input = this.dataInputFactory.create(inputStream);
      // TODO: something better than ignoring the data?
      long systemSeconds = UnsignedInts.toLong(input.readInt());
      long displaySeconds = UnsignedInts.toLong(input.readInt());

      byte[] xmlBytes = new byte[inputStream.available() - 2];
      input.readFully(xmlBytes);

      validateCrc(input.readUnsignedShort(), page.getPageData());

      XmlMapper xmlMapper = new XmlMapper();
      ManufacturingParameters parameterPage = xmlMapper.readValue(new String(xmlBytes, "UTF-8"),
              ManufacturingParameters.class);
      manufacturingParameters.add(parameterPage);
    }
    return manufacturingParameters;
  } catch (IOException e) {
    throw Throwables.propagate(e);
  }
}
 
开发者ID:alexandre-normand,项目名称:blood-shepherd,代码行数:26,代码来源:ManufacturingDataDatabasePagesResponse.java

示例6: unmarshal

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

    ToolSuiteXml toolSuiteXml = serializer.readValue(responseXml, ToolSuiteXml.class);

    assertThat(toolSuiteXml.getReleases(), notNullValue());
    assertThat(toolSuiteXml.getReleases().size(), equalTo(4));
    Release release = toolSuiteXml.getReleases().get(0);
    assertThat(release.getDownloads().size(), equalTo(7));
    assertThat(release.getWhatsnew(), notNullValue());

    assertThat(toolSuiteXml.getOthers(), notNullValue());
    assertThat(toolSuiteXml.getOthers().size(), equalTo(43));
    Release oldRelease = toolSuiteXml.getOthers().get(0);
    assertThat(oldRelease.getDownloads().size(), equalTo(17));
    assertThat(oldRelease.getWhatsnew(), notNullValue());
}
 
开发者ID:spring-io,项目名称:sagan,代码行数:19,代码来源:ToolSuiteXmlParsingTests.java

示例7: setUp

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    String responseXml = Fixtures.load("/fixtures/tools/eclipse.xml");
    XmlMapper serializer = new XmlMapper();
    EclipseXml eclipseXml = serializer.readValue(responseXml, EclipseXml.class);
    eclipseDownloads = new EclipseDownloadsXmlConverter().convert(eclipseXml);
    platforms = eclipseDownloads.getPlatforms();
}
 
开发者ID:spring-io,项目名称:sagan,代码行数:9,代码来源:EclipseDownloadsXmlConverterTests.java

示例8: unmarshal

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

    EclipseXml eclipseXml = serializer.readValue(responseXml, EclipseXml.class);
    assertThat(eclipseXml.getEclipseXmlProducts(), notNullValue());
    assertThat(eclipseXml.getEclipseXmlProducts().size(), equalTo(6));

    EclipseXmlProduct eclipseXmlProduct = eclipseXml.getEclipseXmlProducts().get(0);
    assertThat(eclipseXmlProduct.getName(), equalTo("SpringSource Tool Suites Downloads"));
    assertThat(eclipseXmlProduct.getPackages().size(), equalTo(4));
    assertThat(
            eclipseXmlProduct.getPackages().get(0).getDescription(),
            equalTo("Spring Tool Suite&trade; (STS) provides the best Eclipse-powered development environment for building Spring-based enterprise applications. STS includes tools for all of the latest enterprise Java and Spring based technologies. STS supports application targeting to local, and cloud-based servers and provides built in support for vFabric tc Server. Spring Tool Suite is freely available for development and internal business operations use with no time limits."));
    assertThat(eclipseXmlProduct.getPackages().get(0).getEclipseXmlDownloads().get(0).getFile(),
            equalTo("release/STS/3.3.0/dist/e4.3/spring-tool-suite-3.3.0.RELEASE-e4.3-win32-installer.exe"));
}
 
开发者ID:spring-io,项目名称:sagan,代码行数:18,代码来源:EclipseXmlParsingTests.java

示例9: deserialize

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
/**
 * Deserialize the given XML string to Java object.
 *
 * @param <T> Type
 * @param body The XML string
 * @param returnType The type to deserialize into
 * @return The deserialized Java object
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(String body, Type returnType) throws ApiException {
    try {
        XmlMapper xmlMapper = new XmlMapper();
        return (T) xmlMapper.readValue(body, (Class) returnType);
    } catch (IOException e) {
        return readError(body, returnType);
    }
}
 
开发者ID:hermannpencole,项目名称:nifi-swagger-client,代码行数:18,代码来源:XML.java

示例10: readError

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
private  <T> T readError(String error, Type returnType) throws ApiException {
    try {
        // Fallback processing when failed to parse XML form response body:
        //   return the response body string directly for the String return type;
        //   parse response body into date or datetime for the Date return type.
        if (returnType.equals(String.class))
            return (T) error;
        XmlMapper xmlMapper = new XmlMapper();
        ErrorResponse value = xmlMapper.readValue(error, ErrorResponse.class);
        throw new ApiException(Integer.valueOf(value.getStatus()), value.getStatusText());
    } catch (NumberFormatException | IOException ea) {
       throw new ApiException(error);
    }
}
 
开发者ID:hermannpencole,项目名称:nifi-swagger-client,代码行数:15,代码来源:XML.java

示例11: newInstance

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的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

示例12: createIndexDataBean

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public static IndexDataBean createIndexDataBean(File indexSummaryPath) {
    try {
        XmlMapper xmlMapper = new XmlMapper();
        xmlMapper.configure(Feature.WRITE_XML_DECLARATION, true);
        return xmlMapper.readValue(FileUtils.readFileToString(indexSummaryPath), IndexDataBean.class);

    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:11,代码来源:RepositoryManager.java

示例13: convertRequest

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
/**
 * 
 * @param inputStream request.getInputStream()
 * @return
 */
public static PayNativeInput convertRequest(InputStream inputStream){
	try {
		String content = IOUtils.toString(inputStream);
		
		XmlMapper xmlMapper = new XmlMapper();
		PayNativeInput payNativeInput = xmlMapper.readValue(content, PayNativeInput.class);
		
		return payNativeInput;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:louiseliu,项目名称:weixin-pay,代码行数:19,代码来源:PayUtils.java

示例14: process

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
    LOGGER.info("Got Message from exchange!!");
    Message msg = exchange.getIn();

    String msgBody = msg.getBody().toString();
    //LOGGER.info("Message:"+ msgBody);
    XmlMapper xmlMapper = new XmlMapper();
    TableQrns tableQrns = xmlMapper.readValue(msgBody, TableQrns.class);
    final int objectId = tableQrns.getObjectId();
    LOGGER.info("ObectId {}", objectId);
    String tableName="";
    if(!TABLE_NAME_CACHE.isEmpty() && TABLE_NAME_CACHE.containsKey(Integer.valueOf(objectId))){
        tableName = TABLE_NAME_CACHE.get(Integer.valueOf(objectId));
    }else{
        // query the database table for getting table metadata by objectId
        List<TableObjectsDTO> tableObjectsDTO = (List<TableObjectsDTO>)getOraJdbcTemplate().query(SQL_META_DATA, new Object[]{objectId}, new TableRowMapper());
        tableName = tableObjectsDTO.get(0).getTableName();
        TABLE_NAME_CACHE.put(objectId, tableName);
        List<String> colNames = new ArrayList<String>();
        tableObjectsDTO.forEach(
                p->{
                    colNames.add(p.getColumnName());
                }
        );
        TABLE_META_DATA.put(tableName, colNames);
    }

    importToES(tableQrns, tableName);
}
 
开发者ID:srecon,项目名称:OracleToElasticSearch,代码行数:31,代码来源:MessageProcessor.java

示例15: xmlToBean

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public static <T> T xmlToBean(InputStream src, Class<T> valueType) {
	XmlMapper xml = new XmlMapper();
	try {
		return xml.readValue(src, valueType);
	} catch (IOException e) {
		Logger.getLogger(JacksonXmlUtil.class.getName()).log(Level.SEVERE, null, e);
		return null;
	}
}
 
开发者ID:East196,项目名称:maker,代码行数:10,代码来源:JacksonXmlUtil.java


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