com.isti.jevalresp
Class RespFileParser

java.lang.Object
  extended by com.isti.jevalresp.RespFileParser

public class RespFileParser
extends java.lang.Object

Class RespFileParser manages the parsing of an 'rdseed' ASCII response ("RESP") file.


Nested Class Summary
(package private)  class RespFileParser.BlockFieldSpec
          Class BlockFieldSpec holds block and field numbers.
(package private)  class RespFileParser.RefInfoSpec
          Class RefInfoSpec holds Reference Response block information.
(package private)  class RespFileParser.RespListItem
          Class RespListItem holds a set of frequency, amplitude and phase values, as found in the Response List Blockette.
 
Field Summary
protected  java.lang.String errorMessage
           
protected  java.lang.String infoMessage
           
 
Constructor Summary
RespFileParser(java.io.Reader rdr)
          Creates an 'rdseed' ASCII file parsing object.
RespFileParser(java.io.Reader rdr, java.lang.String fNameStr)
          Creates an 'rdseed' ASCII file parsing object.
RespFileParser(java.lang.String fNameStr)
          Creates an 'rdseed' ASCII file parsing object.
 
Method Summary
 void clearErrorMessage()
          Clears the error message string.
 void clearInfoMessage()
          Clears the info message string.
 boolean clearToEndOfLine()
          Reads in and discards all tokens remaining on the current line.
 void close()
          Closes the input file or stream used by this parser.
 ChanIdHldr findChannelId(java.lang.String[] stationPatArr, java.lang.String[] channelPatArr, java.lang.String[] networkPatArr, java.lang.String[] sitePatArr, java.util.Date beginDateObj, java.util.Date endDateObj)
          Finds a station/channel ID entry.
 ChanIdHldr findChannelId(java.lang.String[] stationPatArr, java.lang.String[] channelPatArr, java.lang.String[] networkPatArr, java.lang.String sitePat, java.util.Date beginDateObj, java.util.Date endDateObj)
          Finds a station/channel ID entry.
 ChanIdHldr findChannelId(java.lang.String[] stationPatArr, java.lang.String[] channelPatArr, java.lang.String networkPat, java.lang.String[] sitePatArr, java.util.Date beginDateObj, java.util.Date endDateObj)
          Finds a station/channel ID entry.
 ChanIdHldr findChannelId(java.lang.String[] stationPatArr, java.lang.String[] channelPatArr, java.lang.String networkPat, java.lang.String sitePat, java.util.Date beginDateObj, java.util.Date endDateObj)
          Finds a station/channel ID entry.
 ChanIdHldr findChannelId(java.lang.String[] stationPatArr, java.lang.String channelPat, java.lang.String networkPat, java.lang.String sitePat, java.util.Date beginDateObj, java.util.Date endDateObj)
          Finds a station/channel ID entry.
 ChanIdHldr findChannelId(java.lang.String stationPat, java.lang.String channelPat, java.lang.String networkPat, java.lang.String sitePat, java.util.Date beginDateObj, java.util.Date endDateObj)
          Finds a station/channel ID entry.
 edu.iris.Fissures.IfNetwork.Sensitivity getCurSensitivityObj()
           
 boolean getErrorFlag()
           
 java.lang.String getErrorMessage()
           
 boolean getInfoFlag()
           
 java.lang.String getInfoMessage()
           
 java.lang.String getInputFileName()
           
 RespFileParser.BlockFieldSpec parseBlockFieldNums(java.lang.String str)
          Parses "B###F##..." string into block and field numbers.
 java.lang.String readBasicDataValue()
           
 java.lang.String readBasicDataValue(boolean lineFlag)
           
 java.lang.String readBlockFieldValue(int blockNum, int fieldNum)
           
 java.lang.String readBlockFieldValue(int blockNum, int fieldNum, boolean lineFlag)
           
 edu.iris.Fissures.IfNetwork.CoefficientErrored readCoefficientErrored()
           
 edu.iris.Fissures.IfNetwork.ComplexNumberErrored readComplexNumberErrored()
           
 RespFileParser.BlockFieldSpec readNextBlockFieldNums()
           
 RespFileParser.BlockFieldSpec readNextBlockFieldNums(int blockNum, int fieldNum)
          Scans until a block with the specified values is found.
 RespFileParser.BlockFieldSpec readNextBlockFieldNums(int blockNum1, int fieldNum1, int blockNum2, int fieldNum2)
          Scans until a block matching one of the specified set of values is found.
 java.lang.String readNextTokenString()
           
 RespFileParser.RespListItem readRespListItem()
          Reads a response list item (freq, amp & phase).
 edu.iris.Fissures.IfNetwork.Response readResponse()
          Parses and returns a set of response data.
