KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > minilang > operation > MapProcessor


1 /*
2  * $Id: MapProcessor.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.minilang.operation;
25
26 import java.util.*;
27
28 import org.w3c.dom.*;
29 import org.ofbiz.base.util.*;
30
31 /**
32  * Map Processor Main Class
33  *
34  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
35  * @version $Rev: 5462 $
36  * @since 2.0
37  */

38 public class MapProcessor {
39     
40     String JavaDoc name;
41     List makeInStrings = new LinkedList();
42     List simpleMapProcesses = new LinkedList();
43
44     public MapProcessor(Element simpleMapProcessorElement) {
45         name = simpleMapProcessorElement.getAttribute("name");
46
47         List makeInStringElements = UtilXml.childElementList(simpleMapProcessorElement, "make-in-string");
48         Iterator misIter = makeInStringElements.iterator();
49
50         while (misIter.hasNext()) {
51             Element makeInStringElement = (Element) misIter.next();
52             MakeInString makeInString = new MakeInString(makeInStringElement);
53
54             makeInStrings.add(makeInString);
55         }
56
57         List simpleMapProcessElements = UtilXml.childElementList(simpleMapProcessorElement, "process");
58         Iterator strProcIter = simpleMapProcessElements.iterator();
59
60         while (strProcIter.hasNext()) {
61             Element simpleMapProcessElement = (Element) strProcIter.next();
62             SimpleMapProcess strProc = new SimpleMapProcess(simpleMapProcessElement);
63
64             simpleMapProcesses.add(strProc);
65         }
66     }
67
68     public String JavaDoc getName() {
69         return name;
70     }
71
72     public void exec(Map inMap, Map results, List messages, Locale locale, ClassLoader JavaDoc loader) {
73         if (makeInStrings != null && makeInStrings.size() > 0) {
74             Iterator misIter = makeInStrings.iterator();
75
76             while (misIter.hasNext()) {
77                 MakeInString makeInString = (MakeInString) misIter.next();
78
79                 makeInString.exec(inMap, results, messages, locale, loader);
80             }
81         }
82
83         if (simpleMapProcesses != null && simpleMapProcesses.size() > 0) {
84             Iterator strPrsIter = simpleMapProcesses.iterator();
85
86             while (strPrsIter.hasNext()) {
87                 SimpleMapProcess simpleMapProcess = (SimpleMapProcess) strPrsIter.next();
88
89                 simpleMapProcess.exec(inMap, results, messages, locale, loader);
90             }
91         }
92     }
93 }
94
Popular Tags