svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.sqlite / org.gvsig.sqlite.provider / src / main / java / org / gvsig / sqlite / dal / functions / Functions.java @ 47456
History | View | Annotate | Download (2.42 KB)
1 |
package org.gvsig.sqlite.dal.functions; |
---|---|
2 |
|
3 |
import java.sql.Connection; |
4 |
import java.sql.SQLException; |
5 |
import org.sqlite.SQLiteConnection; |
6 |
|
7 |
/**
|
8 |
*
|
9 |
* @author jjdelcerro
|
10 |
*/
|
11 |
public class Functions { |
12 |
|
13 |
public static interface Function { |
14 |
public SQLiteConnection getConnection();
|
15 |
public String getName(); |
16 |
public org.sqlite.Function getFunction();
|
17 |
} |
18 |
|
19 |
public static abstract class AbstractFunction extends org.sqlite.Function implements Function { |
20 |
|
21 |
private final SQLiteConnection conn; |
22 |
private final String name; |
23 |
|
24 |
public AbstractFunction(String name, SQLiteConnection conn) { |
25 |
this.conn = conn;
|
26 |
this.name = name;
|
27 |
} |
28 |
|
29 |
@Override
|
30 |
public SQLiteConnection getConnection() {
|
31 |
return this.conn; |
32 |
} |
33 |
|
34 |
@Override
|
35 |
public String getName() { |
36 |
return this.name; |
37 |
} |
38 |
|
39 |
@Override
|
40 |
public org.sqlite.Function getFunction() {
|
41 |
return this; |
42 |
} |
43 |
} |
44 |
|
45 |
public static abstract class AbstractAggregate extends org.sqlite.Function.Aggregate implements Function { |
46 |
|
47 |
private final SQLiteConnection conn; |
48 |
private final String name; |
49 |
|
50 |
public AbstractAggregate(String name, SQLiteConnection conn) { |
51 |
this.conn = conn;
|
52 |
this.name = name;
|
53 |
} |
54 |
|
55 |
@Override
|
56 |
public SQLiteConnection getConnection() {
|
57 |
return this.conn; |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public String getName() { |
62 |
return this.name; |
63 |
} |
64 |
|
65 |
@Override
|
66 |
public org.sqlite.Function.Aggregate getFunction() {
|
67 |
return this; |
68 |
} |
69 |
} |
70 |
|
71 |
public static void register_all(SQLiteConnection conn) throws SQLException { |
72 |
Function[] functions = new Function[]{ |
73 |
new Json_value(conn),
|
74 |
new Reverse(conn),
|
75 |
new Reverseinstr(conn),
|
76 |
new ST_Intersects(conn),
|
77 |
new ST_AsBinary(conn),
|
78 |
new ST_MaxX(conn),
|
79 |
new ST_MaxY(conn),
|
80 |
new ST_MinX(conn),
|
81 |
new ST_MinY(conn),
|
82 |
new ST_GeomFromWKB(conn),
|
83 |
new ST_Extent(conn),
|
84 |
new ST_ExtentAggregate(conn)
|
85 |
}; |
86 |
|
87 |
for (Function function : functions) {
|
88 |
org.sqlite.Function.create(conn, function.getName(), function.getFunction()); |
89 |
} |
90 |
} |
91 |
|
92 |
} |