01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. 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,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.minilang.operation;
19:
20: import java.util.*;
21:
22: import org.w3c.dom.*;
23: import org.ofbiz.base.util.*;
24:
25: /**
26: * Map Processor Main Class
27: */
28: public class MapProcessor {
29:
30: String name;
31: List makeInStrings = new LinkedList();
32: List simpleMapProcesses = new LinkedList();
33:
34: public MapProcessor(Element simpleMapProcessorElement) {
35: name = simpleMapProcessorElement.getAttribute("name");
36:
37: List makeInStringElements = UtilXml.childElementList(
38: simpleMapProcessorElement, "make-in-string");
39: Iterator misIter = makeInStringElements.iterator();
40:
41: while (misIter.hasNext()) {
42: Element makeInStringElement = (Element) misIter.next();
43: MakeInString makeInString = new MakeInString(
44: makeInStringElement);
45:
46: makeInStrings.add(makeInString);
47: }
48:
49: List simpleMapProcessElements = UtilXml.childElementList(
50: simpleMapProcessorElement, "process");
51: Iterator strProcIter = simpleMapProcessElements.iterator();
52:
53: while (strProcIter.hasNext()) {
54: Element simpleMapProcessElement = (Element) strProcIter
55: .next();
56: SimpleMapProcess strProc = new SimpleMapProcess(
57: simpleMapProcessElement);
58:
59: simpleMapProcesses.add(strProc);
60: }
61: }
62:
63: public String getName() {
64: return name;
65: }
66:
67: public void exec(Map inMap, Map results, List messages,
68: Locale locale, ClassLoader loader) {
69: if (makeInStrings != null && makeInStrings.size() > 0) {
70: Iterator misIter = makeInStrings.iterator();
71:
72: while (misIter.hasNext()) {
73: MakeInString makeInString = (MakeInString) misIter
74: .next();
75:
76: makeInString.exec(inMap, results, messages, locale,
77: loader);
78: }
79: }
80:
81: if (simpleMapProcesses != null && simpleMapProcesses.size() > 0) {
82: Iterator strPrsIter = simpleMapProcesses.iterator();
83:
84: while (strPrsIter.hasNext()) {
85: SimpleMapProcess simpleMapProcess = (SimpleMapProcess) strPrsIter
86: .next();
87:
88: simpleMapProcess.exec(inMap, results, messages, locale,
89: loader);
90: }
91: }
92: }
93: }
|