Package org.jooq

Interface Formattable

  • All Known Subinterfaces:
    Cursor<R>, EmbeddableRecord<R>, Record, Record1<T1>, Record10<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10>, Record11<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11>, Record12<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12>, Record13<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13>, Record14<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14>, Record15<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15>, Record16<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16>, Record17<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17>, Record18<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18>, Record19<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18,​T19>, Record2<T1,​T2>, Record20<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18,​T19,​T20>, Record21<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18,​T19,​T20,​T21>, Record22<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9,​T10,​T11,​T12,​T13,​T14,​T15,​T16,​T17,​T18,​T19,​T20,​T21,​T22>, Record3<T1,​T2,​T3>, Record4<T1,​T2,​T3,​T4>, Record5<T1,​T2,​T3,​T4,​T5>, Record6<T1,​T2,​T3,​T4,​T5,​T6>, Record7<T1,​T2,​T3,​T4,​T5,​T6,​T7>, Record8<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8>, Record9<T1,​T2,​T3,​T4,​T5,​T6,​T7,​T8,​T9>, Result<R>, TableRecord<R>, UDTRecord<R>, UpdatableRecord<R>
    All Known Implementing Classes:
    ArrayRecordImpl, CustomRecord, EmbeddableRecordImpl, TableRecordImpl, UDTRecordImpl, UpdatableRecordImpl

    public interface Formattable
    A type that can format its contents.

    This type provides a common interface for Result and Cursor formatting functionality, which includes formatting results to:

    • Charts
    • CSV
    • HTML
    • INSERT statements
    • JSON
    • Text
    • XML

    Calling formatting methods on a Result is repeatable as the Result has been previously materialised in memory and the database resource is closed. Calling these methods on a Cursor is not repeatable as the Cursor (and the underlying JDBC ResultSet) is consumed entirely, and closed eagerly after consumption.

    Author:
    Lukas Eder
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String format()
      Get a simple formatted representation of this result.
      java.lang.String format​(int maxRecords)
      Get a simple formatted representation of this result.
      void format​(java.io.OutputStream stream)
      Like format(), but the data is output onto an OutputStream.
      void format​(java.io.OutputStream stream, int maxRecords)
      Like format(int), but the data is output onto an OutputStream.
      void format​(java.io.OutputStream stream, TXTFormat format)
      Like format(TXTFormat), but the data is output onto an OutputStream.
      void format​(java.io.Writer writer)
      Like format(), but the data is output onto a Writer.
      void format​(java.io.Writer writer, int maxRecords)
      Like format(int), but the data is output onto a Writer.
      void format​(java.io.Writer writer, TXTFormat format)
      Like format(TXTFormat), but the data is output onto a Writer.
      java.lang.String format​(TXTFormat format)
      Get a simple formatted representation of this result.
      java.lang.String formatChart()  
      void formatChart​(java.io.OutputStream stream)
      Like formatChart(), but the data is output onto an OutputStream.
      void formatChart​(java.io.OutputStream stream, ChartFormat format)
      Like formatChart(ChartFormat), but the data is output onto an OutputStream.
      void formatChart​(java.io.Writer writer)
      Like formatChart(), but the data is output onto a Writer.
      void formatChart​(java.io.Writer writer, ChartFormat format)
      Like formatChart(ChartFormat), but the data is output onto a Writer.
      java.lang.String formatChart​(ChartFormat format)  
      java.lang.String formatCSV()
      Get a simple formatted representation of this result as CSV.
      java.lang.String formatCSV​(boolean header)
      Get a simple formatted representation of this result as CSV.
      java.lang.String formatCSV​(boolean header, char delimiter)
      Get a simple formatted representation of this result as CSV.
      java.lang.String formatCSV​(boolean header, char delimiter, java.lang.String nullString)
      Get a simple formatted representation of this result as CSV.
      java.lang.String formatCSV​(char delimiter)
      Get a simple formatted representation of this result as CSV.
      java.lang.String formatCSV​(char delimiter, java.lang.String nullString)
      Get a simple formatted representation of this result as CSV.
      void formatCSV​(java.io.OutputStream stream)
      Like formatCSV(), but the data is output onto an OutputStream.
      void formatCSV​(java.io.OutputStream stream, boolean header)
      Like formatCSV(boolean), but the data is output onto an OutputStream.
      void formatCSV​(java.io.OutputStream stream, boolean header, char delimiter)
      Like formatCSV(boolean, char), but the data is output onto an OutputStream.
      void formatCSV​(java.io.OutputStream stream, boolean header, char delimiter, java.lang.String nullString)
      Like formatCSV(boolean, char, String), but the data is output onto an OutputStream.
      void formatCSV​(java.io.OutputStream stream, char delimiter)
      Like formatCSV(char), but the data is output onto an OutputStream.
      void formatCSV​(java.io.OutputStream stream, char delimiter, java.lang.String nullString)
      Like formatCSV(char, String), but the data is output onto an OutputStream.
      void formatCSV​(java.io.OutputStream stream, CSVFormat format)
      Like formatCSV(CSVFormat), but the data is output onto an OutputStream.
      void formatCSV​(java.io.Writer writer)
      Like formatCSV(), but the data is output onto a Writer.
      void formatCSV​(java.io.Writer writer, boolean header)
      Like formatCSV(boolean), but the data is output onto a Writer.
      void formatCSV​(java.io.Writer writer, boolean header, char delimiter)
      Like formatCSV(boolean, char), but the data is output onto a Writer.
      void formatCSV​(java.io.Writer writer, boolean header, char delimiter, java.lang.String nullString)
      Like formatCSV(boolean, char, String), but the data is output onto a Writer.
      void formatCSV​(java.io.Writer writer, char delimiter)
      Like formatCSV(char), but the data is output onto a Writer.
      void formatCSV​(java.io.Writer writer, char delimiter, java.lang.String nullString)
      Like formatCSV(char, String), but the data is output onto a Writer.
      void formatCSV​(java.io.Writer writer, CSVFormat format)
      Like formatCSV(CSVFormat), but the data is output onto a Writer.
      java.lang.String formatCSV​(CSVFormat format)
      Get a simple formatted representation of this result as CSV.
      java.lang.String formatHTML()
      Get a simple formatted representation of this result as HTML.
      void formatHTML​(java.io.OutputStream stream)
      Like formatHTML(), but the data is output onto an OutputStream.
      void formatHTML​(java.io.Writer writer)
      Like formatHTML(), but the data is output onto a Writer.
      java.lang.String formatInsert()
      Get this result as a set of INSERT statements.
      void formatInsert​(java.io.OutputStream stream)
      Like formatInsert(), but the data is output onto an OutputStream.
      void formatInsert​(java.io.OutputStream stream, Table<?> table, Field<?>... fields)
      Like formatInsert(Table, Field...), but the data is output onto an OutputStream.
      void formatInsert​(java.io.Writer writer)
      Like formatInsert(), but the data is output onto a Writer.
      void formatInsert​(java.io.Writer writer, Table<?> table, Field<?>... fields)
      Like formatInsert(Table, Field...), but the data is output onto an Writer.
      java.lang.String formatInsert​(Table<?> table, Field<?>... fields)
      Get this result as a set of INSERT statements.
      java.lang.String formatJSON()
      Get a simple formatted representation of this result as a JSON array of array.
      void formatJSON​(java.io.OutputStream stream)
      Like formatJSON(), but the data is output onto an OutputStream.
      void formatJSON​(java.io.OutputStream stream, JSONFormat format)
      Like formatJSON(JSONFormat), but the data is output onto an OutputStream.
      void formatJSON​(java.io.Writer writer)
      Like formatJSON(), but the data is output onto a Writer.
      void formatJSON​(java.io.Writer writer, JSONFormat format)
      Like formatJSON(JSONFormat), but the data is output onto a Writer.
      java.lang.String formatJSON​(JSONFormat format)
      Get a simple formatted representation of this result as a JSON data structure, according to the format.
      java.lang.String formatXML()
      Get this result formatted as XML.
      void formatXML​(java.io.OutputStream stream)
      Like formatXML(), but the data is output onto an OutputStream.
      void formatXML​(java.io.OutputStream stream, XMLFormat format)
      Like formatXML(XMLFormat), but the data is output onto an OutputStream.
      void formatXML​(java.io.Writer writer)
      Like formatXML(), but the data is output onto a Writer.
      void formatXML​(java.io.Writer writer, XMLFormat format)
      Like formatXML(XMLFormat), but the data is output onto a Writer.
      java.lang.String formatXML​(XMLFormat format)
      Get this result formatted as XML.
      org.w3c.dom.Document intoXML()
      Get this result as XML.
      <H extends org.xml.sax.ContentHandler>
      H
      intoXML​(H handler)
      Get this result as XML using a SAX ContentHandler.
      <H extends org.xml.sax.ContentHandler>
      H
      intoXML​(H handler, XMLFormat format)
      Get this result as XML using a SAX ContentHandler.
      org.w3c.dom.Document intoXML​(XMLFormat format)
      Get this result as XML.
    • Method Detail

      • format

        java.lang.String format()
        Get a simple formatted representation of this result.

        This is the same as calling format(int) with maxRows = Integer.MAX_VALUE

        Returns:
        The formatted result
      • format

        java.lang.String format​(int maxRecords)
        Get a simple formatted representation of this result.
        Parameters:
        maxRecords - The maximum number of records to include in the formatted result
        Returns:
        The formatted result
      • format

        java.lang.String format​(TXTFormat format)
        Get a simple formatted representation of this result.
        Parameters:
        format - The formatting information
        Returns:
        The formatted result
      • formatHTML

        java.lang.String formatHTML()
        Get a simple formatted representation of this result as HTML.

        The HTML code is formatted as follows:

         <table>
           <thead>
             <tr>
               <th>field-1</th>
               <th>field-2</th>
               ...
               <th>field-n</th>
             </tr>
           </thead>
           <tbody>
             <tr>
               <th>value-1-1</th>
               <th>value-1-2</th>
               ...
               <th>value-1-n</th>
             </tr>
             <tr>
               <th>value-2-1</th>
               <th>value-2-2</th>
               ...
               <th>value-2-n</th>
             </tr>
             ...
           </tbody>
         </table>
         
        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV()
        Get a simple formatted representation of this result as CSV.

        This is the same as calling formatCSV(true, ',', "")

        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV​(char delimiter)
        Get a simple formatted representation of this result as CSV.

        This is the same as calling formatCSV(true, delimiter, "")

        Parameters:
        delimiter - The delimiter to use between records
        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV​(char delimiter,
                                   java.lang.String nullString)
        Get a simple formatted representation of this result as CSV.

        This is the same as calling formatCSV(true, delimiter, nullString)

        Parameters:
        delimiter - The delimiter to use between records
        nullString - A special string for encoding NULL values.
        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV​(boolean header)
        Get a simple formatted representation of this result as CSV.

        This is the same as calling formatCSV(',', "")

        Parameters:
        header - Whether to emit a CSV header line
        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV​(boolean header,
                                   char delimiter)
        Get a simple formatted representation of this result as CSV.

        This is the same as calling formatCSV(delimiter, "")

        Parameters:
        header - Whether to emit a CSV header line
        delimiter - The delimiter to use between records
        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV​(boolean header,
                                   char delimiter,
                                   java.lang.String nullString)
        Get a simple formatted representation of this result as CSV.
        Parameters:
        header - Whether to emit a CSV header line
        delimiter - The delimiter to use between records
        nullString - A special string for encoding NULL values.
        Returns:
        The formatted result
      • formatCSV

        java.lang.String formatCSV​(CSVFormat format)
        Get a simple formatted representation of this result as CSV.
        Returns:
        The formatted result
      • formatJSON

        java.lang.String formatJSON()
        Get a simple formatted representation of this result as a JSON array of array.

        The format is the following:

         {"fields":[{"name":"field-1","type":"type-1"},
                    {"name":"field-2","type":"type-2"},
                    ...,
                    {"name":"field-n","type":"type-n"}],
          "records":[[value-1-1,value-1-2,...,value-1-n],
                     [value-2-1,value-2-2,...,value-2-n]]}
         
        Returns:
        The formatted result
      • formatJSON

        java.lang.String formatJSON​(JSONFormat format)
        Get a simple formatted representation of this result as a JSON data structure, according to the format.
        Returns:
        The formatted result
        See Also:
        JSONFormat
      • formatChart

        java.lang.String formatChart()
      • formatChart

        java.lang.String formatChart​(ChartFormat format)
      • formatInsert

        java.lang.String formatInsert()
        Get this result as a set of INSERT statements.

        This uses the the first record's TableRecord.getTable(), if the first record is a TableRecord. Otherwise, this generates INSERT statements into an "UNKNOWN_TABLE". In both cases, the Result.fields() are used for column names.

      • formatInsert

        java.lang.String formatInsert​(Table<?> table,
                                      Field<?>... fields)
        Get this result as a set of INSERT statements.

        This explicitly specifies the table (and optionally the fields) to insert into. If the fields argument is left empty, the Result.fields() are used, instead.

      • format

        void format​(java.io.OutputStream stream)
             throws IOException
        Like format(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • format

        void format​(java.io.OutputStream stream,
                    int maxRecords)
             throws IOException
        Like format(int), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • format

        void format​(java.io.OutputStream stream,
                    TXTFormat format)
             throws IOException
        Like format(TXTFormat), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatHTML

        void formatHTML​(java.io.OutputStream stream)
                 throws IOException
        Like formatHTML(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream)
                throws IOException
        Like formatCSV(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream,
                       char delimiter)
                throws IOException
        Like formatCSV(char), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream,
                       char delimiter,
                       java.lang.String nullString)
                throws IOException
        Like formatCSV(char, String), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream,
                       boolean header)
                throws IOException
        Like formatCSV(boolean), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream,
                       boolean header,
                       char delimiter)
                throws IOException
        Like formatCSV(boolean, char), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream,
                       boolean header,
                       char delimiter,
                       java.lang.String nullString)
                throws IOException
        Like formatCSV(boolean, char, String), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.OutputStream stream,
                       CSVFormat format)
                throws IOException
        Like formatCSV(CSVFormat), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatJSON

        void formatJSON​(java.io.OutputStream stream)
                 throws IOException
        Like formatJSON(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatXML

        void formatXML​(java.io.OutputStream stream)
                throws IOException
        Like formatXML(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatXML

        void formatXML​(java.io.OutputStream stream,
                       XMLFormat format)
                throws IOException
        Like formatXML(XMLFormat), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatChart

        void formatChart​(java.io.OutputStream stream)
                  throws IOException
        Like formatChart(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatInsert

        void formatInsert​(java.io.OutputStream stream)
                   throws IOException
        Like formatInsert(), but the data is output onto an OutputStream.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • format

        void format​(java.io.Writer writer)
             throws IOException
        Like format(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • format

        void format​(java.io.Writer writer,
                    int maxRecords)
             throws IOException
        Like format(int), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatHTML

        void formatHTML​(java.io.Writer writer)
                 throws IOException
        Like formatHTML(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.Writer writer)
                throws IOException
        Like formatCSV(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.Writer writer,
                       char delimiter)
                throws IOException
        Like formatCSV(char), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.Writer writer,
                       char delimiter,
                       java.lang.String nullString)
                throws IOException
        Like formatCSV(char, String), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.Writer writer,
                       boolean header)
                throws IOException
        Like formatCSV(boolean), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.Writer writer,
                       boolean header,
                       char delimiter)
                throws IOException
        Like formatCSV(boolean, char), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatCSV

        void formatCSV​(java.io.Writer writer,
                       boolean header,
                       char delimiter,
                       java.lang.String nullString)
                throws IOException
        Like formatCSV(boolean, char, String), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatJSON

        void formatJSON​(java.io.Writer writer)
                 throws IOException
        Like formatJSON(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatXML

        void formatXML​(java.io.Writer writer)
                throws IOException
        Like formatXML(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatChart

        void formatChart​(java.io.Writer writer)
                  throws IOException
        Like formatChart(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • formatInsert

        void formatInsert​(java.io.Writer writer)
                   throws IOException
        Like formatInsert(), but the data is output onto a Writer.
        Throws:
        IOException - - an unchecked wrapper for IOException, if anything goes wrong.
      • intoXML

        <H extends org.xml.sax.ContentHandler> H intoXML​(H handler)
                                                  throws org.xml.sax.SAXException
        Get this result as XML using a SAX ContentHandler.
        Parameters:
        handler - The custom content handler.
        Returns:
        The argument content handler is returned for convenience.
        Throws:
        org.xml.sax.SAXException
        See Also:
        formatXML(), http://www.jooq.org/xsd/jooq-export-3.10.0.xsd
      • intoXML

        <H extends org.xml.sax.ContentHandler> H intoXML​(H handler,
                                                         XMLFormat format)
                                                  throws org.xml.sax.SAXException
        Get this result as XML using a SAX ContentHandler.
        Parameters:
        handler - The custom content handler.
        Returns:
        The argument content handler is returned for convenience.
        Throws:
        org.xml.sax.SAXException
        See Also:
        formatXML(), http://www.jooq.org/xsd/jooq-export-3.10.0.xsd