1
/*-------------------------------------------------------------------------
4
* Field is a class used to describe fields in a PostgreSQL ResultSet
6
* Copyright (c) 2003, PostgreSQL Global Development Group
9
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.2.4.1 2004/03/29 17:47:47 barry Exp $
11
*-------------------------------------------------------------------------
13
package org.postgresql.core;
16
import org.postgresql.core.BaseConnection;
22
//Constants for the two V3 protocol data formats
23
public static final int TEXT_FORMAT = 0;
24
public static final int BINARY_FORMAT = 1;
26
private int length; // Internal Length of this field
27
private int oid; // OID of the type
28
private int mod; // type modifier of this field
29
private String name; // Name of this field
30
private int format = TEXT_FORMAT; // In the V3 protocol each field has a format
31
// 0 = text, 1 = binary
32
// In the V2 protocol all fields in a
33
// binary cursor are binary and all
36
private BaseConnection conn; // Connection Instantation
40
* Construct a field based on the information fed to it.
42
* @param conn the connection this field came from
43
* @param name the name of the field
44
* @param oid the OID of the field
45
* @param len the length of the field
47
public Field(BaseConnection conn, String name, int oid, int length, int mod)
57
* Constructor without mod parameter.
59
* @param conn the connection this field came from
60
* @param name the name of the field
61
* @param oid the OID of the field
62
* @param len the length of the field
64
public Field(BaseConnection conn, String name, int oid, int length)
66
this(conn, name, oid, length, 0);
70
* @return the oid of this Field's data type
78
* @return the mod of this Field's data type
86
* @return the name of this Field's data type
88
public String getName()
94
* @return the length of this Field's data type
96
public int getLength()
102
* @return the format of this Field's data (text=0, binary=1)
104
public int getFormat()
110
* @param format the format of this Field's data (text=0, binary=1)
112
public void setFormat(int format)
114
this.format = format;
118
* We also need to get the PG type name as returned by the back end.
120
* @return the String representation of the PG type of this field
121
* @exception SQLException if a database access error occurs
123
public String getPGType() throws SQLException
125
return conn.getPGType(oid);
129
* We also need to get the java.sql.types type.
131
* @return the int representation of the java.sql.types type of this field
132
* @exception SQLException if a database access error occurs
134
public int getSQLType() throws SQLException
136
return conn.getSQLType(oid);