| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PlatformMckoiImpl |
|
| 2.5;2.5 |
| 1 | /** | |
| 2 | * Copyright 2005-2011 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | /* Created on Sep 13, 2005 */ | |
| 17 | package org.apache.ojb.broker.platforms; | |
| 18 | ||
| 19 | ||
| 20 | ||
| 21 | import java.io.ByteArrayInputStream; | |
| 22 | import java.io.InputStreamReader; | |
| 23 | import java.io.Reader; | |
| 24 | import java.io.StringReader; | |
| 25 | import java.sql.PreparedStatement; | |
| 26 | import java.sql.SQLException; | |
| 27 | import java.sql.Types; | |
| 28 | ||
| 29 | import org.apache.ojb.broker.query.LikeCriteria; | |
| 30 | ||
| 31 | /** | |
| 32 | * DatabasePlatform implementation for the Mckoi database. | |
| 33 | * | |
| 34 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 35 | * @see http://www.mckoi.com/database | |
| 36 | */ | |
| 37 | 0 | public class PlatformMckoiImpl extends PlatformDefaultImpl |
| 38 | { | |
| 39 | /* (non-Javadoc) | |
| 40 | * @see DatabasePlatform#setObjectForStatement(PreparedStatement, int, Object, int) | |
| 41 | */ | |
| 42 | public void setObjectForStatement(PreparedStatement statement, int index, Object value, int sqlType) throws SQLException | |
| 43 | { | |
| 44 | 0 | switch (sqlType) |
| 45 | { | |
| 46 | case Types.BLOB : | |
| 47 | case Types.LONGVARBINARY : | |
| 48 | case Types.VARBINARY : | |
| 49 | 0 | if (value instanceof byte[]) |
| 50 | { | |
| 51 | 0 | byte[] buf = (byte[])value; |
| 52 | 0 | ByteArrayInputStream inputStream = new ByteArrayInputStream(buf); |
| 53 | 0 | statement.setBinaryStream(index, inputStream, buf.length); |
| 54 | ||
| 55 | 0 | break; |
| 56 | } | |
| 57 | ||
| 58 | case Types.CLOB : | |
| 59 | 0 | Reader reader = null; |
| 60 | 0 | int length = 0; |
| 61 | ||
| 62 | 0 | if (value instanceof String) |
| 63 | { | |
| 64 | 0 | reader = new StringReader((String)value); |
| 65 | 0 | length = (((String)value)).length(); |
| 66 | } | |
| 67 | 0 | else if (value instanceof char[]) |
| 68 | { | |
| 69 | 0 | String string = new String((char[])value); |
| 70 | ||
| 71 | 0 | reader = new StringReader(string); |
| 72 | 0 | length = string.length(); |
| 73 | 0 | } |
| 74 | 0 | else if (value instanceof byte[]) |
| 75 | { | |
| 76 | 0 | ByteArrayInputStream inputStream = new ByteArrayInputStream((byte[])value); |
| 77 | ||
| 78 | 0 | reader = new InputStreamReader(inputStream); |
| 79 | } | |
| 80 | 0 | statement.setCharacterStream(index, reader, length); |
| 81 | 0 | break; |
| 82 | ||
| 83 | default : | |
| 84 | 0 | super.setObjectForStatement(statement, index, value, sqlType); |
| 85 | ||
| 86 | } | |
| 87 | 0 | } |
| 88 | ||
| 89 | /* (non-Javadoc) | |
| 90 | * @see org.apache.ojb.broker.platforms.Platform#createSequenceQuery(String) | |
| 91 | */ | |
| 92 | public String createSequenceQuery(String sequenceName) | |
| 93 | { | |
| 94 | 0 | return "create sequence " + sequenceName; |
| 95 | } | |
| 96 | ||
| 97 | /* (non-Javadoc) | |
| 98 | * @see org.apache.ojb.broker.platforms.Platform#nextSequenceQuery(String) | |
| 99 | */ | |
| 100 | public String nextSequenceQuery(String sequenceName) | |
| 101 | { | |
| 102 | 0 | return "select nextval('" + sequenceName + "')"; |
| 103 | } | |
| 104 | ||
| 105 | /* (non-Javadoc) | |
| 106 | * @see org.apache.ojb.broker.platforms.Platform#dropSequenceQuery(String) | |
| 107 | */ | |
| 108 | public String dropSequenceQuery(String sequenceName) | |
| 109 | { | |
| 110 | 0 | return "drop sequence " + sequenceName; |
| 111 | } | |
| 112 | ||
| 113 | /* (non-Javadoc) | |
| 114 | * @see org.apache.ojb.broker.platforms.Platform#getJoinSyntaxType() | |
| 115 | */ | |
| 116 | public byte getJoinSyntaxType() | |
| 117 | { | |
| 118 | 0 | return SQL92_NOPAREN_JOIN_SYNTAX; |
| 119 | } | |
| 120 | ||
| 121 | /* (non-Javadoc) | |
| 122 | * @see org.apache.ojb.broker.platforms.Platform#supportsPaging() | |
| 123 | */ | |
| 124 | public boolean supportsPaging() | |
| 125 | { | |
| 126 | // [tomdz] there is no explicit paging support a la LIMIT in Mckoi (yet ?) | |
| 127 | 0 | return false; |
| 128 | } | |
| 129 | ||
| 130 | /* (non-Javadoc) | |
| 131 | * @see org.apache.ojb.broker.platforms.Platform#concatenate(java.lang.String[]) | |
| 132 | */ | |
| 133 | public String concatenate(String[] columns) | |
| 134 | { | |
| 135 | 0 | if (columns.length == 1) |
| 136 | { | |
| 137 | 0 | return columns[0]; |
| 138 | } | |
| 139 | ||
| 140 | 0 | StringBuffer buf = new StringBuffer(); |
| 141 | ||
| 142 | 0 | buf.append("concat("); |
| 143 | 0 | for (int idx = 0; idx < columns.length; idx++) |
| 144 | { | |
| 145 | 0 | if (idx > 0) |
| 146 | { | |
| 147 | 0 | buf.append(","); |
| 148 | } | |
| 149 | 0 | buf.append(columns[idx]); |
| 150 | } | |
| 151 | 0 | buf.append(")"); |
| 152 | ||
| 153 | 0 | return buf.toString(); |
| 154 | } | |
| 155 | ||
| 156 | /* (non-Javadoc) | |
| 157 | * @see org.apache.ojb.broker.platforms.Platform#getEscapeClause(org.apache.ojb.broker.query.LikeCriteria) | |
| 158 | */ | |
| 159 | public String getEscapeClause(LikeCriteria criteria) | |
| 160 | { | |
| 161 | // [tomdz] Mckoi does not support escape characters other than \ | |
| 162 | // TODO Shold we throw some kind of exception here if the escape character is different ? | |
| 163 | 0 | return ""; |
| 164 | } | |
| 165 | } |