Java Doc for XMLSerializer.java in  » 6.0-JDK-Modules » jaxb-impl » com » sun » xml » bind » v2 » runtime » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » jaxb impl » com.sun.xml.bind.v2.runtime 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.xml.bind.v2.runtime.Coordinator
      com.sun.xml.bind.v2.runtime.XMLSerializer

XMLSerializer
final public class XMLSerializer extends Coordinator (Code)
Receives XML serialization event and writes to XmlOutput .

This object coordinates the overall marshalling efforts across different content-tree objects and different target formats.

The following CFG gives the proper sequence of method invocation.

 MARSHALLING  :=  ELEMENT
 ELEMENT      :=  "startElement" NSDECL* "endNamespaceDecls"
 ATTRIBUTE* "endAttributes" BODY "endElement"
 NSDECL       :=  "declareNamespace"
 ATTRIBUTE    :=  "attribute"
 ATTVALUES    :=  "text"*
 BODY         :=  ( "text" | ELEMENT )*
 

A marshalling of one element consists of two stages. The first stage is for marshalling attributes and collecting namespace declarations. The second stage is for marshalling characters/child elements of that element.

Observe that multiple invocation of "text" is allowed.

Also observe that the namespace declarations are allowed only between "startElement" and "endAttributes".

Exceptions in marshaller

IOException , SAXException , and XMLStreamException are thrown from XmlOutput . They are always considered fatal, and therefore caught only by MarshallerImpl .

AccessorException can be thrown when an access to a property/field fails, and this is considered as a recoverable error, so it's caught everywhere.
author:
   Kohsuke Kawaguchi



Field Summary
public  AttachmentMarshallerattachmentMarshaller
    
final public  JAXBContextImplgrammar
    
final public  int[]knownUri2prefixIndexMap
    
final public  NameListnameList
    

Constructor Summary
 XMLSerializer(MarshallerImpl _owner)
    

Method Summary
public  voidaddInscopeBinding(String nsUri, String prefix)
     This method can be called after XMLSerializer.startDocument is called but before the marshalling begins, to set the currently in-scope namespace bindings.
public  voidattWildcardAsAttributes(Map<QName, String> attributes, String fieldName)
    
public  voidattWildcardAsURIs(Map<QName, String> attributes, String fieldName)
    
public  voidattribute(String uri, String local, String value)
    
public  voidattribute(Name name, CharSequence value)
    
public  voidchildAsRoot(Object obj)
    
final public  voidchildAsSoleContent(Object child, String fieldName)
     The equivalent of:
 childAsURIs(child, fieldName);
 endNamespaceDecls();
 childAsAttributes(child, fieldName);
 endAttributes();
 childAsBody(child, fieldName);
 
This produces the given child object as the sole content of an element.
final public  voidchildAsXsiType(Object child, String fieldName, JaxBeanInfo expected)
     This method is called when a type child object is found.

This method produces events of the following form:

 NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODY
 
optionally including @xsi:type if necessary.
Parameters:
  child - Object to be marshalled.
public  voidclose()
    
public  voidendAttributes()
     Switches to the "marshal child texts/elements" mode.
public  voidendDocument()
    
public  voidendElement()
     Ends marshalling of an element.
public  voidendNamespaceDecls(Object innerPeer)
    
public  voiderrorMissingId(Object obj)
     Called when a referenced object doesn't have an ID.
public  Base64DatagetCachedBase64DataInstance()
     Gets the cached instance of Base64Data .
public  ValidationEventLocatorgetCurrentLocation(String fieldName)
    
public  TransformergetIdentityTransformer()
    
public  booleangetInlineBinaryFlag()
    
public static  XMLSerializergetInstance()
     When called from within the realm of the marshaller, this method returns the current XMLSerializer in charge.
protected  ValidationEventLocatorgetLocation()
    
public  NamespaceContext2getNamespaceContext()
    
public  booleangetObjectIdentityCycleDetection()
    
public  QNamegetSchemaType()
    
public  StringgetXMIMEContentType()
     Gets the MIME type with which the binary content shall be printed.
public  booleanhandleError(Exception e)
    
public  booleanhandleError(Exception e, Object source, String fieldName)
    
public  booleanhandleEvent(ValidationEvent event)
    
public  voidleafElement(Name tagName, String data, String fieldName)
    
public  voidleafElement(Name tagName, Pcdata data, String fieldName)
    
public  voidleafElement(Name tagName, int data, String fieldName)
    
public  StringonID(Object owner, String value)
    
public  StringonIDREF(Object obj)
    
 voidreconcileID()
    
public  voidreportError(ValidationEvent ve)
    
final public  voidreportError(String fieldName, Throwable t)
     Report an error found as an exception.
public  MimeTypesetExpectedMimeType(MimeType expectedMimeType)
     This method is used by MimeTypedTransducer to set the expected MIME type for the encapsulated Transducer .
public  booleansetInlineBinaryFlag(boolean value)
    
public  voidsetObjectIdentityCycleDetection(boolean val)
    
public  voidsetPrefixMapper(NamespacePrefixMapper prefixMapper)
    
