public abstract class AbstractMarshallerImpl extends Object implements Marshaller
这类提供的Marshaller接口部分的默认实现。
一个供应商实施JAXB的唯一方法是marshal(Object, javax.xml.transform.Result),marshal(Object, javax.xml.stream.XMLStreamWriter),和marshal(Object, javax.xml.stream.XMLEventWriter)。
Marshaller
Marshaller.ListenerJAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION| Constructor and Description |
|---|
AbstractMarshallerImpl() |
| Modifier and Type | Method and Description |
|---|---|
<A extends XmlAdapter> |
getAdapter(类<A> type)
获取与指定类型关联的适配器。
|
AttachmentMarshaller |
getAttachmentMarshaller() |
protected String |
getEncoding()
用于获取当前输出编码的方便方法。
|
ValidationEventHandler |
getEventHandler()
如果一个没有被设置,返回当前事件处理程序或默认事件处理程序。
|
protected String |
getJavaEncoding(String encoding)
得到相应的java从IANA名称编码。
|
Marshaller.Listener |
getListener()
返回
Marshaller.Listener注册这个
Marshaller。
|
Node |
getNode(Object obj)
默认情况下,是不支持的getnode方法抛出一个
UnsupportedOperationException。
|
protected String |
getNoNSSchemaLocation()
获取当前nonamespaceschemalocation便利的方法。
|
Object |
getProperty(String name)
getProperty方法的默认实现处理四定义的属性在Marshaller。
|
Schema |
getSchema()
把JAXP 1.3
Schema对象被用来执行元帅的时间验证。
|
protected String |
getSchemaLocation()
获取当前schemaLocation便利的方法。
|
protected boolean |
isFormattedOutput()
获取格式化输出标志的方便方法。
|
protected boolean |
isFragment()
获取片段标记的方便方法。
|
void |
marshal(Object obj, ContentHandler handler)
元帅的内容树
jaxbElement成SAX2事件。
|
void |
marshal(Object jaxbElement, File output)
元帅的内容树
jaxbElement到文件。
|
void |
marshal(Object obj, Node node)
元帅的内容树
jaxbElement成DOM树。
|
void |
marshal(Object obj, OutputStream os)
元帅的内容树
jaxbElement到输出流。
|
void |
marshal(Object obj, Writer w)
元帅的内容树
jaxbElement成作家。
|
void |
marshal(Object obj, XMLEventWriter writer)
元帅的内容树
jaxbElement成
XMLEventWriter。
|
void |
marshal(Object obj, XMLStreamWriter writer)
元帅的内容树
jaxbElement成
XMLStreamWriter。
|
<A extends XmlAdapter> |
setAdapter(类<A> type, A adapter)
联想的配置实例
XmlAdapter这个指挥。
|
void |
setAdapter(XmlAdapter adapter)
联想的配置实例
XmlAdapter这个指挥。
|
void |
setAttachmentMarshaller(AttachmentMarshaller am)
将一个可在XML文档中的二进制数据作为XML二进制优化附件传输的上下文关联。
|
protected void |
setEncoding(String encoding)
设置输出编码的方便方法。
|
void |
setEventHandler(ValidationEventHandler handler)
允许应用程序注册一个验证事件处理程序。
|
protected void |
setFormattedOutput(boolean v)
设置格式化输出标志的方便方法。
|
protected void |
setFragment(boolean v)
设置碎片标志的方便方法。
|
void |
setListener(Marshaller.Listener listener)
这
Marshaller登记事件回调
Marshaller.Listener元帅。
|
protected void |
setNoNSSchemaLocation(String location)
设置nonamespaceschemalocation便利的方法。
|
void |
setProperty(String name, Object value)
setProperty方法的默认实现处理四定义的属性在Marshaller。
|
void |
setSchema(Schema schema)
指定JAXP 1.3
Schema对象应该用来验证后续元帅作战。
|
protected void |
setSchemaLocation(String location)
对于设置schemaLocation方便的方法。
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmarshalpublic final void marshal(Object obj, OutputStream os) throws JAXBException
Marshaller
marshal 接口
Marshaller
obj -内容整理根树。
os XML将被添加到该流。
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
obj元帅(或任何物体可从
obj)。看到
Marshalling a JAXB element。
public void marshal(Object jaxbElement, File output) throws JAXBException
Marshaller
marshal 接口
Marshaller
jaxbElement -内容整理根树。
output文件被写入。如果该文件已经存在,它将被覆盖。
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
obj元帅(或任何物体可从
obj)。看到
Marshalling a JAXB element。
public final void marshal(Object obj, Writer w) throws JAXBException
Marshaller
marshal 接口
Marshaller
obj -内容整理根树。
w XML将被发送到这个作家。
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
obj元帅(或任何物体可从
obj)。看到
Marshalling a JAXB element。
public final void marshal(Object obj, ContentHandler handler) throws JAXBException
Marshaller
marshal 接口
Marshaller
obj -内容整理根树。
handler XML将被发送到这个处理SAX2事件。
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
obj元帅(或任何物体可从
obj)。看到
Marshalling a JAXB element。
public final void marshal(Object obj, Node node) throws JAXBException
Marshaller
marshal 接口
Marshaller
obj -内容被整理。
node DOM节点将作为该节点的孩子。该参数必须是一个节点,接受孩子(
Document,
DocumentFragment,或
Element)
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
jaxbElement元帅(或任何物体可从
jaxbElement)。看到
Marshalling a JAXB element。
public Node getNode(Object obj) throws JAXBException
UnsupportedOperationException。选择支持此方法的实现必须重写此方法。
getNode 接口
Marshaller
obj - JAXB java的XML表示的内容
JAXBException -如果任何意想不到的问题发生
protected String getEncoding()
protected void setEncoding(String encoding)
encoding -有效的编码为指定的指挥类文档
protected String getSchemaLocation()
protected void setSchemaLocation(String location)
location - SchemaLocation价值
protected String getNoNSSchemaLocation()
protected void setNoNSSchemaLocation(String location)
location - nonamespaceschemalocation价值
protected boolean isFormattedOutput()
protected void setFormattedOutput(boolean v)
v -格式化输出的标志值。
protected boolean isFragment()
protected void setFragment(boolean v)
v -碎片的标志值。
protected String getJavaEncoding(String encoding) throws UnsupportedEncodingException
UnsupportedEncodingException如果实现找不到java的编码名称。
public void setProperty(String name, Object value) throws PropertyException
setProperty 接口
Marshaller
name -要设置的属性的名称。此值可以使用常量字段或用户提供的字符串中的一个指定。
value -属性要设置的值
PropertyException -当有特定的属性或值的误差处理
public Object getProperty(String name) throws PropertyException
getProperty 接口
Marshaller
name -属性的名称检索
PropertyException -当有检索给定属性或值的属性名称错误
public ValidationEventHandler getEventHandler() throws JAXBException
Marshaller
getEventHandler 接口
Marshaller
JAXBException -如果在当前的事件处理程序时出错
Marshaller.getEventHandler()
public void setEventHandler(ValidationEventHandler handler) throws JAXBException
Marshaller
验证事件处理程序将被JAXB提供者如果任何验证期间遇到错误调用任何元帅的API的。如果客户端应用程序不登记验证事件处理程序调用一个元帅的方法之前,然后验证事件将被默认的事件处理程序将后遇到的第一个错误或致命错误终止元帅作业处理。
使用null参数调用此方法将导致指挥恢复到默认的默认事件处理程序。
setEventHandler 接口
Marshaller
handler -验证事件处理程序
JAXBException如果同时设置事件处理程序时出错
Marshaller.setEventHandler(ValidationEventHandler)
public void marshal(Object obj, XMLEventWriter writer) throws JAXBException
Marshaller
XMLEventWriter。
marshal 接口
Marshaller
obj内容-树在jaxbelement被整理。
writer XML将被发送到这个作家。
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
obj元帅(或任何物体可从
obj)。看到
Marshalling a JAXB element。
public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException
Marshaller
XMLStreamWriter。
marshal 接口
Marshaller
obj -内容被整理。
writer XML将被发送到这个作家。
JAXBException -如果在编组发生任何意外的问题。
MarshalException -如果
ValidationEventHandler返回false其
handleEvent法或
Marshaller无法
obj元帅(或任何物体可从
obj)。看到
Marshalling a JAXB element。
public void setSchema(Schema schema)
Marshaller
setSchema 接口
Marshaller
schema架构对象验证元帅打击或空禁用验证
public Schema getSchema()
Marshaller
Schema对象被用来执行元帅的时间验证。如果没有模式设置在指挥,那么这个方法将返回null表示元帅时间验证将不会执行。
getSchema 接口
Marshaller
public void setAdapter(XmlAdapter adapter)
Marshaller
XmlAdapter这个指挥。
这是一个方便的方法调用setAdapter(adapter.getClass(),adapter);。
setAdapter 接口
Marshaller
Marshaller.setAdapter(Class,XmlAdapter)
public <A extends XmlAdapter> void setAdapter(类<A> type, A adapter)
Marshaller
XmlAdapter这个指挥。
每一个指挥内部保持Map < 类,XmlAdapter >,它使用编组的字段/方法注释的XmlJavaTypeAdapter类。
这种方法允许应用程序使用的配置实例XmlAdapter。当适配器的实例是不给,一个指挥将创建一个通过调用其默认构造函数。
setAdapter 接口
Marshaller
type -适配器的类型。指定的实例时将使用
XmlJavaTypeAdapter.value()指的是这种类型。
adapter -适配器要使用的实例。如果为空,它将不为这种类型的当前适配器设置。
public <A extends XmlAdapter> A getAdapter(类<A> type)
Marshaller
Marshaller.setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)反向操作的方法。
getAdapter 接口
Marshaller
public void setAttachmentMarshaller(AttachmentMarshaller am)
Marshaller
将一个可在XML文档中的二进制数据作为XML二进制优化附件传输的上下文关联。附件是引用XML文档的内容模型的内容ID URI(CID)存储在XML文档中的引用。
setAttachmentMarshaller 接口
Marshaller
public AttachmentMarshaller getAttachmentMarshaller()
getAttachmentMarshaller 接口
Marshaller
public void setListener(Marshaller.Listener listener)
Marshaller
这Marshaller登记事件回调Marshaller.Listener元帅。
有每指挥只有一个听众。设置一个侦听器替换前一个侦听器。一个可以注销当前听众通过设置监听器null。
setListener 接口
Marshaller
listener -实现了类的一个实例
Marshaller.Listener
public Marshaller.Listener getListener()
Marshaller
getListener 接口
Marshaller
Marshaller.Listener或
null如果没有监听器注册这个指挥。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.