- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.sis.xml.XML.unmarshal()
方法的一些代码示例,展示了XML.unmarshal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XML.unmarshal()
方法的具体详情如下:
包路径:org.apache.sis.xml.XML
类名称:XML
方法名:unmarshal
[英]Unmarshal an object from the given file.
[中]从给定文件中解组对象。
代码示例来源:origin: apache/sis
/**
* Unmarshals the given object while listening to warnings.
*/
public DefaultBrowseGraphic unmarshal(final String xml) throws JAXBException {
return (DefaultBrowseGraphic) XML.unmarshal(new StreamSource(new StringReader(xml)),
singletonMap(XML.WARNING_LISTENER, this));
}
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
final Object object;
try {
object = XML.unmarshal(xml);
} catch (JAXBException e) {
代码示例来源:origin: apache/sis
final Object object;
try {
object = XML.unmarshal(xml);
} catch (JAXBException e) {
代码示例来源:origin: org.apache.sis.storage/sis-storage
/**
* Unmarshal the object, if not already done. Note that {@link #object} may still be null
* if an exception has been thrown at this invocation time or in previous invocation.
*
* @throws DataStoreException if an error occurred during the unmarshalling process.
*/
private void unmarshal() throws DataStoreException {
final StreamSource s = source;
final Closeable in = input(s);
source = null; // Cleared first in case of error.
if (in != null) try {
try {
object = XML.unmarshal(s, properties());
} finally {
in.close();
}
} catch (JAXBException | IOException e) {
throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, getDisplayName()), e);
}
if (object instanceof CoordinateReferenceSystem) try {
final DefinitionVerifier v = DefinitionVerifier.withAuthority((CoordinateReferenceSystem) object, null, false);
if (v != null) {
log(v.warning(false));
}
} catch (FactoryException e) {
listeners.warning(null, e);
}
}
代码示例来源:origin: apache/sis
/**
* Unmarshal the object, if not already done. Note that {@link #object} may still be null
* if an exception has been thrown at this invocation time or in previous invocation.
*
* @throws DataStoreException if an error occurred during the unmarshalling process.
*/
private void unmarshal() throws DataStoreException {
final StreamSource s = source;
final Closeable in = input(s);
source = null; // Cleared first in case of error.
if (in != null) try {
try {
object = XML.unmarshal(s, properties());
} finally {
in.close();
}
} catch (JAXBException | IOException e) {
throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, getDisplayName()), e);
}
if (object instanceof CoordinateReferenceSystem) try {
final DefinitionVerifier v = DefinitionVerifier.withAuthority((CoordinateReferenceSystem) object, null, false);
if (v != null) {
log(v.warning(false));
}
} catch (FactoryException e) {
listeners.warning(null, e);
}
}
代码示例来源:origin: apache/sis
final Citation citation = (Citation) XML.unmarshal(IDENTIFIED_XML);
assertTitleEquals("Citation", "My data", citation);
assertEquals(citation, XML.unmarshal(actual));
代码示例来源:origin: apache/sis
/**
* Tests (un)marshalling of an operation method.
*
* @throws JAXBException if an error occurred during marshalling or unmarshalling.
*/
@Test
public void testOperationMethod() throws JAXBException {
final String xml = XML.marshal(createMercatorMethod());
assertXmlEquals("<gml:OperationMethod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:name>Mercator (1SP)</gml:name>\n" +
" <gml:formula>See EPSG guide.</gml:formula>\n" +
" <gml:sourceDimensions>2</gml:sourceDimensions>\n" +
" <gml:targetDimensions>2</gml:targetDimensions>\n" +
" <gml:parameter>\n" +
" <gml:OperationParameter gml:id=\"epsg-parameter-8801\">\n" +
" <gml:identifier codeSpace=\"IOGP\">urn:ogc:def:parameter:EPSG::8801</gml:identifier>\n" +
" <gml:name codeSpace=\"EPSG\">Latitude of natural origin</gml:name>\n" +
" </gml:OperationParameter>\n" +
" </gml:parameter>\n" +
" <gml:parameter>\n" +
" <gml:OperationParameter gml:id=\"epsg-parameter-8802\">\n" +
" <gml:identifier codeSpace=\"IOGP\">urn:ogc:def:parameter:EPSG::8802</gml:identifier>\n" +
" <gml:name codeSpace=\"EPSG\">Longitude of natural origin</gml:name>\n" +
" </gml:OperationParameter>\n" +
" </gml:parameter>\n" +
"</gml:OperationMethod>", xml, "xmlns:*");
final OperationMethod method = (OperationMethod) XML.unmarshal(xml);
verifyMethod(method);
Validators.validate(method);
}
代码示例来源:origin: apache/sis
@DependsOnMethod("testReference")
public void testReferenceInEmptyObject() throws JAXBException {
final Citation citation = (Citation) XML.unmarshal(REFERENCED_XML);
assertTitleEquals("Citation.title", "My data", citation);
assertEquals(citation, XML.unmarshal(actual));
代码示例来源:origin: apache/sis
final Citation citation = (Citation) XML.unmarshal(REFERENCED_XML_WITH_BODY);
assertTitleEquals("Citation.title", "My data", citation);
assertEquals(citation, XML.unmarshal(actual));
代码示例来源:origin: apache/sis
/**
* Tests (un)marshalling of a parameter descriptor.
*
* @throws JAXBException if an error occurred during marshalling or unmarshalling.
*/
@Test
public void testDescriptor() throws JAXBException {
final DefaultParameterDescriptor<Double> descriptor = new DefaultParameterDescriptor<>(
Collections.singletonMap(DefaultParameterDescriptor.NAME_KEY, "A descriptor"),
0, 1, Double.class, null, null, null);
final String xml = XML.marshal(descriptor);
assertXmlEquals(
"<gml:OperationParameter xmlns:gml=\"" + Namespaces.GML + "\">\n"
+ " <gml:name>A descriptor</gml:name>\n"
+ " <gml:minimumOccurs>0</gml:minimumOccurs>\n"
+ "</gml:OperationParameter>", xml, "xmlns:*");
final DefaultParameterDescriptor<?> r = (DefaultParameterDescriptor<?>) XML.unmarshal(xml);
assertEquals("name", "A descriptor", r.getName().getCode());
assertEquals("minimumOccurs", 0, r.getMinimumOccurs());
assertEquals("maximumOccurs", 1, r.getMaximumOccurs());
/*
* A DefaultParameterDescriptor with null 'valueClass' is illegal, but there is no way we can guess
* this information if the <gml:OperationParameter> element was not a child of <gml:ParameterValue>.
* The current implementation leaves 'valueClass' to null despite being illegal. This behavior may
* change in any future Apache SIS version.
*/
assertNull("valueDomain", r.getValueDomain());
assertNull("valueClass", r.getValueClass()); // May change in any future SIS release.
}
代码示例来源:origin: apache/sis
final DefaultParameterValue<?> r = (DefaultParameterValue<?>) XML.unmarshal(xml);
if (!Objects.deepEquals(parameter.getValue(), r.getValue())) {
json: 无法将数组解码为 Go 类型的值 配置 json: { "monitor_servers_info":[ { "server
我有一个看起来像这样的 JSON blob { "metadata":{ "id":"2377f625-619b-4e20-90af-9a6cbfb80040",
我正在向第 3 方 API 发出 JSON 请求。如果我的身份验证 token 已过期,我会收到 {"error": "message"} .如果一切顺利,我会收到有效的回复。 现在,我调用json.
这个问题在这里已经有了答案: json.Marshal(struct) returns "{}" (3 个答案) 关闭 6 年前。 我在解码从 .json 文件中读取的 json 数据时遇到问题 t
我正在尝试从文件中读取并将其加载到结构 slice 中。如 block 注释中所示,我读入的行已正确加载。 我遇到的问题是 class 变量总是返回空值。我做错了什么? func loadClasse
我很难理解为什么下面使用 unmarshal 方法的代码不起作用,但我用 NewDecoder 编写的代码几乎相同,而且运行良好。 package conf import ( "os"
我目前遇到以下问题: 我通过 websocket 得到一个 []byte/string 看起来像 eventname {"JSON": "data", "In": "different formats
我正在从本地主机读取一个 json 文档并尝试将其转换为 Test 类型: type Test struct { one string two string three str
这个问题在这里已经有了答案: My structures are not marshalling into json [duplicate] (3 个答案) 关闭 6 年前。 我有以下代码: pac
我正在开发一个 RSS 阅读器应用程序,遇到了纽约时报 RSS 提要的问题。我已将问题缩小到以下 XML(省略了不必要的字段): https://www.nytimes.com/2017/09/
我有一个如下所示的 JSON 对象: {"API version":"1.2.3"} 我想使用 json.Unmarshal() 将它转换为一个对象去功能。根据this blog post : How
我有一个像这样的 JSON blob { "metadata":{ "id":"2377f625-619b-4e20-90af-9a6cbfb80040", "
我已经被这个问题困扰了几个星期了。我有一个从 Autonomy IDOL 搜索中收到的 XML 文档,可以将其成功解码为一组 Java 对象。但是,如果有国际字符,例如中文、日文、俄文/西里尔文,它们
我有一个图像数据结构 type ImageData struct { Name string Data []byte } 数据字段是转换为字节的图像。 我有jsonImages和[{"
这不是Stop json.Marshal() from stripping trailing zero from floating point number的副本,因为我希望和编码(marshal)(
在此链接:JAXB Unmarshalling XML string - Looping through all tags有人提出了一个很好的解决方案。我试图从中受益,但我无法让它在我的情况下发挥作用
我正在尝试解码一个没有注释的编码对象。 这是我的对象类。 class Student { private String name; private int age; publi
我在各种堆栈溢出帖子和博客条目中看到了以下语法: JAXBElement sc = unmarshaller.unmarshal(is, SomeClass.class); 那么当我尝试使用此语法时,
我必须在 Java 对象中解析 XML,并且 XML 包含一个未包装的对象列表,如下所示: Main Property A Main Property B
刚开始使用 Go,我对我正在学习的教程有一点疑问。我读到 Unmarshall 是某种 JSON 编码,我的疑问是:err = json.Unmarshal(body, &p) 为什么我们要将编码后的
我是一名优秀的程序员,十分优秀!