1 10 11 package com.triactive.jdo.store; 12 13 import java.math.BigInteger ; 14 import java.sql.DatabaseMetaData ; 15 import java.sql.ResultSet ; 16 import java.sql.Types ; 17 import java.util.ArrayList ; 18 19 20 29 30 class SAPDBAdapter extends DatabaseAdapter 31 { 32 37 38 protected SAPDBAdapter(DatabaseMetaData metadata) 39 { 40 super(metadata); 41 } 42 43 public String getVendorID() 44 { 45 return "sapdb"; 46 } 47 48 public TypeInfo newTypeInfo(ResultSet rs) 49 { 50 TypeInfo ti = new SAPDBTypeInfo(rs); 51 52 59 if (ti.dataType == Types.VARBINARY) 60 return null; 61 62 return ti; 63 } 64 65 public boolean supportsAlterTableDropConstraint() 66 { 67 return false; 68 } 69 70 public boolean supportsBooleanComparison() 71 { 72 return false; 73 } 74 75 public boolean supportsDeferredConstraints() 76 { 77 return false; 78 } 79 80 public TableExpression newTableExpression(QueryStatement qs, Table table, SQLIdentifier rangeVar) 81 { 82 return new TableExprAsJoins(qs, table, rangeVar); 83 } 84 85 public String getAddPrimaryKeyStatement(SQLIdentifier pkName, PrimaryKey pk) 86 { 87 return "ALTER TABLE " + pk.getTable().getName() + " ADD " + pk; 88 } 89 90 public String getAddCandidateKeyStatement(SQLIdentifier ckName, CandidateKey ck) 91 { 92 return getCreateIndexStatement(ckName, new Index(ck)); 93 } 94 95 public String getAddForeignKeyStatement(SQLIdentifier fkName, ForeignKey fk) 96 { 97 return "ALTER TABLE " + fk.getTable().getName() + " ADD " + fk; 98 } 99 100 public NumericExpression lengthMethod(CharacterExpression str) 101 { 102 ArrayList args = new ArrayList (); 103 args.add(str); 104 105 return new NumericExpression("LENGTH", args); 106 } 107 108 public CharacterExpression substringMethod(CharacterExpression str, 109 NumericExpression begin) 110 { 111 ArrayList args = new ArrayList (); 112 args.add(str); 113 args.add(begin.add(new IntegerLiteral(str.getQueryStatement(), BigInteger.ONE))); 114 115 return new CharacterExpression("SUBSTR", args); 116 } 117 118 public CharacterExpression substringMethod(CharacterExpression str, 119 NumericExpression begin, 120 NumericExpression end) 121 { 122 ArrayList args = new ArrayList (); 123 args.add(str); 124 args.add(begin.add(new IntegerLiteral(str.getQueryStatement(), BigInteger.ONE))); 125 args.add(end.sub(begin)); 126 127 return new CharacterExpression("SUBSTR", args); 128 } 129 } 130 | Popular Tags |