protected  void setErrorMessage(java.lang.String str)
           
protected  void setInfoMessage(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorMessage

protected java.lang.String errorMessage

infoMessage

protected java.lang.String infoMessage
Constructor Detail

RespFileParser

public RespFileParser(java.lang.String fNameStr)
Creates an 'rdseed' ASCII file parsing object.

Parameters:
fNameStr - the name of an input file from which to read data.

RespFileParser

public RespFileParser(java.io.Reader rdr,
                      java.lang.String fNameStr)
Creates an 'rdseed' ASCII file parsing object.

Parameters:
rdr - an input stream from which to read data.
fNameStr - file name associated with the given input stream.

RespFileParser

public RespFileParser(java.io.Reader rdr)
Creates an 'rdseed' ASCII file parsing object.

Parameters:
rdr - an input stream from which to read data.
Method Detail

close

public void close()
Closes the input file or stream used by this parser.


findChannelId

public ChanIdHldr findChannelId(java.lang.String[] stationPatArr,
                                java.lang.String[] channelPatArr,
                                java.lang.String[] networkPatArr,
                                java.lang.String[] sitePatArr,
                                java.util.Date beginDateObj,
                                java.util.Date endDateObj)
Finds a station/channel ID entry. The name pattern parameters are expected to be glob-style expressions (can have '*' or '?' characters). After a station/channel ID entry is found the 'readResponse()' method may be used to parse and return the response data.

Parameters:
stationPatArr - an array of station name patterns to search for, or a null or empty array to accept all station names.
channelPatArr - an array of channel name patterns to search for, or a null or empty array to accept all channel names.
networkPatArr - an array of network name patterns to search for, or a null or empty array to accept all network names.
sitePatArr - an array of site name patterns to search for, or a null or empty array to accept all site names.
beginDateObj - the beginning of a date range to search for, or null for no begin date. If no end-date is given then this becomes a single date that must be within the date-range of matched responses.
endDateObj - the end of a date range to search for, or null for no end date.
Returns:
A new 'ChanIdHldr' object filled with data from the station/channel ID found, or null if no matching ID was found (in which case 'getErorFlag()' may be used to see if any errors were detected and 'getErorMessage()' may be used to see information about the first error detected).

findChannelId

public ChanIdHldr findChannelId(java.lang.String[] stationPatArr,
                                java.lang.String[] channelPatArr,
                                java.lang.String[] networkPatArr,
                                java.lang.String sitePat,
                                java.util.Date beginDateObj,
                                java.util.Date endDateObj)
Finds a station/channel ID entry. The name pattern parameters are expected to be glob-style expressions (can have '*' or '?' characters). After a station/channel ID entry is found the 'readResponse()' method may be used to parse and return the response data.

Parameters:
stationPatArr - an array of station name patterns to search for, or a null or empty array to accept all station names.
channelPatArr - an array of channel name patterns to search for, or a null or empty array to accept all channel names.
networkPatArr - an array of network name patterns to search for, or a null or empty array to accept all network names.
sitePat - a site name pattern to search for, or a null or empty string to accept all site names.
beginDateObj - the beginning of a date range to search for, or null for no begin date. If no end-date is given then this becomes a single date that must be within the date-range of matched responses.
endDateObj - the end of a date range to search for, or null for no end date.
Returns:
A new 'ChanIdHldr' object filled with data from the station/channel ID found, or null if no matching ID was found (in which case 'getErorFlag()' may be used to see if any errors were detected and 'getErorMessage()' may be used to see information about the first error detected).

findChannelId

public ChanIdHldr findChannelId(java.lang.String[] stationPatArr,
                                java.lang.String[] channelPatArr,
                                java.lang.String networkPat,
                                java.lang.String[] sitePatArr,
                                java.util.Date beginDateObj,
                                java.util.Date endDateObj)
Finds a station/channel ID entry. The name pattern parameters are expected to be glob-style expressions (can have '*' or '?' characters).

Parameters:
stationPatArr - an array of station name patterns to search for, or a null or empty array to accept all station names.
channelPatArr - an array of channel name patterns to search for, or a null or empty array to accept all channel names.
networkPat - a network name pattern to search for, or a null or empty string to accept all network names.
sitePatArr - an array of site name patterns to search for, or a null or empty array to accept all site names.
beginDateObj - the beginning of a date range to search for, or null for no begin date. If no end-date is given then this becomes a single date that must be within the date-range of matched responses.
endDateObj - the end of a date range to search for, or null for no end date.
Returns:
A new 'ChanIdHldr' object filled with data from the station/channel ID found, or null if no matching ID was found (in which case 'getErorFlag()' may be used to see if any errors were detected and 'getErorMessage()' may be used to see information about the first error detected).

findChannelId

public ChanIdHldr findChannelId(java.lang.String[] stationPatArr,
                                java.lang.String[] channelPatArr,
                                java.lang.String networkPat,
                                java.lang.String sitePat,
                                java.util.Date beginDateObj,
                                java.util.Date endDateObj)
Finds a station/channel ID entry. The name pattern parameters are expected to be glob-style expressions (can have '*' or '?' characters).

Parameters:
stationPatArr - an array of station name patterns to search for, or a null or empty array to accept all station names.
channelPatArr - an array of channel name patterns to search for, or a null or empty array to accept all channel names.
networkPat - a network name pattern to search for, or a null or empty string to accept all network names.
sitePat - a site name pattern to search for, or a null or empty string to accept all site names.
beginDateObj - the beginning of a date range to search for, or null for no begin date. If no end-date is given then this becomes a single date that must be within the date-range of matched responses.
endDateObj - the end of a date range to search for, or null for no end date.
Returns:
A new 'ChanIdHldr' object filled with data from the station/channel ID found, or null if no matching ID was found (in which case 'getErorFlag()' may be used to see if any errors were detected and 'getErorMessage()' may be used to see information about the first error detected).

findChannelId

public ChanIdHldr findChannelId(java.lang.String[] stationPatArr,
                                java.lang.String channelPat,
                                java.lang.String networkPat,
                                java.lang.String sitePat,
                                java.util.Date beginDateObj,
                                java.util.Date endDateObj)
Finds a station/channel ID entry. The name pattern parameters are expected to be glob-style expressions (can have '*' or '?' characters).

Parameters:
stationPatArr - an array of station name patterns to search for, or a null or empty array to accept all station names.
channelPat - a channel name pattern to search for, or a null or empty string to accept all channel names.
networkPat - a network name pattern to search for, or a null or empty string to accept all network names.
sitePat - a site name pattern to search for, or a null or empty string to accept all site names.
beginDateObj - the beginning of a date range to search for, or null for no begin date. If no end-date is given then this becomes a single date that must be within the date-range of matched responses.
endDateObj - the end of a date range to search for, or null for no end date.
Returns:
A new 'ChanIdHldr' object filled with data from the station/channel ID found, or null if no matching ID was found (in which case 'getErorFlag()' may be used to see if any errors were detected and 'getErorMessage()' may be used to see information about the first error detected).

findChannelId

public ChanIdHldr findChannelId(java.lang.String stationPat,
                                java.lang.String channelPat,
                                java.lang.String networkPat,
                                java.lang.String sitePat,
                                java.util.Date beginDateObj,
                                java.util.Date endDateObj)
Finds a station/channel ID entry. The name pattern parameters are expected to be glob-style expressions (can have '*' or '?' characters).

Parameters:
stationPat - a station name pattern to search for, or a null or empty string to accept all station names.
channelPat - a channel name pattern to search for, or a null or empty string to accept all channel names.
networkPat - a network name pattern to search for, or a null or empty string to accept all network names.
sitePat - a site name pattern to search for, or a null or empty string to accept all site names.
beginDateObj - the beginning of a date range to search for, or null for no begin date. If no end-date is given then this becomes a single date that must be within the date-range of matched responses.
endDateObj - the end of a date range to search for, or null for no end date.
Returns:
A new 'ChanIdHldr' object filled with data from the station/channel ID found, or null if no matching ID was found (in which case 'getErorFlag()' may be used to see if any errors were detected and 'getErorMessage()' may be used to see information about the first error detected).

readResponse

public edu.iris.Fissures.IfNetwork.Response readResponse()
Parses and returns a set of response data. The 'findChannelId()' method should be used to find the desired station/channel ID before this method is used.

Returns:
A new 'Response' object filled with parsed data, or null if an error occurred (in which case 'getErorMessage()' may be used to see information about the error).

readBlockFieldValue

public java.lang.String readBlockFieldValue(int blockNum,
                                            int fieldNum,
                                            boolean lineFlag)
Parameters:
blockNum - block number
fieldNum - field number
lineFlag - if true then all the rest of the tokens on the line are also returned; if false then only the next token is returned and the rest on the line are read in and discarded.
Returns:
the given block/field value or null if the next item cannot be be found, its numbers do not match, or if an error occurs.

readBlockFieldValue

public java.lang.String readBlockFieldValue(int blockNum,
                                            int fieldNum)
Parameters:
blockNum - block number
fieldNum - field number
Returns:
the given block/field number item and returns its associated value. Returns null if the next item cannot be be found, its numbers do not match, or if an error occurs.

readNextBlockFieldNums

public RespFileParser.BlockFieldSpec readNextBlockFieldNums()
Returns:
the block and field numbers of the next "B###F##..." string or null if valid string not found or error. Any leading blank for comment lines are skipped, but the next word token must be a valid "B###F##..." string or null is returned.

readNextBlockFieldNums

public RespFileParser.BlockFieldSpec readNextBlockFieldNums(int blockNum,
                                                            int fieldNum)
Scans until a block with the specified values is found.

Parameters:
blockNum - block number to find.
fieldNum - field number to find.
Returns:
the block and field numbers of the for requested block, or null if valid string not found or error.

readNextBlockFieldNums

public RespFileParser.BlockFieldSpec readNextBlockFieldNums(int blockNum1,
                                                            int fieldNum1,
                                                            int blockNum2,
                                                            int fieldNum2)
Scans until a block matching one of the specified set of values is found.

Parameters:
blockNum1 - first block number to find.
fieldNum1 - first field number to find.
blockNum2 - second block number to find.
fieldNum2 - second field number to find.
Returns:
The block and field numbers for the requested block, or null if valid string not found or error.

readNextTokenString

public java.lang.String readNextTokenString()
Returns:
the next token or null if token not found or error.

readBasicDataValue

public java.lang.String readBasicDataValue(boolean lineFlag)
Parameters:
lineFlag - if true then all the rest of the tokens on the line are also returned; if false then only the next token is returned and the rest on the line are read in and discarded.
Returns:
the token after the next "xxx:" token or null if token not found or error.

readBasicDataValue

public java.lang.String readBasicDataValue()
Returns:
the token after the next "xxx:" token or null if token not found or error. The single token is returned and the rest on the line are read in and discarded.

readComplexNumberErrored

public edu.iris.Fissures.IfNetwork.ComplexNumberErrored readComplexNumberErrored()
Returns:
four floating-point values; returns null if unexpected input or error.

readCoefficientErrored

public edu.iris.Fissures.IfNetwork.CoefficientErrored readCoefficientErrored()
Returns:
two floating-point values; returns null if unexpected input or error.

readRespListItem

public RespFileParser.RespListItem readRespListItem()
Reads a response list item (freq, amp & phase).

Returns:
A new 'RespListItem' object, or null if unexpected input or error.

clearToEndOfLine

public boolean clearToEndOfLine()
Reads in and discards all tokens remaining on the current line.

Returns:
true if successful, false if an I/O error is detected (in which case an error message will be set).

parseBlockFieldNums

public RespFileParser.BlockFieldSpec parseBlockFieldNums(java.lang.String str)
Parses "B###F##..." string into block and field numbers.

Parameters:
str - string
Returns:
block field spec

setErrorMessage

protected void setErrorMessage(java.lang.String str)

getErrorFlag

public boolean getErrorFlag()
Returns:
true if an error was detected. The error message may be fetched via the 'getErrorMessage()' method.

getErrorMessage

public java.lang.String getErrorMessage()
Returns:
message string for last error (or 'No error' if none).

clearErrorMessage

public void clearErrorMessage()
Clears the error message string.


setInfoMessage

protected void setInfoMessage(java.lang.String str)

getInfoFlag

public boolean getInfoFlag()
Returns:
true if an info message has been entered. The info message may be fetched via the 'getInfoMessage()' method.

getInfoMessage

public java.lang.String getInfoMessage()
Returns:
the info message string (or 'No message' if none).

clearInfoMessage

public void clearInfoMessage()
Clears the info message string.


getInputFileName

public java.lang.String getInputFileName()
Returns:
the input file name for this parser.

getCurSensitivityObj

public edu.iris.Fissures.IfNetwork.Sensitivity getCurSensitivityObj()
Returns:
the current-sensitivity object.