Class Writer


  • public class Writer
    extends AWriter
    XML writer for conversion of objects to XML.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static javax.xml.stream.XMLOutputFactory FACTORY
      The xml output factory.
      protected boolean genids
      Control flag for generating ids.
      protected boolean indent
      Control flag for generating indention.
      protected boolean newline
      Control flag for generating newlines.
    • Constructor Summary

      Constructors 
      Constructor Description
      Writer()
      Create a new reader (with genids=true and indent=true).
      Writer​(boolean genids)
      Create a new reader (with genids=true and indent=true).
      Writer​(boolean genids, boolean indent, boolean newline)
      Create a new reader.
    • Field Detail

      • FACTORY

        protected static final javax.xml.stream.XMLOutputFactory FACTORY
        The xml output factory.
      • genids

        protected boolean genids
        Control flag for generating ids.
      • indent

        protected boolean indent
        Control flag for generating indention.
      • newline

        protected boolean newline
        Control flag for generating newlines.
    • Constructor Detail

      • Writer

        public Writer()
        Create a new reader (with genids=true and indent=true).
        Parameters:
        readerhandler - The handler.
      • Writer

        public Writer​(boolean genids)
        Create a new reader (with genids=true and indent=true).
        Parameters:
        readerhandler - The handler.
      • Writer

        public Writer​(boolean genids,
                      boolean indent,
                      boolean newline)
        Create a new reader.
        Parameters:
        readerhandler - The handler.
    • Method Detail

      • write

        public void write​(IObjectWriterHandler handler,
                          java.lang.Object object,
                          java.io.OutputStream out,
                          java.lang.ClassLoader classloader,
                          java.lang.Object context)
                   throws java.lang.Exception
        Write the properties to an xml.
        Overrides:
        write in class AWriter
        Parameters:
        input - The input stream.
        classloader - The classloader.
        context - The context.
        Throws:
        java.lang.Exception
      • write

        public void write​(IObjectWriterHandler handler,
                          java.lang.Object object,
                          java.lang.String encoding,
                          java.io.OutputStream out,
                          java.lang.ClassLoader classloader,
                          java.lang.Object context)
                   throws java.lang.Exception
        Write the properties to an xml.
        Specified by:
        write in class AWriter
        Parameters:
        input - The input stream.
        classloader - The classloader.
        context - The context.
        Throws:
        java.lang.Exception
      • writeObject

        protected void writeObject​(WriteContextDesktop wc,
                                   java.lang.Object object,
                                   QName tag)
                            throws java.lang.Exception
        Write an object to xml. Note: Must have tag parameter to support writing an object using an arbitrary tag. Cannot write tag in beforehand, because it must be written in one pass.
        Throws:
        java.lang.Exception
      • writeSubobjects

        protected void writeSubobjects​(WriteContextDesktop wc,
                                       TreeNode node,
                                       TypeInfo typeinfo)
                                throws java.lang.Exception
        Write the subobjects of an object.
        Throws:
        java.lang.Exception
      • writeStartObject

        protected void writeStartObject​(javax.xml.stream.XMLStreamWriter writer,
                                        QName tag,
                                        int level)
                                 throws java.lang.Exception
        Write the start of an object.
        Throws:
        java.lang.Exception
      • writeEndObject

        protected void writeEndObject​(javax.xml.stream.XMLStreamWriter writer,
                                      int level)
                               throws java.lang.Exception
        Write the end of an object.
        Throws:
        java.lang.Exception
      • writeIndentation

        protected void writeIndentation​(javax.xml.stream.XMLStreamWriter writer,
                                        int level)
                                 throws java.lang.Exception
        Write the indentation.
        Throws:
        java.lang.Exception
      • writeNewline

        protected void writeNewline​(javax.xml.stream.XMLStreamWriter writer)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getXMLPath

        protected QName[] getXMLPath​(java.util.List<StackElement> stack)
        Get the xml path for a stack.
        Parameters:
        stack - The stack.
        Returns:
        The string representig the xml stack (e.g. tag1/tag2/tag3)
      • getWriter

        public static javax.xml.stream.XMLStreamWriter getWriter​(AWriteContext context)