KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > FirebirdAdapter


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: FirebirdAdapter.java,v 1.2 2002/12/23 00:04:13 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.math.BigInteger JavaDoc;
14 import java.sql.DatabaseMetaData JavaDoc;
15 import java.util.ArrayList JavaDoc;
16
17
18 /**
19  * Provides methods for adapting SQL language elements to the Firebird database.
20  *
21  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
22  * @version $Revision: 1.2 $
23  *
24  * @see DatabaseAdapter
25  */

26
27 class FirebirdAdapter extends DatabaseAdapter
28 {
29     /**
30      * Constructs a Firebird adapter based on the given JDBC metadata.
31      *
32      * @param metadata the database metadata.
33      */

34
35     protected FirebirdAdapter(DatabaseMetaData JavaDoc metadata)
36     {
37         super(metadata);
38     }
39
40     public String JavaDoc getVendorID()
41     {
42         return "firebird";
43     }
44
45     public String JavaDoc getDropTableStatement(BaseTable table)
46     {
47         return "DROP TABLE " + table.getName();
48     }
49
50
51     public boolean supportsDeferredConstraints()
52     {
53         return false;
54     }
55
56     public boolean supportsBooleanComparison()
57     {
58         return false;
59     }
60
61     public boolean supportsNullsInCandidateKeys()
62     {
63         return false;
64     }
65
66     public TableExpression newTableExpression(QueryStatement qs, Table table, SQLIdentifier rangeVar)
67     {
68         return new TableExprAsJoins(qs, table, rangeVar);
69     }
70
71     public NumericExpression lengthMethod(CharacterExpression str)
72     {
73         ArrayList JavaDoc args = new ArrayList JavaDoc();
74         args.add(str);
75
76         return new NumericExpression("STRLEN", args);
77     }
78
79     public CharacterExpression substringMethod(CharacterExpression str,
80                                                NumericExpression begin)
81     {
82         ArrayList JavaDoc args = new ArrayList JavaDoc();
83         args.add(str);
84         args.add(begin.add(new IntegerLiteral(str.getQueryStatement(), BigInteger.ONE)));
85
86         return new CharacterExpression("SUBSTR", args);
87     }
88
89     public CharacterExpression substringMethod(CharacterExpression str,
90                                                NumericExpression begin,
91                                                NumericExpression end)
92     {
93         ArrayList JavaDoc args = new ArrayList JavaDoc();
94         args.add(str);
95         args.add(begin.add(new IntegerLiteral(str.getQueryStatement(), BigInteger.ONE)));
96         args.add(end);
97
98         return new CharacterExpression("SUBSTR", args);
99     }
100 }
101
Popular Tags