01: package org.mvel.tests.main.res;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import static org.mvel.MVEL.parseMacros;
20: import org.mvel.Macro;
21:
22: import java.util.HashMap;
23: import java.util.Map;
24:
25: public class KnowledgeHelperFixer {
26:
27: public String fix(final String raw) {
28: if (raw == null) {
29: return raw;
30: }
31:
32: Map macros = new HashMap(5);
33:
34: macros.put("insert", new Macro() {
35: public String doMacro() {
36: return "drools.insert";
37: }
38: });
39:
40: macros.put("insertLogical", new Macro() {
41: public String doMacro() {
42: return "drools.insertLogical";
43: }
44: });
45:
46: macros.put("modifyRetract", new Macro() {
47: public String doMacro() {
48: return "drools.modifyRetract";
49: }
50: });
51:
52: macros.put("modifyInsert", new Macro() {
53: public String doMacro() {
54: return "drools.modifyInsert";
55: }
56: });
57:
58: macros.put("update", new Macro() {
59: public String doMacro() {
60: return "drools.update";
61: }
62: });
63:
64: macros.put("retract", new Macro() {
65: public String doMacro() {
66: return "drools.retract";
67: }
68: });
69:
70: return parseMacros(raw, macros);
71: }
72: }
|