001/** 002 * Copyright 2015 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package core.tut.pori.dao.clause; 017 018/** 019 * <p>Create a raw sql WhereClause, the insertable sql string (such as COLUMN=? or COLUMN<9) can be added manually.</p> 020 * 021 * <p>This class can be used to create SQL WHERE clauses not supported by the built-in WhereClause implementations, 022 * without the need to implement a new WhereClause class.</p> 023 * 024 */ 025public class RawClause extends WhereClause{ 026 private String _sqlClause = null; 027 private Object[] _values = null; 028 private SQLType[] _types = null; 029 private ClauseType _type = null; 030 031 /** 032 * 033 * @param sqlClause the raw clause 034 * @param values optional list of values 035 * @param types optional list of types 036 * @param type type of this clause 037 */ 038 public RawClause(String sqlClause, Object[] values, SQLType[] types, ClauseType type){ 039 _sqlClause = sqlClause; 040 _values = values; 041 _type = type; 042 _types = types; 043 } 044 045 @Override 046 public SQLType[] getValueTypes() { 047 return _types; 048 } 049 050 @Override 051 public Object[] getValues() { 052 return _values; 053 } 054 055 @Override 056 public void toSQLString(StringBuilder sql) { 057 sql.append(_sqlClause); 058 } 059 060 @Override 061 public ClauseType getClauseType() { 062 return _type; 063 } 064}