Class YamlDataSet

All Implemented Interfaces:
IDataSet, IDataSetConsumer

public class YamlDataSet extends CachedDataSet
Reads and writes flat YAML-based dataset documents. Contrary to the flat XML layout, columns are calculated by parsing the entire data set, not just the first row.

The format looks like this:
 <table_name>:
   - <column>: <value>
     <column>: <value>
             ...
   - <column>: <value>
     <column>: <value>
             ...
        ...
    ...
 

I.e.:
 TEST_TABLE:
   - COL0: "row 0 col 0"
     COL1: "row 0 col 1"
     COL2: "row 0 col 2"
   - COL1: "row 1 col 1"
 SECOND_TABLE:
   - COL0: "row 0 col 0"
     COL1: "row 0 col 1"
 EMPTY_TABLE: []
 
Version:
$Revision$ $Date$
Author:
Björn Beskow
  • Constructor Details

    • YamlDataSet

      public YamlDataSet(File file) throws IOException, DataSetException
      Creates a YAML dataset based on a yaml file
      Parameters:
      file - the YAML file to load.
      Throws:
      IOException - if the file cannot be read.
      DataSetException - if the document cannot be parsed.
    • YamlDataSet

      public YamlDataSet(InputStream inputStream) throws DataSetException
      Creates a YAML dataset based on an inputstream
      Parameters:
      inputStream - An inputstream pointing to a YAML dataset
      Throws:
      DataSetException - if the document cannot be parsed.
  • Method Details

    • write

      public static void write(IDataSet dataSet, OutputStream out) throws DataSetException
      Writes the specified dataset to the specified output stream as YAML, encoded in UTF-8, matching what YamlProducer decodes.
      Parameters:
      dataSet - the dataset to write.
      out - the stream to write the YAML document to.
      Throws:
      DataSetException - if the dataset cannot be read.
    • write

      public static void write(IDataSet dataSet, Writer out) throws DataSetException
      Write the specified dataset to the specified writer as YAML.
      Parameters:
      dataSet - the dataset to write.
      out - the writer to write the YAML document to.
      Throws:
      DataSetException - if the dataset cannot be read.