01: /*
02: * Copyright 2007 JBoss Inc
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 Jun 20, 2007
17: */
18: package org.drools.base.accumulators;
19:
20: /**
21: * An interface for accumulate external function implementations
22: *
23: * @author etirelli
24: *
25: */
26: public interface AccumulateFunction {
27:
28: /**
29: * Creates and returns a new context object
30: * @return
31: */
32: public Object createContext();
33:
34: /**
35: * Initializes the accumulator
36: * @param context
37: * @throws Exception
38: */
39: public void init(Object context) throws Exception;
40:
41: /**
42: * Executes the accumulation action
43: * @param context
44: * @param value
45: */
46: public void accumulate(Object context, Object value);
47:
48: /**
49: * Reverses the accumulation action
50: * @param context
51: * @param value
52: * @throws Exception
53: */
54: public void reverse(Object context, Object value) throws Exception;
55:
56: /**
57: * Returns the current value in this accumulation session
58: *
59: * @param context
60: * @return
61: * @throws Exception
62: */
63: public Object getResult(Object context) throws Exception;
64:
65: /**
66: * True if the function supports reverse. False otherwise.
67: *
68: * @return
69: */
70: public boolean supportsReverse();
71:
72: }
|