org.apache.sis.xml.XML.unmarshal()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.apache.sis.xml.XML.unmarshal()方法的一些代码示例,展示了XML.unmarshal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XML.unmarshal()方法的具体详情如下:
包路径:org.apache.sis.xml.XML
类名称:XML
方法名:unmarshal

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())) {

相关文章