*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ---------------
* ExpressionFunction.java
* ---------------
* Author: Volker Berlin
*
*/
package smallsql.database;
import java.sql.*;
abstract class ExpressionFunction extends Expression {
Expression param1;
Expression param2;
Expression param3;
Expression param4;
ExpressionFunction(){
super(FUNCTION);
}
abstract int getFunction();
byte[] getBytes() throws Exception{
return ExpressionValue.getBytes(getObject(), getDataType());
}
void setParams( Expression[] params ){
super.setParams( params );
if(params.length >0) param1 = params[0] ;
if(params.length >1) param2 = params[1] ;
if(params.length >2) param3 = params[2] ;
if(params.length >3) param4 = params[3] ;
}
final void setParamAt( Expression param, int idx){
switch(idx){
case 0:
param1 = param;
break;
case 1:
param2 = param;
break;
case 2:
param3 = param;
break;
case 3:
param4 = param;
break;
}
super.setParamAt( param, idx );
}
public boolean equals(Object expr){
if(!super.equals(expr)) return false;
if(!(expr instanceof ExpressionFunction)) return false;
if( ((ExpressionFunction)expr).getFunction() != getFunction()) return false;
return true;
}
SQLException createUnspportedDataType( int dataType ){
return Utils.createSQLException("Unsupported data type '" +
SQLTokenizer.getKeyWord(dataType) +
"' for function " +
SQLTokenizer.getKeyWord(getFunction()) );
}
SQLException createUnspportedConversion( int dataType ){
return Utils.createSQLException("Unsupported conversion to data type '" +
SQLTokenizer.getKeyWord(dataType) +
"' for function " +
SQLTokenizer.getKeyWord(getFunction()) );
}
}