Class Cif2DataParser

java.lang.Object
javajs.util.CifDataParser
org.jmol.adapter.readers.cif.Cif2DataParser
All Implemented Interfaces:
javajs.api.GenericCifDataParser

public class Cif2DataParser extends javajs.util.CifDataParser
Fully implemented 2016.12.1 see http://journals.iucr.org/j/issues/2016/01/00/aj5269/index.html Will deliver JSON versions of the data while file reading and Java List/Map structures when called by x = getProperty("cifInfo", filename) Validated using the test-data suite by John Bollinger (John.Bollinger@stjude.org) found at https://github.com/COMCIFS/cif_api
Author:
Bob Hanson hansonr@stolaf.edu
  • Field Summary

    Fields inherited from class javajs.util.CifDataParser

    asObject, cch, cterm, debugging, ich, KEY_MAX, line, nullString, str, wasUnquoted

    Fields inherited from interface javajs.api.GenericCifDataParser

    NONE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private String
    allow white space between \ and \n
    static double[]
    turn "[1,2,3]" into [1.0,2.0,3.0] array will be truncated to n elements, or filled with zeros to pad to n, as necessary.
    static int[]
    turn "[1,2,3]" into [1,2,3] array will be truncated to n elements, or filled with zeros to pad to n, as necessary.
    protected Object
    final get for quoted object
    protected int
     
    protected boolean
    isQuote(char ch)
    Includes all possible operator tokens
    private boolean
    isSpaceOrColon(int ich)
    used by readTable
    protected String
    initial processing; returns a string bounded by \1
    private Object
    Handle all forms of quotation, including '...', "...", '''...''', """...""", and ;...\n...\n;
    protected String
    Sets a multiline semicolon-eclipsed string to be parsed from the beginning, allowing for CIF 2.0-type prefixed text lines and removing line folding.
    Read a CIF 2.0 table into either a JSON string or a java data structure
    There is no need to convert to unicode in CIF 2.0.
    protected Object
    Handle unquoted value as Integer or Float if we can.

    Methods inherited from class javajs.util.CifDataParser

    fixKey, fullTrim, getAllCifData, getColumnCount, getColumnData, getColumnName, getData, getFileHeader, getNextDataToken, getNextToken, getNextTokenObject, getNextTokenProtected, getTokenPeeked, isTerminator, parseDataBlockParameters, peekToken, prepareNextLine, preprocessSemiString, readLine, readList, set, setNullValue, setString, skipLoop, skipNextToken

    Methods inherited from class java.lang.Object

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

    • Cif2DataParser

      public Cif2DataParser()
  • Method Details

    • getVersion

      protected int getVersion()
      Overrides:
      getVersion in class javajs.util.CifDataParser
    • toUnicode

      public String toUnicode(String data)
      There is no need to convert to unicode in CIF 2.0.
      Specified by:
      toUnicode in interface javajs.api.GenericCifDataParser
      Overrides:
      toUnicode in class javajs.util.CifDataParser
      Parameters:
      data -
      Returns:
      cleaned string
    • isQuote

      protected boolean isQuote(char ch)
      Includes all possible operator tokens
      Overrides:
      isQuote in class javajs.util.CifDataParser
      Parameters:
      ch -
      Returns:
      true if this character is a (starting) quote
    • getQuotedStringOrObject

      protected Object getQuotedStringOrObject(char ch)
      final get for quoted object
      Overrides:
      getQuotedStringOrObject in class javajs.util.CifDataParser
      Parameters:
      ch - current character being pointed to
      Returns:
      a String data object
    • preprocessString

      protected String preprocessString() throws Exception
      initial processing; returns a string bounded by \1
      Overrides:
      preprocessString in class javajs.util.CifDataParser
      Returns:
      escaped part with attached extra data
      Throws:
      Exception
    • processQuotedString

      private Object processQuotedString()
      Handle all forms of quotation, including '...', "...", '''...''', """...""", and ;...\n...\n;
      Returns:
      a string or data structure, depending upon setting asObject
    • processSemiString

      protected String processSemiString() throws Exception
      Sets a multiline semicolon-eclipsed string to be parsed from the beginning, allowing for CIF 2.0-type prefixed text lines and removing line folding. ;xxxx\comments here xxxx xxxx xxxx ;
      Returns:
      \1...quote....\1
      Throws:
      Exception
    • readTable

      public Object readTable() throws Exception
      Read a CIF 2.0 table into either a JSON string or a java data structure
      Returns:
      an Object or String, depending upon settings
      Throws:
      Exception
    • isSpaceOrColon

      private boolean isSpaceOrColon(int ich)
      used by readTable
      Parameters:
      ich - buffer pointer
      Returns:
      true if whitespace or colon
    • unquoted

      protected Object unquoted(String s)
      Handle unquoted value as Integer or Float if we can.
      Overrides:
      unquoted in class javajs.util.CifDataParser
      Parameters:
      s - unquoted string
      Returns:
      unchanged value
    • fixLineFolding

      private String fixLineFolding(String str)
      allow white space between \ and \n
      Parameters:
      str - already enclosed in \1.....\1
      Returns:
      fixed line
    • getArrayFromStringList

      public static double[] getArrayFromStringList(String s, int n)
      turn "[1,2,3]" into [1.0,2.0,3.0] array will be truncated to n elements, or filled with zeros to pad to n, as necessary.
      Parameters:
      s -
      n -
      Returns:
      double[] array
    • getIntArrayFromStringList

      public static int[] getIntArrayFromStringList(String s, int n)
      turn "[1,2,3]" into [1,2,3] array will be truncated to n elements, or filled with zeros to pad to n, as necessary.
      Parameters:
      s -
      n -
      Returns:
      int[] array