javax.xml.bind.JAXB._marshal()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(17.1k)|赞(0)|评价(0)|浏览(181)

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

JAXB._marshal介绍

[英]Writes a Java object tree to XML and store it to the specified location.

This method is a convenience method that combines several basic operations in the JAXBContext and Marshaller. This method is designed to be the prefered method for developers new to JAXB. This method has the following characterstics:

  1. Generally speaking, the performance is not necessarily optimal. It is expected that those people who need to write performance critical code will use the rest of the JAXB API directly.
  2. Errors that happen during the processing is wrapped into DataBindingException (which will have JAXBExceptionas its Throwable#getCause(). It is expected that those people who prefer the checked exception would use the rest of the JAXB API directly.
    [中]将Java对象树写入XML并将其存储到指定位置。
    此方法是一种方便的方法,它结合了JAXBContext和Marshaller中的几个基本操作。这种方法被设计成JAXB新手的首选方法。此方法具有以下特点:
    1.一般来说,性能不一定是最优的。预计那些需要编写性能关键代码的人将直接使用JAXB API的其余部分。
    1.处理过程中发生的错误被包装到DataBindingException中(这将使JaxBeException成为其可丢弃的#getCause()。希望那些喜欢检查异常的人会直接使用JAXB API的其余部分。

代码示例

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the {@link Result} object.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, Result xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be {@link URLConnection#getOutputStream() sent} to the
 *      resource pointed by this URL. Note that not all {@code URL}s support
 *      such operation, and exact semantics depends on the {@code URL}
 *      implementations. In case of {@link HttpURLConnection HTTP URLs},
 *      this will perform HTTP POST.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URL xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the given {@link OutputStream}.
 *      Upon a successful completion, the stream will be closed by this method.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, OutputStream xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      XML will be written to this file. If it already exists,
 *      it will be overwritten.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, File xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent as a character stream to the given {@link Writer}.
 *      Upon a successful completion, the stream will be closed by this method.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, Writer xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The URI is {@link URI#toURL() turned into URL} and then
 *      follows the handling of {@code URL}. See above.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URI xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The string is first interpreted as an absolute {@code URI}.
 *      If it's not {@link URI#isAbsolute() a valid absolute URI},
 *      then it's interpreted as a {@code File}
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, String xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api-osgi

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the {@link Result} object.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, Result xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/com.springsource.javax.xml.bind

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The URI is {@link URI#toURL() turned into URL} and then
 *      follows the handling of <tt>URL</tt>. See above.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URI xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax/javaee-endorsed-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      XML will be written to this file. If it already exists,
 *      it will be overwritten.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, File xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: jboss/jboss-javaee-specs

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      XML will be written to this file. If it already exists,
 *      it will be overwritten.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, File xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: sun-jaxb/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the {@link Result} object.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, Result xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: jakarta.xml.bind/jakarta.xml.bind-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the {@link Result} object.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, Result xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: org.jboss.spec.javax.xml.bind/jboss-jaxb-api_2.2_spec

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The URI is {@link URI#toURL() turned into URL} and then
 *      follows the handling of <tt>URL</tt>. See above.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URI xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/com.springsource.javax.xml.bind

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the {@link Result} object.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, Result xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: sun-jaxb/jaxb-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be {@link URLConnection#getOutputStream() sent} to the
 *      resource pointed by this URL. Note that not all <tt>URL</tt>s support
 *      such operation, and exact semantics depends on the <tt>URL</tt>
 *      implementations. In case of {@link HttpURLConnection HTTP URLs},
 *      this will perform HTTP POST.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URL xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: org.jboss.spec.javax.xml.bind/jboss-jaxb-api_2.2_spec

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      XML will be written to this file. If it already exists,
 *      it will be overwritten.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, File xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax/javaee-endorsed-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be {@link URLConnection#getOutputStream() sent} to the
 *      resource pointed by this URL. Note that not all <tt>URL</tt>s support
 *      such operation, and exact semantics depends on the <tt>URL</tt>
 *      implementations. In case of {@link HttpURLConnection HTTP URLs},
 *      this will perform HTTP POST.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URL xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: jakarta.xml.bind/jakarta.xml.bind-api

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The XML will be sent to the given {@link OutputStream}.
 *      Upon a successful completion, the stream will be closed by this method.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, OutputStream xml ) {
  _marshal(jaxbObject,xml);
}

代码示例来源:origin: javax.xml.bind/jaxb-api-osgi

/**
 * Writes a Java object tree to XML and store it to the specified location.
 *
 * @param jaxbObject
 *      The Java object to be marshalled into XML. If this object is
 *      a {@link JAXBElement}, it will provide the root tag name and
 *      the body. If this object has {@link XmlRootElement}
 *      on its class definition, that will be used as the root tag name
 *      and the given object will provide the body. Otherwise,
 *      the root tag name is {@link Introspector#decapitalize(String) infered} from
 *      {@link Class#getSimpleName() the short class name}.
 *      This parameter must not be null.
 *
 * @param xml
 *      The URI is {@link URI#toURL() turned into URL} and then
 *      follows the handling of <tt>URL</tt>. See above.
 *
 * @throws DataBindingException
 *      If the operation fails, such as due to I/O error, unbindable classes.
 */
public static void marshal( Object jaxbObject, URI xml ) {
  _marshal(jaxbObject,xml);
}

相关文章