Package hec.lang
Class RdcDelim
java.lang.Object
hec.lang.RdcDelim
Title: Processes strings containing field separators like tab-delimited text files.
The steps are: (1) Set the field separator (optional), (2) compute the fields
by calling computeFields, (3) Get the field content by calling getFieldContent
for the desired field.
Description:
Company:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RdcFieldField Object to contain parameters for one fieldprotected StringWorking variable conatining the string of characters in the current field.protected intNumber of fields found in input string.protected intWorking variable containing the number of characters in the current field.protected intNumber of characters in input string that will be parsed.protected VectorContains and array of rdcField objects that for each field include beginning and ending character locations, number of characters in field, etc.protected StringContain separator characters that are used to determine breaks between fields.protected StringContain separator characters that are used to determine breaks between fields.protected StringInput String that will be parsed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcomputeFields(StringBuffer stringIn) Parse the entire input stringvoidcomputeFields(StringBuffer stringIn, int firstCol, int length) Determine the fields for an input string "stringIn" starting at the specified first column (starting at zero) and ending after length characters.fieldContent(int ixField) Pass-through for old callsintfirstCol(int ixField) Returns the first character position in the input string for field ixField, both position and field start at zero.intReturns the number of fields that were found.getFieldContent(int ixField) Returns the stringBuffer content from input string for field ixField where ixField starts at zero.chargetFieldSeparator(int ixField) Returns the char separator that separated field ixField from the next field.getSeps()Returns the string of character(s) that are used to parse for fields.Returns the string of character(s) that will be used to determine a string contained within quotes that will not be parsed.intlastCol(int ixField) Returns the last character position in the input string for field ixField, both position and field start at zero.intlengthField(int ixField) Returns the number of characters found in field ixField (0 through nfields-1).static voidvoidvoidrdcFields(StringBuffer stringIn, int firstCol, int length) Pass-through for old conventionvoidreset()Reset the RdcDelim Vector to be empty - it won't contain any elements.intSet the field separator character(s) and returns the number of characters that were set.intsetSepsQuote(String theSepsQ) Set the string of character(s) that will be used to determine a string contained within quotes that will not be parsed.intsize()Returns the number of fields that were found.
-
Field Details
-
_rdcFields
Contains and array of rdcField objects that for each field include beginning and ending character locations, number of characters in field, etc. -
_field
Field Object to contain parameters for one field -
_separators
Contain separator characters that are used to determine breaks between fields. -
_separatorQuote
Contain separator characters that are used to determine breaks between fields. -
_numberOfFields
protected int _numberOfFieldsNumber of fields found in input string. -
_numCharIn_string
protected int _numCharIn_stringNumber of characters in input string that will be parsed. -
_string
Input String that will be parsed. -
_numCharIn_fieldContent
protected int _numCharIn_fieldContentWorking variable containing the number of characters in the current field. -
_fieldContent
Working variable conatining the string of characters in the current field.
-
-
Constructor Details
-
RdcDelim
public RdcDelim()Create an instance of a string parser for delimited fields.
-
-
Method Details
-
reset
public void reset()Reset the RdcDelim Vector to be empty - it won't contain any elements. -
setSeps
Set the field separator character(s) and returns the number of characters that were set. -
getSeps
Returns the string of character(s) that are used to parse for fields. -
setSepsQuote
Set the string of character(s) that will be used to determine a string contained within quotes that will not be parsed. -
getSepsQuote
Returns the string of character(s) that will be used to determine a string contained within quotes that will not be parsed. -
getCountOfFields
public int getCountOfFields()Returns the number of fields that were found. Deprecated. -
size
public int size()Returns the number of fields that were found. Replaces deprecated getCountOfFields.- Returns:
-
lengthField
public int lengthField(int ixField) Returns the number of characters found in field ixField (0 through nfields-1). -
firstCol
public int firstCol(int ixField) Returns the first character position in the input string for field ixField, both position and field start at zero. -
lastCol
public int lastCol(int ixField) Returns the last character position in the input string for field ixField, both position and field start at zero. -
fieldContent
Pass-through for old calls -
getFieldContent
Returns the stringBuffer content from input string for field ixField where ixField starts at zero. Returns null if there is a failure to get the field content. -
getFieldSeparator
public char getFieldSeparator(int ixField) Returns the char separator that separated field ixField from the next field.- Parameters:
ixField- The field whose separator is wanted.- Returns:
- The separator character.
-
rdcFields
Pass-through for old convention -
computeFields
Parse the entire input string -
computeFields
Determine the fields for an input string "stringIn" starting at the specified first column (starting at zero) and ending after length characters. This is the primary method for parsing an input string. -
printFields
public void printFields() -
main
-