File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\api\AggregateFunction.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.api;
8
9 import java.sql.Connection;
10 import java.sql.SQLException;
11
12 /**
13 * A user-defined aggregate function needs to implement this interface.
14 * The class must be public and must have a public non-argument constructor.
15 */
16 public interface AggregateFunction {
17
18 /**
19 * This method is called when the aggregate function is used.
20 * A new object is created for each invocation.
21 *
22 * @param conn a connection to the database
23 */
24 void init(Connection conn) throws SQLException;
25
26 /**
27 * This method must return the SQL type of the method, given the SQL type of
28 * the input data. The method should check here if the number of parameters
29 * passed is correct, and if not it should throw an exception.
30 *
31 * @param inputTypes the SQL type of the parameters
32 * @return the SQL type of the result
33 */
34 int getType(int[] inputTypes) throws SQLException;
35
36 /**
37 * This method is called once for each row.
38 * If the aggregate function is called with multiple parameters,
39 * those are passed as array.
40 *
41 * @param value the value(s) for this row
42 */
43 void add(Object value) throws SQLException;
44
45 /**
46 * This method returns the computed aggregate value.
47 *
48 * @return the aggregated value
49 */
50 Object getResult() throws SQLException;
51
52 }