Statistics
| Revision:

root / trunk / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / driver / foodriver / FooDriver.java @ 10627

History | View | Annotate | Download (3.23 KB)

1
package com.hardcode.gdbms.driver.foodriver;
2

    
3
import java.sql.Connection;
4
import java.sql.Date;
5
import java.sql.SQLException;
6
import java.sql.Time;
7
import java.sql.Timestamp;
8
import java.util.HashMap;
9

    
10
import com.hardcode.gdbms.driver.exceptions.BadFieldDriverException;
11
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
12
import com.hardcode.gdbms.engine.data.DataSourceFactory;
13
import com.hardcode.gdbms.engine.data.driver.AlphanumericDBDriver;
14
import com.hardcode.gdbms.engine.spatial.GeneralPath;
15
import com.hardcode.gdbms.engine.spatial.GeometryImpl;
16
import com.hardcode.gdbms.engine.spatial.PTTypes;
17
import com.hardcode.gdbms.engine.values.Value;
18
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
19

    
20
public class FooDriver implements AlphanumericDBDriver {
21

    
22
        public Connection getConnection(String host, int port, String dbName, String user, String password) throws SQLException {
23
                return new FooConnection();
24
        }
25

    
26
        public void open(Connection con, String sql) throws SQLException {
27
        }
28

    
29
        public void execute(Connection con, String sql) throws SQLException {
30
        }
31

    
32
        public void close() throws SQLException {
33
        }
34

    
35
        public String getInternalTableName(String tablename) {
36
                return tablename;
37
        }
38

    
39
        public Value getFieldValue(long rowIndex, int fieldId) throws ReadDriverException {
40
                GeneralPath gp = new GeneralPath();
41
                gp.moveTo(10.0, 10.0);
42
                gp.lineTo(10.0, 20.0);
43
                gp.lineTo(20.0, 20.0);
44
                gp.lineTo(20.0, 10.0);
45
                gp.closePath();
46
                Value v = new GeometryImpl(gp);
47
                return v;
48
        }
49

    
50
        public int getFieldCount() throws ReadDriverException {
51
                return 1;
52
        }
53

    
54
        public String getFieldName(int fieldId) throws ReadDriverException {
55
                if (fieldId != 1) throw new BadFieldDriverException(getName(),null,String.valueOf(fieldId));
56
                return "Geometr?a";
57
        }
58

    
59
        public long getRowCount() throws ReadDriverException {
60
                return 1;
61
        }
62

    
63
        public int getFieldType(int i) throws ReadDriverException {
64
                if (i != 1) throw new BadFieldDriverException(getName(),null,String.valueOf(i));
65
                return PTTypes.GEOMETRY;
66
        }
67

    
68
        public String getName() {
69
                return "FooDriver";
70
        }
71

    
72
        public String getStatementString(long i) {
73
                throw new RuntimeException();
74
        }
75

    
76
        public String getStatementString(int i, int sqlType) {
77
                throw new RuntimeException();
78
        }
79

    
80
        public String getStatementString(double d, int sqlType) {
81
                throw new RuntimeException();
82
        }
83

    
84
        public String getStatementString(String str, int sqlType) {
85
                throw new RuntimeException();
86
        }
87

    
88
        public String getStatementString(Date d) {
89
                throw new RuntimeException();
90
        }
91

    
92
        public String getStatementString(Time t) {
93
                throw new RuntimeException();
94
        }
95

    
96
        public String getStatementString(Timestamp ts) {
97
                throw new RuntimeException();
98
        }
99

    
100
        public String getStatementString(byte[] binary) {
101
                throw new RuntimeException();
102
        }
103

    
104
        public String getStatementString(boolean b) {
105
                throw new RuntimeException();
106
        }
107

    
108
        public String getNullStatementString() {
109
                throw new RuntimeException();
110
        }
111

    
112
        public HashMap getDriverProperties() {
113
                return null;
114
        }
115

    
116
        public void setDataSourceFactory(DataSourceFactory dsf) {
117

    
118
        }
119

    
120
        public int getFieldWidth(int i) throws ReadDriverException {
121
                if (i != 1) throw new BadFieldDriverException(getName(),null,String.valueOf(i));
122
                return 1;
123
        }
124

    
125
        public ITableDefinition getTableDefinition() throws ReadDriverException {
126
                return null;
127
        }
128

    
129
}