1 package org.melati.poem.test;
2
3 import java.sql.PreparedStatement;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.sql.Types;
7
8 import org.melati.poem.AccessPoemException;
9 import org.melati.poem.AtomPoemType;
10 import org.melati.poem.ColumnInfo;
11 import org.melati.poem.NullTypeMismatchPoemException;
12 import org.melati.poem.ParsingPoemException;
13 import org.melati.poem.SQLPoemType;
14 import org.melati.poem.TypeMismatchPoemException;
15 import org.melati.poem.ValidationPoemException;
16 import org.melati.poem.dbms.Dbms;
17
18
19
20
21
22
23
24 public class SqlExceptionPoemType extends AtomPoemType<Integer> {
25
26
27
28
29
30
31
32 public SqlExceptionPoemType(boolean nullable) {
33 super(Types.INTEGER, "INT", nullable);
34 }
35
36
37
38
39
40
41 protected void _assertValidRaw(Object raw) throws ValidationPoemException {
42 if (raw == null)
43 throw new NullTypeMismatchPoemException(this);
44 if (! (raw instanceof Integer))
45 throw new TypeMismatchPoemException(raw, this);
46 }
47
48
49
50
51
52
53 protected boolean _canRepresent(SQLPoemType<?> other) {
54 return false;
55 }
56
57
58
59
60
61
62 protected Integer _getRaw(ResultSet rs, int col) throws SQLException {
63 throw new SQLException("Dummy");
64 }
65
66
67
68
69
70
71 protected Integer _rawOfString(String string) throws ParsingPoemException {
72
73 return new Integer(string);
74 }
75
76
77
78
79
80
81 protected void _saveColumnInfo(ColumnInfo info) throws AccessPoemException {
82
83 }
84
85
86
87
88
89
90
91 protected void _setRaw(PreparedStatement ps, int col, Object raw)
92 throws SQLException {
93 throw new SQLException("Dummy");
94
95 }
96
97
98
99
100
101
102 public String sqlDefaultValue(Dbms dbms) {
103 return "1";
104 }
105
106
107
108
109
110
111 public String toDsdType() {
112 return null;
113 }
114
115 }