Package ucar.nc2.util
Class TableParser
- java.lang.Object
-
- ucar.nc2.util.TableParser
-
@Deprecated public class TableParser extends Object
Deprecated.move in ver6Utility class to read and parse a fixed length table. Each line of the table becomes a "Record". Each Record has a set of Fields described by the format string.List
recs = TableParser.readTable(is, "3,15,46,54,60d,67d,73d", 50000); for (TableParser.Record record : recs) { Station s = new Station(); s.id = "K" + record.get(0); s.name = record.get(2) + " " + record.get(3); s.lat = (Double) record.get(4) * .01; s.lon = (Double) record.get(5) * .01; s.elev = (Double) record.get(6); stationTableHash.put(s.id, s); if (showStations) System.out.println(" station= " + s); } Example Table: TLX 000001 OKLAHOMA_CITY/Norman OK US 3532 -9727 370 0 NWS AMA 000313 AMARILLO/Amarillo TX US 3523 -10170 1093 0 NWS HGX 000378 HOUSTON/GALVESTON/Dickinson TX US 2947 -9507 5 0 NWS MLB 000302 MELBOURNE/Melbourne FL US 2810 -8065 11 0 NWS format: "3,15,54,60d,67d,73d" grammer: format = {field,} field = endPos type endPos = ending pos in the line, 0 based, exclusive, ie [start, end) type = i=integer, d=double, L=long else String field[0] goes from [0, endPos[0]) field[i] goes from [endPos[i-1] to endPos[i])
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TableParser.DerivedField
Deprecated.will move in ver6.static class
TableParser.Field
Deprecated.will move in ver6.static class
TableParser.Record
Deprecated.will move in ver6.static interface
TableParser.Transform
Deprecated.will move in ver6.
-
Constructor Summary
Constructors Constructor Description TableParser(String format)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TableParser.DerivedField
addDerivedField(TableParser.Field from, TableParser.Transform transform, Class type)
Deprecated.TableParser.Field
getField(int fldno)
Deprecated.int
getNumberOfFields()
Deprecated.List<TableParser.Record>
readAllRecords(InputStream ios, int maxLines)
Deprecated.static List<TableParser.Record>
readTable(InputStream ios, String format, int maxLines)
Deprecated.Reads an input stream, containing lines of ascii in fixed width format.static List<TableParser.Record>
readTable(String urlString, String format, int maxLines)
Deprecated.Reads a URL or file in as a table.void
setComment(String comment)
Deprecated.
-
-
-
Constructor Detail
-
TableParser
public TableParser(String format) throws NumberFormatException
Deprecated.- Throws:
NumberFormatException
-
-
Method Detail
-
readTable
public static List<TableParser.Record> readTable(String urlString, String format, int maxLines) throws IOException, NumberFormatException
Deprecated.Reads a URL or file in as a table.- Parameters:
urlString
- starts with http, read URL contenets, else read file.format
- describe format of each line.maxLines
- maximum number of lines to parse, set to < 0 to read all- Returns:
- List of TableParser.Record
- Throws:
IOException
- on read errorNumberFormatException
- on parse number error- See Also:
readTable(InputStream ios, String format, int maxLines)
-
readTable
public static List<TableParser.Record> readTable(InputStream ios, String format, int maxLines) throws IOException, NumberFormatException
Deprecated.Reads an input stream, containing lines of ascii in fixed width format. Breaks each line into a set of Fields (space or comma delimited) which may be String, integer or double.- Parameters:
ios
- the input stream, will be closedformat
- describe format of each line.maxLines
- maximum number of lines to parse, set to < 0 to read all- Returns:
- List of TableParser.Record
- Throws:
IOException
- on read errorNumberFormatException
- on parse number error
-
setComment
public void setComment(String comment)
Deprecated.
-
readAllRecords
public List<TableParser.Record> readAllRecords(InputStream ios, int maxLines) throws IOException, NumberFormatException
Deprecated.- Throws:
IOException
NumberFormatException
-
getField
public TableParser.Field getField(int fldno)
Deprecated.
-
getNumberOfFields
public int getNumberOfFields()
Deprecated.
-
addDerivedField
public TableParser.DerivedField addDerivedField(TableParser.Field from, TableParser.Transform transform, Class type)
Deprecated.
-
-