home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import symjava.lang.Bignum;
- import symjava.sql.Date;
- import symjava.sql.SQLException;
- import symjava.sql.Time;
- import symjava.sql.Timestamp;
-
- abstract class CharField extends Field {
- String _data;
-
- void read(DataInputStream var1) throws SQLException, IOException, ErrorException {
- super.read(var1);
- this._data = new String("");
- }
-
- void write(DataOutputStream var1) throws IOException {
- super.write(var1);
- }
-
- public String getString() throws SQLException {
- return ((Field)this).isNull() ? null : new String(this._data);
- }
-
- public boolean getBoolean() throws SQLException {
- if (((Field)this).isNull()) {
- return false;
- } else {
- byte var1 = (byte)this._data.charAt(0);
- return var1 != 0;
- }
- }
-
- public byte getByte() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- try {
- Double var1 = new Double(this._data);
- return (byte)var1.intValue();
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public short getShort() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- try {
- Double var1 = new Double(this._data);
- return (short)var1.intValue();
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public int getInt() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- try {
- Double var1 = new Double(this._data);
- return var1.intValue();
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public long getLong() throws SQLException {
- if (((Field)this).isNull()) {
- return 0L;
- } else {
- try {
- Double var1 = new Double(this._data);
- return var1.longValue();
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public float getFloat() throws SQLException {
- if (((Field)this).isNull()) {
- return 0.0F;
- } else {
- try {
- Double var1 = new Double(this._data);
- return var1.floatValue();
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public double getDouble() throws SQLException {
- if (((Field)this).isNull()) {
- return (double)0.0F;
- } else {
- try {
- Double var1 = new Double(this._data);
- return var1;
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public Bignum getBignum(int var1) throws SQLException {
- return ((Field)this).isNull() ? null : new Bignum(this._data, var1);
- }
-
- public byte[] getBytes() throws SQLException {
- if (((Field)this).isNull()) {
- return new byte[0];
- } else {
- try {
- byte[] var1 = new byte[this._data.length()];
- this._data.getBytes(0, this._data.length() - 1, var1, 0);
- return var1;
- } catch (Exception var2) {
- throw new SQLException(((Throwable)var2).getMessage());
- }
- }
- }
-
- public Date getDate() throws SQLException {
- return ((Field)this).isNull() ? null : Date.valueOf(this._data);
- }
-
- public Time getTime() throws SQLException {
- return ((Field)this).isNull() ? null : Time.valueOf(this._data);
- }
-
- public Timestamp getTimestamp() throws SQLException {
- return ((Field)this).isNull() ? null : Timestamp.valueOf(this._data);
- }
-
- public InputStream getAsciiStream() throws SQLException {
- return ((Field)this).isNull() ? null : new BinaryInputStream(this._data);
- }
-
- public InputStream getUnicodeStream() throws SQLException {
- return ((Field)this).isNull() ? null : new BinaryInputStream(this._data);
- }
-
- public InputStream getBinaryStream() throws SQLException {
- return ((Field)this).isNull() ? null : new BinaryInputStream(this._data);
- }
-
- public void setBoolean(boolean var1) throws SQLException {
- if (var1) {
- this._data = new String("true");
- } else {
- this._data = new String("false");
- }
-
- super._null = false;
- }
-
- public void setByte(byte var1) throws SQLException {
- this._data = Integer.toString(var1);
- super._null = false;
- }
-
- public void setShort(short var1) throws SQLException {
- this._data = Integer.toString(var1);
- super._null = false;
- }
-
- public void setInt(int var1) throws SQLException {
- this._data = Integer.toString(var1);
- super._null = false;
- }
-
- public void setLong(long var1) throws SQLException {
- this._data = Long.toString(var1);
- super._null = false;
- }
-
- public void setFloat(float var1) throws SQLException {
- this._data = Float.toString(var1);
- super._null = false;
- }
-
- public void setDouble(double var1) throws SQLException {
- this._data = Double.toString(var1);
- super._null = false;
- }
-
- public void setBignum(Bignum var1) throws SQLException {
- this._data = var1.toString();
- super._null = false;
- }
-
- public void setString(String var1) throws SQLException {
- this._data = var1;
- super._null = false;
- }
-
- public void setBytes(byte[] var1) throws SQLException {
- this._data = new String(var1, 0);
- super._null = false;
- }
-
- public void setDate(Date var1) throws SQLException {
- this._data = var1.toString();
- super._null = false;
- }
-
- public void setTime(Time var1) throws SQLException {
- this._data = var1.toString();
- super._null = false;
- }
-
- public void setTimestamp(Timestamp var1) throws SQLException {
- this._data = var1.toString();
- super._null = false;
- }
-
- public void setStream(InputStream var1, int var2) throws SQLException {
- if (var2 >= 0 && var2 <= 255) {
- byte[] var3 = new byte[var2];
-
- try {
- var1.read(var3, 0, var2);
- } catch (IOException var5) {
- throw new SQLException(((Throwable)var5).getMessage());
- }
-
- this._data = new String(var3, 0, 0, var3.length);
- super._null = false;
- } else {
- throw new SQLException("Stream length out of range.");
- }
- }
-
- public void setAsciiStream(InputStream var1, int var2) throws SQLException {
- this.setStream(var1, var2);
- }
-
- public void setUnicodeStream(InputStream var1, int var2) throws SQLException {
- this.setStream(var1, var2);
- }
-
- public void setBinaryStream(InputStream var1, int var2) throws SQLException {
- this.setStream(var1, var2);
- }
- }
-