Package com.actelion.research.chem.io
Class SDFileParser
- java.lang.Object
-
- com.actelion.research.chem.io.CompoundFileParser
-
- com.actelion.research.chem.io.SDFileParser
-
public class SDFileParser extends CompoundFileParser
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringcNewLineString-
Fields inherited from class com.actelion.research.chem.io.CompoundFileParser
mReader
-
-
Constructor Summary
Constructors Constructor Description SDFileParser(java.io.File file)SDFileParser(java.io.File file, java.lang.String[] fieldName)SDFileParser(java.io.Reader reader)SDFileParser(java.io.Reader reader, java.lang.String[] fieldName)SDFileParser(java.lang.String fileName)SDFileParser(java.lang.String fileName, java.lang.String[] fieldName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanadvanceToNext()Dont't call this method directly.protected java.lang.StringextractFieldName(java.lang.String line)java.lang.StringgetFieldData(int index)Returns the cell content of the current row.java.lang.String[]getFieldNames()Returns a list of field names.java.lang.String[]getFieldNames(int recordsToInspect)Returns a list of field names.StereoMoleculegetMolecule()Either this method or getIDCode() and getCoordinates() must be overwritten!!!java.lang.StringgetMoleculeName()java.lang.StringgetNextFieldData()Returns the field data of the current record as one big String as it was read from the input file.java.lang.StringgetNextMolFile()Returns the molfile of the current record as one big String as it was read from the input file.intgetRowCount()Only accurate if getFieldNames() or getFieldNames(int) was called earlier and if the number of records of the SD-file is smaller than the number of records that were examined within the the getFieldNames() method.-
Methods inherited from class com.actelion.research.chem.io.CompoundFileParser
close, createParser, getCoordinates, getDescriptor, getDescriptorHandlerFactory, getFieldIndex, getIDCode, isOpen, next, setDescriptorHandlerFactory
-
-
-
-
Field Detail
-
cNewLineString
public static final java.lang.String cNewLineString
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SDFileParser
public SDFileParser(java.lang.String fileName)
-
SDFileParser
public SDFileParser(java.lang.String fileName, java.lang.String[] fieldName)
-
SDFileParser
public SDFileParser(java.io.File file)
-
SDFileParser
public SDFileParser(java.io.File file, java.lang.String[] fieldName)
-
SDFileParser
public SDFileParser(java.io.Reader reader)
-
SDFileParser
public SDFileParser(java.io.Reader reader, java.lang.String[] fieldName)
-
-
Method Detail
-
getRowCount
public int getRowCount()
Only accurate if getFieldNames() or getFieldNames(int) was called earlier and if the number of records of the SD-file is smaller than the number of records that were examined within the the getFieldNames() method. If not all records of the file were seen, then -1 is returned. For getRowCount() to reliably return the record count call getFieldNames(Integer.MAX_VALUE) first.- Specified by:
getRowCountin classCompoundFileParser- Returns:
- number of rows or -1
-
advanceToNext
protected boolean advanceToNext()
Description copied from class:CompoundFileParserDont't call this method directly. Use next() instead.- Specified by:
advanceToNextin classCompoundFileParser- Returns:
- false if there is no next row
-
getMolecule
public StereoMolecule getMolecule()
Description copied from class:CompoundFileParserEither this method or getIDCode() and getCoordinates() must be overwritten!!!- Overrides:
getMoleculein classCompoundFileParser- Returns:
- the molecule of the current record (null in case of parsing error)
-
getMoleculeName
public java.lang.String getMoleculeName()
- Specified by:
getMoleculeNamein classCompoundFileParser- Returns:
- name/id of (primary) chemical structure of the current row
-
getNextMolFile
public java.lang.String getNextMolFile()
Returns the molfile of the current record as one big String as it was read from the input file. Line endings are '\n'.- Returns:
-
getNextFieldData
public java.lang.String getNextFieldData()
Returns the field data of the current record as one big String as it was read from the input file. Line endings are '\n'.- Returns:
-
getFieldNames
public java.lang.String[] getFieldNames()
Returns a list of field names. If the field names were not passed to the constructor of SDFileParser, this method parses the file/reader to extract all field names and uses up this SDFileParser. In this case one needs to instantiate a new SDFileParser to sequentially iterate through the file/reader's records and supply the field name array to the constructor.- Specified by:
getFieldNamesin classCompoundFileParser- Returns:
- array of field names
-
getFieldNames
public java.lang.String[] getFieldNames(int recordsToInspect)
Returns a list of field names. If the field names were not passed to the constructor of SDFileParser, this method parses the file/readerrecords to extract all field names and uses up this SDFileParser. In this case one needs to instantiate a new SDFileParser to sequentially iterate through the file/reader's records and supply the field name array to the constructor. - Returns:
- array of field names
-
getFieldData
public java.lang.String getFieldData(int index)
Description copied from class:CompoundFileParserReturns the cell content of the current row. Multi-line cell entries are separated by a '\n' character.- Specified by:
getFieldDatain classCompoundFileParser- Parameters:
index- refers to alpha-numerical columns only, as getFieldNames()- Returns:
-
extractFieldName
protected java.lang.String extractFieldName(java.lang.String line)
-
-