Package org.jmol.adapter.readers.cif
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.CifDataParserFully 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
-
-
Constructor Summary
Constructors Constructor Description Cif2DataParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringfixLineFolding(java.lang.String str)allow white space between \ and \nstatic double[]getArrayFromStringList(java.lang.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.static int[]getIntArrayFromStringList(java.lang.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.protected java.lang.ObjectgetQuotedStringOrObject(char ch)final get for quoted objectprotected intgetVersion()protected booleanisQuote(char ch)Includes all possible operator tokensprivate booleanisSpaceOrColon(int ich)used by readTableprotected java.lang.StringpreprocessString()initial processing; returns a string bounded by \1private java.lang.ObjectprocessQuotedString()Handle all forms of quotation, including '...', "...", '''...''', """...""", and ;...\n...\n;protected java.lang.StringprocessSemiString()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.java.lang.ObjectreadTable()Read a CIF 2.0 table into either a JSON string or a java data structurejava.lang.StringtoUnicode(java.lang.String data)There is no need to convert to unicode in CIF 2.0.protected java.lang.Objectunquoted(java.lang.String s)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
-
-
-
-
Method Detail
-
getVersion
protected int getVersion()
- Overrides:
getVersionin classjavajs.util.CifDataParser
-
toUnicode
public java.lang.String toUnicode(java.lang.String data)
There is no need to convert to unicode in CIF 2.0.- Specified by:
toUnicodein interfacejavajs.api.GenericCifDataParser- Overrides:
toUnicodein classjavajs.util.CifDataParser- Returns:
- cleaned string
-
isQuote
protected boolean isQuote(char ch)
Includes all possible operator tokens- Overrides:
isQuotein classjavajs.util.CifDataParser- Returns:
- true if this character is a (starting) quote
-
getQuotedStringOrObject
protected java.lang.Object getQuotedStringOrObject(char ch)
final get for quoted object- Overrides:
getQuotedStringOrObjectin classjavajs.util.CifDataParser- Parameters:
ch- current character being pointed to- Returns:
- a String data object
-
preprocessString
protected java.lang.String preprocessString() throws java.lang.Exceptioninitial processing; returns a string bounded by \1- Overrides:
preprocessStringin classjavajs.util.CifDataParser- Returns:
- escaped part with attached extra data
- Throws:
java.lang.Exception
-
processQuotedString
private java.lang.Object processQuotedString()
Handle all forms of quotation, including '...', "...", '''...''', """...""", and ;...\n...\n;- Returns:
- a string or data structure, depending upon setting asObject
-
processSemiString
protected java.lang.String processSemiString() throws java.lang.ExceptionSets 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:
java.lang.Exception
-
readTable
public java.lang.Object readTable() throws java.lang.ExceptionRead a CIF 2.0 table into either a JSON string or a java data structure- Returns:
- an Object or String, depending upon settings
- Throws:
java.lang.Exception
-
isSpaceOrColon
private boolean isSpaceOrColon(int ich)
used by readTable- Parameters:
ich- buffer pointer- Returns:
- true if whitespace or colon
-
unquoted
protected java.lang.Object unquoted(java.lang.String s)
Handle unquoted value as Integer or Float if we can.- Overrides:
unquotedin classjavajs.util.CifDataParser- Parameters:
s- unquoted string- Returns:
- unchanged value
-
fixLineFolding
private java.lang.String fixLineFolding(java.lang.String str)
allow white space between \ and \n- Parameters:
str- already enclosed in \1.....\1- Returns:
- fixed line
-
getArrayFromStringList
public static double[] getArrayFromStringList(java.lang.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(java.lang.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
-
-