Class EcsvHeader


  • public class EcsvHeader
    extends java.lang.Object
    Represents the part of an ECSV file preceding the actual data lines.
    Since:
    28 Apr 2020
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      EcsvHeader​(java.lang.String[] yamlLines, java.lang.String namesLine)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getNamesLine()
      Returns the CSV-formatted line supposed to contain column names.
      java.lang.String[] getYamlLines()
      Returns the lines of YAML containing header information.
      static boolean isMagic​(byte[] intro)
      Indicates whether a byte sequence indicates the start of an ECSV file.
      static EcsvHeader readHeader​(LineReader rdr)
      Constructs an EcsvHeader instance by reading lines from a file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EcsvHeader

        public EcsvHeader​(java.lang.String[] yamlLines,
                          java.lang.String namesLine)
        Constructor.
        Parameters:
        yamlLines - lines of YAML containing header information; these lines exclude the leading "# " characters found in the ECSV file
        namesLine - first non-YAML line in the ECSV file, which is supposed to contain a redundant list of column names
    • Method Detail

      • getYamlLines

        public java.lang.String[] getYamlLines()
        Returns the lines of YAML containing header information. Leading "# " characters are not included.
        Returns:
        YAML text as array of lines
      • getNamesLine

        public java.lang.String getNamesLine()
        Returns the CSV-formatted line supposed to contain column names.
        Returns:
        column names line
      • readHeader

        public static EcsvHeader readHeader​(LineReader rdr)
                                     throws java.io.IOException,
                                            EcsvFormatException
        Constructs an EcsvHeader instance by reading lines from a file.
        Parameters:
        rdr - line reader returning input lines
        Returns:
        header instance
        Throws:
        java.io.IOException
        EcsvFormatException
      • isMagic

        public static boolean isMagic​(byte[] intro)
        Indicates whether a byte sequence indicates the start of an ECSV file.
        Parameters:
        intro - first few bytes of a file
        Returns:
        true iff file looks like ECSV