]> granicus.if.org Git - postgresql/blob - src/interfaces/jdbc/org/postgresql/core/Field.java
Add to mmap emails.
[postgresql] / src / interfaces / jdbc / org / postgresql / core / Field.java
1 /*-------------------------------------------------------------------------
2  *
3  * Field.java
4  *     Field is a class used to describe fields in a PostgreSQL ResultSet
5  *
6  * Copyright (c) 2003, PostgreSQL Global Development Group
7  *
8  * IDENTIFICATION
9  *        $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.1 2003/03/07 18:39:41 barry Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 package org.postgresql.core;
14
15 import java.lang.*;
16 import java.sql.*;
17 import java.util.*;
18 import org.postgresql.core.BaseConnection;
19 import org.postgresql.util.PSQLException;
20
21 /*
22  */
23 public class Field
24 {
25         private int length;             // Internal Length of this field
26         private int oid;                // OID of the type
27         private int mod;                // type modifier of this field
28         private String name;            // Name of this field
29
30         private BaseConnection conn;    // Connection Instantation
31
32
33         /*
34          * Construct a field based on the information fed to it.
35          *
36          * @param conn the connection this field came from
37          * @param name the name of the field
38          * @param oid the OID of the field
39          * @param len the length of the field
40          */
41         public Field(BaseConnection conn, String name, int oid, int length, int mod)
42         {
43                 this.conn = conn;
44                 this.name = name;
45                 this.oid = oid;
46                 this.length = length;
47                 this.mod = mod;
48         }
49
50         /*
51          * Constructor without mod parameter.
52          *
53          * @param conn the connection this field came from
54          * @param name the name of the field
55          * @param oid the OID of the field
56          * @param len the length of the field
57          */
58         public Field(BaseConnection conn, String name, int oid, int length)
59         {
60                 this(conn, name, oid, length, 0);
61         }
62
63         /*
64          * @return the oid of this Field's data type
65          */
66         public int getOID()
67         {
68                 return oid;
69         }
70
71         /*
72          * @return the mod of this Field's data type
73          */
74         public int getMod()
75         {
76                 return mod;
77         }
78
79         /*
80          * @return the name of this Field's data type
81          */
82         public String getName()
83         {
84                 return name;
85         }
86
87         /*
88          * @return the length of this Field's data type
89          */
90         public int getLength()
91         {
92                 return length;
93         }
94
95         /*
96          * We also need to get the PG type name as returned by the back end.
97          *
98          * @return the String representation of the PG type of this field
99          * @exception SQLException if a database access error occurs
100          */
101         public String getPGType() throws SQLException
102         {
103                 return conn.getPGType(oid);
104         }
105
106         /*
107          * We also need to get the java.sql.types type.
108          *
109          * @return the int representation of the java.sql.types type of this field
110          * @exception SQLException if a database access error occurs
111          */
112         public int getSQLType() throws SQLException
113         {
114                 return conn.getSQLType(oid);
115         }
116
117 }