public  QNamesetSchemaType(QName st)
    
public  voidstartDocument(XmlOutput out, boolean fragment, String schemaLocation, String noNsSchemaLocation)
     Reset this object to write to the specified output.
public  voidstartElement(Name tagName, Object outerPeer)
    
public  voidstartElement(String nsUri, String localName, String preferredPrefix, Object outerPeer)
    
public  voidstartElementForce(String nsUri, String localName, String forcedPrefix, Object outerPeer)
     Variation of XMLSerializer.startElement(String,String,String,Object) that forces a specific prefix.
public  voidtext(String text, String fieldName)
     Marshalls text.

This method can be called after the XMLSerializer.endAttributes() method to marshal texts inside elements. If the method is called more than once, those texts are considered as separated by whitespaces.

public  voidtext(Pcdata text, String fieldName)
     The XMLSerializer.text(String,String) method that takes Pcdata .
public  voidwriteDom(E element, DomHandler<E, ?> domHandler, Object parentBean, String fieldName)
    
final public  voidwriteXsiNilTrue()
    

Field Detail
attachmentMarshaller
public AttachmentMarshaller attachmentMarshaller(Code)



grammar
final public JAXBContextImpl grammar(Code)



knownUri2prefixIndexMap
final public int[] knownUri2prefixIndexMap(Code)



nameList
final public NameList nameList(Code)




Constructor Detail
XMLSerializer
XMLSerializer(MarshallerImpl _owner)(Code)




Method Detail
addInscopeBinding
public void addInscopeBinding(String nsUri, String prefix)(Code)
This method can be called after XMLSerializer.startDocument is called but before the marshalling begins, to set the currently in-scope namespace bindings.

This method is useful to avoid redundant namespace declarations when the marshalling is producing a sub-document.




attWildcardAsAttributes
public void attWildcardAsAttributes(Map<QName, String> attributes, String fieldName) throws SAXException(Code)



attWildcardAsURIs
public void attWildcardAsURIs(Map<QName, String> attributes, String fieldName)(Code)



attribute
public void attribute(String uri, String local, String value) throws SAXException(Code)



attribute
public void attribute(Name name, CharSequence value) throws IOException, XMLStreamException(Code)



childAsRoot
public void childAsRoot(Object obj) throws JAXBException, IOException, SAXException, XMLStreamException(Code)



childAsSoleContent
final public void childAsSoleContent(Object child, String fieldName) throws SAXException, IOException, XMLStreamException(Code)
The equivalent of:
 childAsURIs(child, fieldName);
 endNamespaceDecls();
 childAsAttributes(child, fieldName);
 endAttributes();
 childAsBody(child, fieldName);
 
This produces the given child object as the sole content of an element. Used to reduce the code size in the generated marshaller.



childAsXsiType
final public void childAsXsiType(Object child, String fieldName, JaxBeanInfo expected) throws SAXException, IOException, XMLStreamException(Code)
This method is called when a type child object is found.

This method produces events of the following form:

 NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODY
 
optionally including @xsi:type if necessary.
Parameters:
  child - Object to be marshalled. The JaxBeanInfo forthis object must return a type name.
Parameters:
  expected - Expected type of the object.
Parameters:
  fieldName - property name of the parent objeect from which 'o' comes.Used as a part of the error message in case anything goes wrongwith 'o'.



close
public void close()(Code)



endAttributes
public void endAttributes() throws SAXException, IOException, XMLStreamException(Code)
Switches to the "marshal child texts/elements" mode. This method has to be called after the 1st pass is completed.



endDocument
public void endDocument() throws IOException, SAXException, XMLStreamException(Code)



endElement
public void endElement() throws SAXException, IOException, XMLStreamException(Code)
Ends marshalling of an element. Pops the internal stack.



endNamespaceDecls
public void endNamespaceDecls(Object innerPeer) throws IOException, XMLStreamException(Code)



errorMissingId
public void errorMissingId(Object obj) throws SAXException(Code)
Called when a referenced object doesn't have an ID.



getCachedBase64DataInstance
public Base64Data getCachedBase64DataInstance()(Code)
Gets the cached instance of Base64Data . Base64Data



getCurrentLocation
public ValidationEventLocator getCurrentLocation(String fieldName)(Code)



getIdentityTransformer
public Transformer getIdentityTransformer()(Code)



getInlineBinaryFlag
public boolean getInlineBinaryFlag()(Code)



getInstance
public static XMLSerializer getInstance()(Code)
When called from within the realm of the marshaller, this method returns the current XMLSerializer in charge.



getLocation
protected ValidationEventLocator getLocation()(Code)



getNamespaceContext
public NamespaceContext2 getNamespaceContext()(Code)



getObjectIdentityCycleDetection
public boolean getObjectIdentityCycleDetection()(Code)



getSchemaType
public QName getSchemaType()(Code)



getXMIMEContentType
public String getXMIMEContentType()(Code)
Gets the MIME type with which the binary content shall be printed.

