-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathColumnMetaData.java
More file actions
149 lines (118 loc) · 5.33 KB
/
ColumnMetaData.java
File metadata and controls
149 lines (118 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* Copyright (c) restSQL Project Contributors. Licensed under MIT. */
package org.restsql.core;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.restsql.core.TableMetaData.TableRole;
/**
* Encapsulates column (or field) metadata of an SQL Resource.
*
* @author Mark Sawers
* @see SqlResource
* @see TableMetaData
*/
public interface ColumnMetaData extends Comparable<ColumnMetaData> {
/**
* Compares another column based on the column number of the select clause in the SQL Resource definition query.
* Implements Comparable interface.
*/
@Override
public int compareTo(ColumnMetaData column);
/**
* Returns column label, a string identified in double quotes after columns in the select clause in the SQL Resource
* definition query.
*/
public String getColumnLabel();
/** Returns column name, as it is known by the database. */
public String getColumnName();
/** Returns column number in the select clause in the SQL Resource definition query. */
public int getColumnNumber();
/**
* Returns column type from java.sql.Types.
*
* @return java.sql.Types constant
* @see java.sql.Types
*/
public int getColumnType();
/** Returns column type name as given by the database JDBC driver. */
public String getColumnTypeName();
/** Returns database name. */
public String getDatabaseName();
/**
* Returns fully qualified column label in database-specific form for use in SQL statements. MySQL uses the form
* <code>database.table.label</code>, for example <code>sakila.film.id</code>. PostgreSQL can only use
* <code>label</code> and cannot disambiguate by table source.
*/
public String getQualifiedColumnLabel();
/**
* Returns fully qualified column name in database-specific form for use in SQL statements. MySQL uses the form
* <code>database.table.column</code>, for example <code>sakila.film.film_id</code>. PostgreSQL uses the form
* <code>database.schema.table.column</code>, for example <code>sakila.public.film.film_id</code>.
*/
public String getQualifiedColumnName();
/**
* Returns fully qualified table name in database-specific form for use in SQL statements. MySQL uses the form
* <code>database.table</code>, for example <code>sakila.film</code>. PostgreSQL uses the form
* <code>database.schema.table</code>, for example <code>sakila.public.film</code>.
*/
public String getQualifiedTableName();
/** Returns object from result set using the column label. */
public Object getResultByLabel(ResultSet resultSet) throws SQLException;
/** Returns object from result set using the column number. */
public Object getResultByNumber(ResultSet resultSet) throws SQLException;
/** Returns sequence name associated with column or null if none. For MySQL, returns table name. */
public String getSequenceName();
/** Returns table name. */
public String getTableName();
/** Returns role of table in the SQL Resource. */
public TableRole getTableRole();
/** Returns true if type is BINARY, BLOB, JAVA OBJECT or LONGVARBINARY. */
public boolean isBinaryType();
/** Returns true if column is a character string or date, time or timestamp. */
public boolean isCharOrDateTimeType();
/**
* Returns true for foreign key columns not declared in the SQL Resource query but added by the framework. These are
* required for writes to child extensions, parent extensions and and one-to-many child tables.
*/
public boolean isNonqueriedForeignKey();
/** Returns true if the column is a primary key. */
public boolean isPrimaryKey();
/** Returns true if the column is read-only, for example derived from SQL function or a database view. */
public boolean isReadOnly();
/**
* Returns true if column is associated with a sequence.
*
* @see #getSequenceName()
*/
public boolean isSequence();
/**
* Converts String value to a numeric Object, Date or UUDecode String into Object if required using the column
* metadata.
*
* @param requestValue parameter or resource identifier
* @throws InvalidRequestException if conversion failed
*/
public void normalizeValue(final RequestValue requestValue) throws InvalidRequestException;
/**
* Used for all columns declared in the SqlResource select clause.
*/
public void setAttributes(final int columnNumber, final String databaseName,
final String qualifiedTableName, final String tableName, final String columnName,
final String qualifiedColumnName, final String columnLabel, final String qualifiedColumnLabel,
final String columnTypeName, final int columnType, final boolean readOnly);
/**
* Used for foreign key columns not declared in the SqlResource select columns. These are required for writes to
* child extensions, parent extensions and child tables.
*/
public void setAttributes(final String databaseName, final String sqlQualifiedTableName,
final String tableName, final TableRole tableRole, final String columnName,
final String qualifiedColumnName, final String columnLabel, final String qualifiedColumnLabel,
final String columnTypeString);
/** Sets primary key. */
public void setPrimaryKey(final boolean primaryKey);
/** Sets true if column populated with a sequence function (auto increment). */
public void setSequence(final boolean sequence);
/** Sets sequence name. */
public void setSequenceName(final String sequenceName);
/** Sets table role. */
public void setTableRole(final TableRole tableRole);
}