Пример #1
0
        /**
         *
         * Retrieve a column's string value from the current row.
         *
         * @param column the column name
         * @see tinySQLTable#GetCol
         *
         */
        public override String GetCol(String column)
        {//throws tinySQLException {
            try
            {
                // get the column info
                //
                String[] info = (String[])column_info.get(column);

                // retrieve datatype, size, and position within row
                //
                String datatype = info[COLUMN_TYPE];
                int    size     = java.lang.Integer.parseInt(info[COLUMN_SIZE]);
                int    pos      = java.lang.Integer.parseInt(info[COLUMN_POS]);

                // save the file pointer
                //
                long OldPosition = ftbl.getFilePointer();

                // read the whole line from this row.
                //
                String line = ftbl.readLine();

                // retrieve the column from the line we just read,
                // at offset pos, for length size
                //
                String result = line.substring(pos, pos + size);

                // restore the file pointer
                //
                ftbl.seek(OldPosition);

                // trim the result if it was numeric
                //
                if (datatype.equals("NUMERIC"))
                {
                    return(result.trim());
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception e)
            {
                throw new TinySQLException(e.getMessage());
            }
        }