001: /*
002: * $Id: MapProcessor.java,v 1.1 2003/08/17 06:06:11 ajzeneski Exp $
003: *
004: * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
005: *
006: * Permission is hereby granted, free of charge, to any person obtaining a
007: * copy of this software and associated documentation files (the "Software"),
008: * to deal in the Software without restriction, including without limitation
009: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010: * and/or sell copies of the Software, and to permit persons to whom the
011: * Software is furnished to do so, subject to the following conditions:
012: *
013: * The above copyright notice and this permission notice shall be included
014: * in all copies or substantial portions of the Software.
015: *
016: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023: */
024: package org.ofbiz.minilang.operation;
025:
026: import java.util.*;
027:
028: import org.w3c.dom.*;
029: import org.ofbiz.base.util.*;
030:
031: /**
032: * Map Processor Main Class
033: *
034: * @author <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
035: * @version $Revision: 1.1 $
036: * @since 2.0
037: */
038: public class MapProcessor {
039:
040: String name;
041: List makeInStrings = new LinkedList();
042: List simpleMapProcesses = new LinkedList();
043:
044: public MapProcessor(Element simpleMapProcessorElement) {
045: name = simpleMapProcessorElement.getAttribute("name");
046:
047: List makeInStringElements = UtilXml.childElementList(
048: simpleMapProcessorElement, "make-in-string");
049: Iterator misIter = makeInStringElements.iterator();
050:
051: while (misIter.hasNext()) {
052: Element makeInStringElement = (Element) misIter.next();
053: MakeInString makeInString = new MakeInString(
054: makeInStringElement);
055:
056: makeInStrings.add(makeInString);
057: }
058:
059: List simpleMapProcessElements = UtilXml.childElementList(
060: simpleMapProcessorElement, "process");
061: Iterator strProcIter = simpleMapProcessElements.iterator();
062:
063: while (strProcIter.hasNext()) {
064: Element simpleMapProcessElement = (Element) strProcIter
065: .next();
066: SimpleMapProcess strProc = new SimpleMapProcess(
067: simpleMapProcessElement);
068:
069: simpleMapProcesses.add(strProc);
070: }
071: }
072:
073: public String getName() {
074: return name;
075: }
076:
077: public void exec(Map inMap, Map results, List messages,
078: Locale locale, ClassLoader loader) {
079: if (makeInStrings != null && makeInStrings.size() > 0) {
080: Iterator misIter = makeInStrings.iterator();
081:
082: while (misIter.hasNext()) {
083: MakeInString makeInString = (MakeInString) misIter
084: .next();
085:
086: makeInString.exec(inMap, results, messages, locale,
087: loader);
088: }
089: }
090:
091: if (simpleMapProcesses != null && simpleMapProcesses.size() > 0) {
092: Iterator strPrsIter = simpleMapProcesses.iterator();
093:
094: while (strPrsIter.hasNext()) {
095: SimpleMapProcess simpleMapProcess = (SimpleMapProcess) strPrsIter
096: .next();
097:
098: simpleMapProcess.exec(inMap, results, messages, locale,
099: loader);
100: }
101: }
102: }
103: }
|