// end methods implemented from tinySQLTable.java // the rest of this stuff is internal methods // for textFileTable // /* * * Reads in a table definition and populates the column_info * Hashtable * */ void readColumnInfo() {//throws tinySQLException { try { column_info = new java.util.Hashtable <Object, Object>(); // Open an FileInputStream to the .def (table // definition) file // java.io.FileInputStream fdef = new java.io.FileInputStream(dataDir + "/" + table + ".def"); // use a StreamTokenizer to break up the stream. // java.io.Reader r = new java.io.BufferedReader( new java.io.InputStreamReader(fdef)); java.io.StreamTokenizer def = new java.io.StreamTokenizer(r); // set the | as a delimiter, and set everything between // 0 and z as word characters. Let it know that eol is // *not* significant, and that it should parse numbers. // def.whitespaceChars('|', '|'); def.wordChars('0', 'z'); def.eolIsSignificant(false); def.parseNumbers(); // read each token from the tokenizer // while (def.nextToken() != java.io.StreamTokenizer.TT_EOF) { // first token is the datatype // // Q&D: Default is char value, numeric is special String datatype = java.lang.StringJ.valueOf(java.sql.Types.CHAR); if (def.sval.equals("NUMERIC")) { datatype = java.lang.StringJ.valueOf(java.sql.Types.NUMERIC); } // get the next token; it's the column name // def.nextToken(); String column = def.sval; // get the third token; it's the size of the column // def.nextToken(); long size = (new java.lang.Double(def.nval)).longValue(); // create an info array // String[] info = new String[3]; // store the datatype, the size, and the position // within the record (the record length *before* // we increment it with the size of this column // info[COLUMN_TYPE] = datatype; info[COLUMN_SIZE] = java.lang.Long.toString(size); info[COLUMN_POS] = java.lang.Long.toString(record_length); // this is the start position of the next column // record_length += size; // store this info in the column_info hash, // keyed by column name. // column_info.put(column, info); } fdef.close(); // close the file } catch (Exception e) { throw new TinySQLException(e.getMessage()); } }