X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjavajs%2Futil%2FCifDataParser.java;fp=src%2Fjavajs%2Futil%2FCifDataParser.java;h=d0cb3fda9c8f9390a471c210edd49b710bb7ecfd;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hp=39317c7fb6037ade9b0ec87734a37b8b0c55a54d;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44;p=jalviewjs.git
diff --git a/src/javajs/util/CifDataParser.java b/src/javajs/util/CifDataParser.java
index 39317c7..d0cb3fd 100644
--- a/src/javajs/util/CifDataParser.java
+++ b/src/javajs/util/CifDataParser.java
@@ -1,633 +1,633 @@
-package javajs.util;
-
-import java.io.BufferedReader;
-
-import java.util.Hashtable;
-
-import java.util.Map;
-
-import javajs.api.GenericCifDataParser;
-import javajs.api.GenericLineReader;
-
-
-
-public class CifDataParser implements GenericCifDataParser {
- /**
- *
- * A special tokenizer class for dealing with quoted strings in CIF files.
- *
- * Greek letters implemented in Jmol 13.3.9 and only for
- * titles and space groups. All other mark ups ignored.
- *
- *
- * regarding the treatment of single quotes vs. primes in
- * cif file, PMR wrote:
- *
- *
- * * There is a formal grammar for CIF
- * (see http://www.iucr.org/iucr-top/cif/index.html)
- * which confirms this. The textual explanation is
- *
- *
- * 14. Matching single or double quote characters (' or ") may
- * be used to bound a string representing a non-simple data value
- * provided the string does not extend over more than one line.
- *
- *
- * 15. Because data values are invariably separated from other
- * tokens in the file by white space, such a quote-delimited
- * character string may contain instances of the character used
- * to delimit the string provided they are not followed by white
- * space. For example, the data item
- *
- * _example 'a dog's life'
- *
- * is legal; the data value is a dog's life.
- *
- *
- * [PMR - the terminating character(s) are quote+whitespace.
- * That would mean that:
- *
- * _example 'Jones' life'
- *
- * would be an error
- *
- *
- * The CIF format was developed in that late 1980's under the aegis of the
- * International Union of Crystallography (I am a consultant to the COMCIFs
- * committee). It was ratified by the Union and there have been several
- * workshops. mmCIF is an extension of CIF which includes a relational
- * structure. The formal publications are:
- *
- *
- * Hall, S. R. (1991). "The STAR File: A New Format for Electronic Data
- * Transfer and Archiving", J. Chem. Inform. Comp. Sci., 31, 326-333.
- * Hall, S. R., Allen, F. H. and Brown, I. D. (1991). "The Crystallographic
- * Information File (CIF): A New Standard Archive File for Crystallography",
- * Acta Cryst., A47, 655-685.
- * Hall, S.R. & Spadaccini, N. (1994). "The STAR File: Detailed
- * Specifications," J. Chem. Info. Comp. Sci., 34, 505-508.
- *
- */
- private GenericLineReader reader;
- private BufferedReader br;
-
- private String line;
- private String str;
- private int ich;
- private int cch;
- private boolean wasUnQuoted;
- private String strPeeked;
- private int ichPeeked;
- private int fieldCount;
- private String[] loopData;
- private SB fileHeader = new SB();
- private boolean isHeader = true;
- private String nullString = "\0";
-
- /**
- * Set the string value of what is returned for "." and "?"
- *
- * @param nullString null here returns "." and "?"; default is "\0"
- *
- */
- public void setNullValue(String nullString) {
- this.nullString = nullString;
- }
-
- /**
- * A global, static map that contains field information. The assumption is that
- * if we read a set of fields for, say, atom_site, once in a lifetime, then
- * that should be good forever. Those are static lists. Or should be....
- */
- private static Map htFields = new Hashtable();
-
- ////////////////////////////////////////////////////////////////
- // special tokenizer class
- ////////////////////////////////////////////////////////////////
-
- public CifDataParser() {
- // for reflection
- }
-
- private String[] fields;
-
- @Override
- public String getLoopData(int i) {
- return loopData[i];
- }
-
- @Override
- public int getFieldCount() {
- return fieldCount;
- }
-
- @Override
- public String getField(int i) {
- return fields[i];
- }
-
- /**
- * A Chemical Information File data parser.
- *
- * Should be called immediately upon construction.
- *
- * Two options; one of reader or br should be null, or reader will be
- * ignored. Just simpler this way...
- *
- * @param reader Anything that can deliver a line of text or null
- * @param br A standard BufferedReader.
- *
- */
- @Override
- public CifDataParser set(GenericLineReader reader, BufferedReader br) {
- this.reader = reader;
- this.br = br;
- return this;
- }
-
- /**
- *
- * @return commented-out section at the start of a CIF file.
- *
- */
- @Override
- public String getFileHeader() {
- return fileHeader.toString();
- }
-
-
- /**
- * Parses all CIF data for a reader defined in the constructor
- * into a standard Map structure and close the BufferedReader if
- * it exists.
- *
- * @return Hashtable of models Vector of Hashtable data
- */
- @Override
- public Map getAllCifData() {
- line = "";
- String key;
- Map data = null;
- Map allData = new Hashtable();
- Lst