01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: FirebirdAdapter.java,v 1.2 2002/12/23 00:04:13 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.math.BigInteger;
14: import java.sql.DatabaseMetaData;
15: import java.util.ArrayList;
16:
17: /**
18: * Provides methods for adapting SQL language elements to the Firebird database.
19: *
20: * @author <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
21: * @version $Revision: 1.2 $
22: *
23: * @see DatabaseAdapter
24: */
25:
26: class FirebirdAdapter extends DatabaseAdapter {
27: /**
28: * Constructs a Firebird adapter based on the given JDBC metadata.
29: *
30: * @param metadata the database metadata.
31: */
32:
33: protected FirebirdAdapter(DatabaseMetaData metadata) {
34: super (metadata);
35: }
36:
37: public String getVendorID() {
38: return "firebird";
39: }
40:
41: public String getDropTableStatement(BaseTable table) {
42: return "DROP TABLE " + table.getName();
43: }
44:
45: public boolean supportsDeferredConstraints() {
46: return false;
47: }
48:
49: public boolean supportsBooleanComparison() {
50: return false;
51: }
52:
53: public boolean supportsNullsInCandidateKeys() {
54: return false;
55: }
56:
57: public TableExpression newTableExpression(QueryStatement qs,
58: Table table, SQLIdentifier rangeVar) {
59: return new TableExprAsJoins(qs, table, rangeVar);
60: }
61:
62: public NumericExpression lengthMethod(CharacterExpression str) {
63: ArrayList args = new ArrayList();
64: args.add(str);
65:
66: return new NumericExpression("STRLEN", args);
67: }
68:
69: public CharacterExpression substringMethod(CharacterExpression str,
70: NumericExpression begin) {
71: ArrayList args = new ArrayList();
72: args.add(str);
73: args.add(begin.add(new IntegerLiteral(str.getQueryStatement(),
74: BigInteger.ONE)));
75:
76: return new CharacterExpression("SUBSTR", args);
77: }
78:
79: public CharacterExpression substringMethod(CharacterExpression str,
80: NumericExpression begin, NumericExpression end) {
81: ArrayList args = new ArrayList();
82: args.add(str);
83: args.add(begin.add(new IntegerLiteral(str.getQueryStatement(),
84: BigInteger.ONE)));
85: args.add(end);
86:
87: return new CharacterExpression("SUBSTR", args);
88: }
89: }
|