Package adams.data.io.input
Class SPCSpectrumReader.AbstractParser
- java.lang.Object
-
- adams.data.io.input.SPCSpectrumReader.AbstractParser
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SPCSpectrumReader.FileParser,SPCSpectrumReader.SubFileParser
- Enclosing class:
- SPCSpectrumReader
public abstract static class SPCSpectrumReader.AbstractParser extends Object implements Serializable
Parser class for SPC files.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_BytesReadthe number of bytes read.protected byte[]m_Datathe binary data to analyze.protected intm_Offsetthe offset to use.protected SPCSpectrumReader.AbstractParserm_Parentthe parent parser, if any.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractParser(SPCSpectrumReader.AbstractParser parent, byte[] data, int offset)Initializes the parser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected byte[]copyBytes(int start, int len)Copies the bytes into a new array.intgetBytesRead()Returns the number of bytes that were read.SPCSpectrumReader.AbstractParsergetParent()Returns the parent parser if any.Stringparse()Parses the data.protected abstract StringparseData()Parses the spectral data.protected StringparseFooter()Parses the footer data (if any).protected abstract StringparseHeader()Parses the header data.protected StringpostProcess()For post-processing the data.protected longsumBytes(int start, int len)Sums up the bytes.
-
-
-
Field Detail
-
m_Parent
protected SPCSpectrumReader.AbstractParser m_Parent
the parent parser, if any.
-
m_Data
protected byte[] m_Data
the binary data to analyze.
-
m_Offset
protected int m_Offset
the offset to use.
-
m_BytesRead
protected int m_BytesRead
the number of bytes read.
-
-
Constructor Detail
-
AbstractParser
protected AbstractParser(SPCSpectrumReader.AbstractParser parent, byte[] data, int offset)
Initializes the parser.- Parameters:
parent- the parent parserdata- the data to analyzeoffset- the offset to use
-
-
Method Detail
-
getParent
public SPCSpectrumReader.AbstractParser getParent()
Returns the parent parser if any.- Returns:
- the parser, null if not available
-
sumBytes
protected long sumBytes(int start, int len)Sums up the bytes.- Parameters:
start- the start indexlen- the number of bytes to sum up- Returns:
- the sum
-
copyBytes
protected byte[] copyBytes(int start, int len)Copies the bytes into a new array.- Parameters:
start- the start indexlen- the number of bytes to copy- Returns:
- the new array
-
parseHeader
protected abstract String parseHeader()
Parses the header data.- Returns:
- null if successfully parsed, otherwise error message
-
parseData
protected abstract String parseData()
Parses the spectral data.- Returns:
- null if successfully parsed, otherwise error message
-
parseFooter
protected String parseFooter()
Parses the footer data (if any).- Returns:
- null if successfully parsed, otherwise error message
-
postProcess
protected String postProcess()
For post-processing the data.- Returns:
- null if successfully parsed, otherwise error message
-
parse
public String parse()
Parses the data.- Returns:
- null if successfully parsed, otherwise error message
-
getBytesRead
public int getBytesRead()
Returns the number of bytes that were read.- Returns:
- the number of bytes
-
-