org.exolab.castor.xml.Marshaller.setMapping()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(93)

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

Marshaller.setMapping介绍

[英]Sets the given mapping to be used by the marshalling Framework. If a resolver exists this mapping will be added to the existing ClassDescriptorResolver. Otherwise a new ClassDescriptorResolver will be created.
[中]设置编组框架要使用的给定映射。如果存在解析程序,此映射将添加到现有的ClassDescriptorResolver。否则将创建一个新的ClassDescriptorResolver。

代码示例

代码示例来源:origin: org.codehaus.castor/castor-jdo

public void saveHistory() {
  // write back the history to file
  try {
    FileWriter writer = new FileWriter("queryhistory.xml");
    Marshaller marshaller = new Marshaller(writer);
    marshaller.setMapping(_mapping);
    marshaller.marshal(_qhistory);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: com.github.muff1nman.chameleon/core

/**
   * Initializes the Castor mapping instance.
   * @param mapping a Castor mapping. Shall not be <code>null</code>.
   * @throws NullPointerException if <code>mapping</code> is <code>null</code>.
   * @throws MappingException an exception indicating an invalid mapping error.
   */
  private void setMapping(final Mapping mapping) throws MappingException
  {
    _unmarshaller = new Unmarshaller(mapping); // May throw MappingException.
    _unmarshaller.setValidation(false);
    _unmarshaller.setIgnoreExtraElements(true);

    _marshaller = new Marshaller();
    _marshaller.setMapping(mapping); // May throw MappingException.
    _marshaller.setValidation(false);
    //_marshaller.setDebug(true);
    // Specifies whether to support XML namespaces by default. Default is false.
    //_marshaller.setProperty("org.exolab.castor.parser.namespaces", "true");
    // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
    //_marshaller.setProperty("org.exolab.castor.indent", "true");
  }
}

代码示例来源:origin: org.codehaus.castor/castor-testsuite-xml-framework

private Marshaller createMarshaler(final File marshalOutput) throws Exception {
 getXMLContext().getInternalContext().getXMLClassDescriptorResolver().cleanDescriptorCache();
 Marshaller marshaller = getXMLContext().createMarshaller();
 marshaller.setWriter(new FileWriter(marshalOutput));
 // -- Configuration for marshaler? Use config from unit test case if available
 Configuration config = _unitTest.getConfiguration();
 if (config == null) {
  config = _configuration;
 }
 if (config != null) {
  ConfigurationType marshal = config.getMarshal();
  List returnValues = invokeEnumeratedMethods(marshaller, marshal);
  returnValues.clear(); // We don't care about the return values
 } // -- config != null
 if (_mapping != null) {
  marshaller.setMapping(_mapping);
 }
 if (_listener != null && _listener instanceof MarshalListener
   && _listenerType != TypeType.UNMARSHAL) {
  marshaller.setMarshalListener((MarshalListener) _listener);
 }
 return marshaller;
}

代码示例来源:origin: org.codehaus.xfire/xfire-castor

if (mapping != null)
  marshaller.setMapping(mapping);

相关文章