This method shall be used from those RuntimeBuiltinLeafInfo that are bound to base64Binary.
See Also:   JAXBContextImpl.getXMIMEContentType(Object)




handleError
public boolean handleError(Exception e)(Code)



handleError
public boolean handleError(Exception e, Object source, String fieldName)(Code)



handleEvent
public boolean handleEvent(ValidationEvent event)(Code)



leafElement
public void leafElement(Name tagName, String data, String fieldName) throws SAXException, IOException, XMLStreamException(Code)



leafElement
public void leafElement(Name tagName, Pcdata data, String fieldName) throws SAXException, IOException, XMLStreamException(Code)



leafElement
public void leafElement(Name tagName, int data, String fieldName) throws SAXException, IOException, XMLStreamException(Code)



onID
public String onID(Object owner, String value)(Code)



onIDREF
public String onIDREF(Object obj) throws SAXException(Code)



reconcileID
void reconcileID() throws SAXException(Code)



reportError
public void reportError(ValidationEvent ve) throws SAXException(Code)



reportError
final public void reportError(String fieldName, Throwable t) throws SAXException(Code)
Report an error found as an exception.
Parameters:
  fieldName - the name of the property being processed when an error is found.



setExpectedMimeType
public MimeType setExpectedMimeType(MimeType expectedMimeType)(Code)
This method is used by MimeTypedTransducer to set the expected MIME type for the encapsulated Transducer .



setInlineBinaryFlag
public boolean setInlineBinaryFlag(boolean value)(Code)



setObjectIdentityCycleDetection
public void setObjectIdentityCycleDetection(boolean val)(Code)



setPrefixMapper
public void setPrefixMapper(NamespacePrefixMapper prefixMapper)(Code)



setSchemaType
public QName setSchemaType(QName st)(Code)



startDocument
public void startDocument(XmlOutput out, boolean fragment, String schemaLocation, String noNsSchemaLocation) throws IOException, SAXException, XMLStreamException(Code)
Reset this object to write to the specified output.
Parameters:
  schemaLocation - if non-null, this value is printed on the root element as xsi:schemaLocation
Parameters:
  noNsSchemaLocation - Similar to 'schemaLocation' but this one works for xsi:noNamespaceSchemaLocation



startElement
public void startElement(Name tagName, Object outerPeer)(Code)



startElement
public void startElement(String nsUri, String localName, String preferredPrefix, Object outerPeer)(Code)



startElementForce
public void startElementForce(String nsUri, String localName, String forcedPrefix, Object outerPeer)(Code)
Variation of XMLSerializer.startElement(String,String,String,Object) that forces a specific prefix. Needed to preserve the prefix when marshalling DOM.



text
public void text(String text, String fieldName) throws SAXException, IOException, XMLStreamException(Code)
Marshalls text.

This method can be called after the XMLSerializer.endAttributes() method to marshal texts inside elements. If the method is called more than once, those texts are considered as separated by whitespaces. For example,

 c.startElement("","foo");
 c.endAttributes();
 c.text("abc");
 c.text("def");
 c.startElement("","bar");
 c.endAttributes();
 c.endElement();
 c.text("ghi");
 c.endElement();
 
will generate <foo>abc def<bar/>ghi</foo>.



text
public void text(Pcdata text, String fieldName) throws SAXException, IOException, XMLStreamException(Code)
The XMLSerializer.text(String,String) method that takes Pcdata .



writeDom
public void writeDom(E element, DomHandler<E, ?> domHandler, Object parentBean, String fieldName) throws SAXException(Code)



writeXsiNilTrue
final public void writeXsiNilTrue() throws SAXException, IOException, XMLStreamException(Code)
Short for the following call sequence:
 getNamespaceContext().declareNamespace(WellKnownNamespace.XML_SCHEMA_INSTANCE,"xsi",true);
 endNamespaceDecls();
 attribute(WellKnownNamespace.XML_SCHEMA_INSTANCE,"nil","true");
 endAttributes();
 



Fields inherited from com.sun.xml.bind.v2.runtime.Coordinator
public static boolean debugTableNPE(Code)(Java Doc)
public Exception guyWhoSetTheTableToNull(Code)(Java Doc)

Methods inherited from com.sun.xml.bind.v2.runtime.Coordinator
public static Coordinator _getInstance()(Code)(Java Doc)
public boolean containsAdapter(Class<T> type)(Code)(Java Doc)
final public void error(SAXParseException exception) throws SAXException(Code)(Java Doc)
final public void fatalError(SAXParseException exception) throws SAXException(Code)(Java Doc)
final public T getAdapter(Class<T> key)(Code)(Java Doc)
abstract protected ValidationEventLocator getLocation()(Code)(Java Doc)
final protected void popCoordinator()(Code)(Java Doc)
final protected void pushCoordinator()(Code)(Java Doc)
final public XmlAdapter putAdapter(Class<? extends XmlAdapter> c, XmlAdapter a)(Code)(Java Doc)
final protected void resetThreadAffinity()(Code)(Java Doc)
final protected void setThreadAffinity()(Code)(Java Doc)
final public void warning(SAXParseException exception) throws SAXException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.