1 package org.apache.torque.util.functions; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.torque.Column; 23 24 /** 25 * Define the basic methods that classes that support SQL Functions 26 * need to implement for Classes that use them. This is intended to 27 * allow code to be written before functions are fully integrated 28 * with the DBAdaptors. As well as allowing for functions to 29 * expand as needed. 30 * 31 * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a> 32 * @version $Id: SQLFunction.java 1388656 2012-09-21 19:59:16Z tfischer $ 33 */ 34 public interface SQLFunction extends Column 35 { 36 /** 37 * Returns the function parameters at index i. 38 * Should be null if parameter does not exist. 39 * 40 * @param i The 0 based parameter to get. 41 * @return The parameter. Null if one does not exist. 42 */ 43 Object getArgument(int i); 44 45 /** 46 * Returns the column to which this function is applied. 47 * 48 * @return the column, not null. 49 * 50 * @throws IllegalStateException if the column cannot be determined. 51 */ 52 Column getColumn(); 53 54 /** 55 * Return all the parameters as an object array. This allow for 56 * processing of the parameters in their original format rather 57 * than just in String format. E.g. a parameter might be specified 58 * as a Date object, or a Column object. 59 * 60 * @return Should return a valid Object array and not null. E.g. 61 * implementors should return new Object[0] if there are no parameters. 62 */ 63 Object[] getArguments(); 64 65 /** 66 * Sets the function specific arguments. Note, this should generally 67 * only be called by FunctionFactory. 68 * 69 * @param args The function specific arguments. 70 */ 71 void setArguments(Object[] args); 72 }