internal static System.String determineAtomSetCollectionReader(System.IO.StreamReader bufferedReader) { System.String[] lines = new System.String[4]; LimitedLineReader llr = new LimitedLineReader(bufferedReader, 16384); for (int i = 0; i < lines.Length; ++i) { lines[i] = llr.readLineWithNewline(); } if (lines[3].Length >= 6) { System.String line4trimmed = lines[3].Trim(); if (line4trimmed.EndsWith("V2000") || line4trimmed.EndsWith("v2000") || line4trimmed.EndsWith("V3000")) { return("Mol"); } try { System.Int32.Parse(lines[3].Substring(0, (3) - (0)).Trim()); System.Int32.Parse(lines[3].Substring(3, (6) - (3)).Trim()); return("Mol"); } catch (System.FormatException nfe) { } } try { /*int atomCount = */ System.Int32.Parse(lines[0].Trim()); return("Xyz"); } catch (System.FormatException e) { } try { SupportClass.Tokenizer tokens = new SupportClass.Tokenizer(lines[0].Trim(), " \t"); if ((tokens != null) && (tokens.Count >= 2)) { System.Int32.Parse(tokens.NextToken().Trim()); return("FoldingXyz"); } } catch (System.FormatException e) { // } // run these loops forward ... easier for people to understand for (int i = 0; i < startsWithRecords.Length; ++i) { System.String[] recordTags = startsWithRecords[i]; for (int j = 0; j < recordTags.Length; ++j) { System.String recordTag = recordTags[j]; for (int k = 0; k < lines.Length; ++k) { if (lines[k].StartsWith(recordTag)) { return(startsWithFormats[i]); } } } } for (int i = 0; i < containsRecords.Length; ++i) { System.String[] recordTags = containsRecords[i]; for (int j = 0; j < recordTags.Length; ++j) { System.String recordTag = recordTags[j]; for (int k = 0; k < lines.Length; ++k) { if (lines[k].IndexOf(recordTag) != -1) { return(containsFormats[i]); } } } } if (lines[1] == null || lines[1].Trim().Length == 0) { return("Jme"); // this is really quite broken :-) } return(null); }
internal static System.String determineAtomSetCollectionReader(System.IO.StreamReader bufferedReader, JmolAdapter.Logger logger) { System.String[] lines = new System.String[4]; LimitedLineReader llr = new LimitedLineReader(bufferedReader, 16384); for (int i = 0; i < lines.Length; ++i) lines[i] = llr.readLineWithNewline(); if (lines[3].Length >= 6) { System.String line4trimmed = lines[3].Trim(); if (line4trimmed.EndsWith("V2000") || line4trimmed.EndsWith("v2000") || line4trimmed.EndsWith("V3000")) return "Mol"; try { System.Int32.Parse(lines[3].Substring(0, (3) - (0)).Trim()); System.Int32.Parse(lines[3].Substring(3, (6) - (3)).Trim()); return "Mol"; } catch (System.FormatException nfe) { } } try { /*int atomCount = */ System.Int32.Parse(lines[0].Trim()); return "Xyz"; } catch (System.FormatException e) { } try { SupportClass.Tokenizer tokens = new SupportClass.Tokenizer(lines[0].Trim(), " \t"); if ((tokens != null) && (tokens.Count >= 2)) { System.Int32.Parse(tokens.NextToken().Trim()); return "FoldingXyz"; } } catch (System.FormatException e) { // } // run these loops forward ... easier for people to understand for (int i = 0; i < startsWithRecords.Length; ++i) { System.String[] recordTags = startsWithRecords[i]; for (int j = 0; j < recordTags.Length; ++j) { System.String recordTag = recordTags[j]; for (int k = 0; k < lines.Length; ++k) { if (lines[k].StartsWith(recordTag)) return startsWithFormats[i]; } } } for (int i = 0; i < containsRecords.Length; ++i) { System.String[] recordTags = containsRecords[i]; for (int j = 0; j < recordTags.Length; ++j) { System.String recordTag = recordTags[j]; for (int k = 0; k < lines.Length; ++k) { if (lines[k].IndexOf(recordTag) != -1) return containsFormats[i]; } } } if (lines[1] == null || lines[1].Trim().Length == 0) return "Jme"; // this is really quite broken :-) return null; }