2 * Copyright (C) 2001, 2002 The Mir-coders group
4 * This file is part of Mir.
6 * Mir is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Mir is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Mir; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * In addition, as a special exception, The Mir-coders gives permission to link
21 * the code of this program with the com.oreilly.servlet library, any library
22 * licensed under the Apache Software License, The Sun (tm) Java Advanced
23 * Imaging library (JAI), The Sun JIMI library (or with modified versions of
24 * the above that use the same license as the above), and distribute linked
25 * combinations including the two. You must obey the GNU General Public
26 * License in all respects for all of the code used other than the above
27 * mentioned libraries. If you modify this file, you may extend this exception
28 * to your version of the file, but you are not obligated to do so. If you do
29 * not wish to do so, delete this exception statement from your version.
32 package mir.producer.reader;
36 import java.lang.System;
37 import org.xml.sax.helpers.DefaultHandler;
39 import javax.xml.parsers.ParserConfigurationException;
40 import javax.xml.parsers.SAXParser;
41 import javax.xml.parsers.SAXParserFactory;
44 import mir.config.exceptions.*;
45 import mir.producer.*;
47 //import mir.producer.exceptions.*;
48 import mir.misc.Location;
50 public class ProducerConfigReader {
51 private ProducerNodeBuilderLibrary builderLibrary;
52 private ProducerNodeBuilderLibrary scriptedNodeBuilderLibrary;
54 public ProducerConfigReader() {
58 public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, Map aProducerFactories) throws ProducerConfigFailure {
59 parseFile(aFileName, aBuilderLibrary, aProducerFactories, new Vector());
62 public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, Map aProducerFactories, List aUsedFiles) throws ProducerConfigFailure {
64 builderLibrary = aBuilderLibrary;
65 scriptedNodeBuilderLibrary = new ProducerNodeBuilderLibrary();
67 SAXParserFactory parserFactory = SAXParserFactory.newInstance();
69 parserFactory.setNamespaceAware(false);
70 parserFactory.setValidating(true);
72 ProducerConfigHandler handler = new ProducerConfigHandler(parserFactory, aProducerFactories, aUsedFiles);
74 handler.includeFile(aFileName);
77 if (e instanceof SAXParseException && ((SAXParseException) e).getException() instanceof ProducerConfigFailure) {
78 throw (ProducerConfigFailure) ((SAXParseException) e).getException();
81 throw new ProducerConfigFailure( e );
86 private class ProducerConfigHandler extends DefaultHandler {
87 private Locator locator;
88 private Stack includeFileStack;
89 private SAXParserFactory parserFactory;
90 private SectionsManager manager;
91 private List usedFiles;
92 private InputSource inputSource;
94 public ProducerConfigHandler(SAXParserFactory aParserFactory, Map aProducers, List aUsedFiles) {
97 includeFileStack=new Stack();
98 parserFactory=aParserFactory;
99 includeFileStack = new Stack();
100 manager = new SectionsManager();
101 usedFiles = aUsedFiles;
103 manager.pushHandler(new RootSectionHandler(aProducers));
106 public String getLocatorDescription(Locator aLocator) {
107 return aLocator.getPublicId()+" ("+aLocator.getLineNumber()+")";
110 public void setDocumentLocator(Locator aLocator) {
114 private void includeFile(String aFileName) throws ProducerConfigExc, ProducerConfigFailure, SAXParseException, SAXException {
119 if (!includeFileStack.empty())
120 file = new File(new File((String) includeFileStack.peek()).getParent(), aFileName);
122 file = new File(aFileName);
124 System.err.println("about to include "+file.getCanonicalPath());
126 if (includeFileStack.contains(file.getCanonicalPath())) {
127 throw new ProducerConfigExc("recursive inclusion of file "+file.getCanonicalPath());
132 parser=parserFactory.newSAXParser();
134 inputSource = new InputSource(new FileInputStream(file));
135 inputSource.setPublicId(file.getCanonicalPath());
137 includeFileStack.push(file.getCanonicalPath());
139 parser.parse(inputSource, this);
142 includeFileStack.pop();
145 catch (ParserConfigurationException e) {
146 throw new ProducerConfigExc("Internal exception while including \""+aFileName+"\": "+e.getMessage());
148 catch (SAXParseException e) {
151 catch (ProducerConfigFailure e) {
154 catch (FileNotFoundException e) {
155 throw new ProducerConfigExc("Include file \""+aFileName+"\" not found: "+e.getMessage());
157 catch (IOException e) {
158 throw new ProducerConfigExc("unable to open include file \""+aFileName+"\": "+e.getMessage());
162 public void startElement(String aUri, String aTag, String aQualifiedName, Attributes anAttributes) throws SAXException {
167 if (aQualifiedName.equals("include")) {
168 String fileName=anAttributes.getValue("file");
170 if (fileName==null) {
171 throw new ProducerConfigExc("include has no file attribute");
174 includeFile(fileName);
177 attributesMap = new HashMap();
178 for (i=0; i<anAttributes.getLength(); i++)
179 attributesMap.put(anAttributes.getQName(i), anAttributes.getValue(i));
181 manager.pushHandler( manager.currentHandler().startElement(aQualifiedName, attributesMap) );
184 catch (ProducerConfigExc e) {
185 throw new SAXParseException(e.getMessage(), locator, new ProducerConfigExc("Config error at ["+getLocatorDescription(locator)+"]: "+e.getMessage()));
187 catch (Exception e) {
188 throw new SAXException(e);
192 public void endElement(String aUri, String aTag, String aQualifiedName) throws SAXException {
195 if (!aQualifiedName.equals("include")) {
196 SectionHandler handler = manager.popHandler();
198 handler.finishSection();
200 if (!manager.isEmpty()) {
201 manager.currentHandler().endElement(handler);
205 catch (ProducerConfigExc e) {
206 throw new SAXParseException(e.getMessage(), locator, new ProducerConfigExc("Config error at ["+getLocatorDescription(locator)+"]: "+e.getMessage()));
208 catch (Exception e) {
209 throw new SAXException(e);
213 public void characters(char[] aBuffer, int aStart, int anEnd) throws SAXParseException {
214 String text = new String(aBuffer, aStart, anEnd).trim();
215 if ( text.length() > 0) {
216 throw new SAXParseException("Text not allowed", locator, new ProducerConfigExc("Config error at ["+getLocatorDescription(locator)+"]: Text not allowed"));
221 public class SectionsManager {
224 public SectionsManager() {
225 handlerStack = new Stack();
228 public void pushHandler(SectionHandler aSectionHandler) {
229 handlerStack.push(aSectionHandler);
232 public SectionHandler popHandler() {
233 return (SectionHandler) handlerStack.pop();
236 public SectionHandler currentHandler() {
237 return (SectionHandler) handlerStack.peek();
240 public boolean isEmpty() {
241 return handlerStack.isEmpty();
245 public abstract class SectionHandler {
246 public abstract SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc;
248 public abstract void endElement(SectionHandler aHandler) throws ProducerConfigExc;
252 public void finishSection() throws ProducerConfigExc {
256 public class RootSectionHandler extends SectionHandler {
257 private Map producers;
259 public RootSectionHandler(Map aProducers) {
260 producers = aProducers;
263 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
264 if (aTag.equals("producers")) {
265 return new ProducersSectionHandler(producers);
268 throw new ProducerConfigExc ("Tag 'producers' expected, tag '"+aTag+"' found");
271 public void endElement(SectionHandler aHandler) {
274 public void finishSection() throws ProducerConfigExc {
279 private final static String PRODUCER_NAME_ATTRIBUTE = "name";
280 private final static String[] PRODUCER_REQUIRED_ATTRIBUTES = { PRODUCER_NAME_ATTRIBUTE };
281 private final static String[] PRODUCER_OPTIONAL_ATTRIBUTES = { };
283 private final static String NODE_DEFINITION_NAME_ATTRIBUTE = "name";
284 private final static String[] NODE_DEFINITION_REQUIRED_ATTRIBUTES = { NODE_DEFINITION_NAME_ATTRIBUTE };
285 private final static String[] NODE_DEFINITION_OPTIONAL_ATTRIBUTES = { };
287 public class ProducersSectionHandler extends SectionHandler {
288 private Map producers;
291 public ProducersSectionHandler(Map aProducers) {
292 producers = aProducers;
295 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
297 if (aTag.equals("producer")) {
298 ReaderTool.checkAttributes(anAttributes, PRODUCER_REQUIRED_ATTRIBUTES, PRODUCER_OPTIONAL_ATTRIBUTES);
300 name = (String) anAttributes.get(PRODUCER_NAME_ATTRIBUTE);
301 ReaderTool.checkValidIdentifier( name );
303 if (producers.containsKey(name))
304 throw new ProducerConfigExc("Duplicate producer name: '" + name + "'");
306 name = (String) anAttributes.get(PRODUCER_NAME_ATTRIBUTE);
308 return new ProducerSectionHandler();
310 else if (aTag.equals("nodedefinition")) {
311 ReaderTool.checkAttributes(anAttributes, NODE_DEFINITION_REQUIRED_ATTRIBUTES, NODE_DEFINITION_OPTIONAL_ATTRIBUTES);
313 name = (String) anAttributes.get(NODE_DEFINITION_NAME_ATTRIBUTE);
314 ReaderTool.checkValidIdentifier( name );
316 // if (producers.containsKey(name))
317 // throw new ProducerConfigExc("Duplicate producer name: '" + name + "'");
319 name = (String) anAttributes.get(NODE_DEFINITION_NAME_ATTRIBUTE);
321 return new NodeDefinitionSectionHandler(name);
324 throw new ProducerConfigExc("Unexpected tag: "+aTag );
327 public void endElement(SectionHandler aHandler) throws ProducerConfigExc {
328 if (aHandler instanceof ProducerSectionHandler) {
329 producers.put(name, ((ProducerSectionHandler) aHandler).getProducerFactory());
331 else if (aHandler instanceof NodeDefinitionSectionHandler) {
332 scriptedNodeBuilderLibrary.registerFactory(name,
333 new DefaultProducerNodeBuilders.ScriptedProducerNodeBuilder.factory(
334 ((NodeDefinitionSectionHandler) aHandler).getDefinition()));
336 else throw new ProducerConfigExc("ProducersSectionHandler.endElement Internal error: Unexpected handler: " + aHandler.getClass().getName());
339 public void finishSection() throws ProducerConfigExc {
343 public class ProducerSectionHandler extends SectionHandler {
344 private ProducerFactory producerFactory;
346 private ProducerNode body;
348 private String defaultVerb;
350 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
351 if (aTag.equals("verbs")) {
353 throw new ProducerConfigExc("Verbs already processed");
355 throw new ProducerConfigExc("Verbs should come before body");
357 return new ProducerVerbsSectionHandler();
359 else if (aTag.equals("body")) {
361 return new ProducerNodeSectionHandler();
363 throw new ProducerConfigExc("Body already processed");
365 throw new ProducerConfigExc("Unexpected tag: '"+aTag+"'");
368 public void endElement(SectionHandler aHandler) throws ProducerConfigExc {
369 if (aHandler instanceof ProducerNodeSectionHandler) {
370 body = ((ProducerNodeSectionHandler) aHandler).getProducerNode();
372 else if (aHandler instanceof ProducerVerbsSectionHandler)
374 verbs = ((ProducerVerbsSectionHandler) aHandler).getVerbs();
375 defaultVerb = ((ProducerVerbsSectionHandler) aHandler).getDefaultVerb();
377 else throw new ProducerConfigExc("ProducerSectionHandler.endElement Internal error: Unexpected handler: " + aHandler.getClass().getName());
380 public void finishSection() throws ProducerConfigExc {
382 throw new ProducerConfigExc("No verbs defined");
385 throw new ProducerConfigExc("No body defined");
387 producerFactory = new ScriptedProducerFactory(verbs, body, defaultVerb);
390 public ProducerFactory getProducerFactory() {
391 return producerFactory;
395 private final static String PRODUCER_VERB_NAME_ATTRIBUTE = "name";
396 private final static String PRODUCER_VERB_DESCRIPTION_ATTRIBUTE = "description";
397 private final static String PRODUCER_VERB_DEFAULT_ATTRIBUTE = "default";
398 private final static String[] PRODUCER_VERB_REQUIRED_ATTRIBUTES = { PRODUCER_VERB_NAME_ATTRIBUTE };
399 private final static String[] PRODUCER_VERB_OPTIONAL_ATTRIBUTES = { PRODUCER_VERB_DEFAULT_ATTRIBUTE, PRODUCER_VERB_DESCRIPTION_ATTRIBUTE };
401 public class ProducerVerbsSectionHandler extends SectionHandler {
403 private String defaultVerb;
404 private String currentVerb;
405 private String currentVerbDescription;
407 public ProducerVerbsSectionHandler() {
408 verbs = new HashMap();
412 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
413 if (aTag.equals("verb")) {
414 ReaderTool.checkAttributes(anAttributes, PRODUCER_VERB_REQUIRED_ATTRIBUTES, PRODUCER_VERB_OPTIONAL_ATTRIBUTES);
415 currentVerb = (String) anAttributes.get( PRODUCER_VERB_NAME_ATTRIBUTE );
417 ReaderTool.checkValidIdentifier( currentVerb );
419 if (verbs.containsKey(currentVerb))
420 throw new ProducerConfigExc( "Duplicate definition of verb '" + currentVerb + "'" );
422 if (anAttributes.containsKey(PRODUCER_VERB_DEFAULT_ATTRIBUTE)) {
423 if (defaultVerb!=null)
424 throw new ProducerConfigExc( "Default verb already declared" );
426 defaultVerb = currentVerb;
429 if (anAttributes.containsKey( PRODUCER_VERB_DESCRIPTION_ATTRIBUTE ))
430 currentVerbDescription = (String) anAttributes.get( PRODUCER_VERB_DESCRIPTION_ATTRIBUTE );
432 currentVerbDescription = "";
434 return new ProducerNodeSectionHandler();
436 else throw new ProducerConfigExc("Only 'verb' tags allowed here, '" + aTag + "' encountered.");
439 public void endElement(SectionHandler aHandler) {
440 verbs.put(currentVerb, ((ProducerNodeSectionHandler) aHandler).getProducerNode());
443 public void finishSection() {
446 public String getDefaultVerb() {
450 public Map getVerbs() {
455 public class EmptySectionHandler extends SectionHandler {
456 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
457 throw new ProducerConfigExc("No tags are allowed here");
460 public void endElement(SectionHandler aHandler) {
465 public class MultiProducerNodeSectionHandler extends SectionHandler {
466 private Map nodeParameters;
467 private Set validNodeParameters;
468 private String currentNodeParameter;
469 private String scriptedNodeName;
470 private Set allowedNodeParameterReferences;
472 public MultiProducerNodeSectionHandler(String aScriptedNodeName, Set anAllowedNodeParameterReferences, Set aValidNodeParameters) {
473 allowedNodeParameterReferences = anAllowedNodeParameterReferences;
474 scriptedNodeName = aScriptedNodeName;
475 validNodeParameters = aValidNodeParameters;
476 nodeParameters = new HashMap();
478 public MultiProducerNodeSectionHandler(Set aValidNodeParameters) {
479 this("", new HashSet(), aValidNodeParameters);
482 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
483 if (!validNodeParameters.contains(aTag))
484 throw new ProducerConfigExc("Invalid node parameter: '" + aTag + "'");
485 else if (nodeParameters.containsKey(aTag))
486 throw new ProducerConfigExc("Node parameter: '" + aTag + "' already specified");
487 else if (anAttributes.size()>0)
488 throw new ProducerConfigExc("No parameters are allowed here");
490 currentNodeParameter = aTag;
492 return new ProducerNodeSectionHandler(scriptedNodeName, validNodeParameters);
495 public void endElement(SectionHandler aHandler) throws ProducerConfigExc {
496 if (aHandler instanceof ProducerNodeSectionHandler) {
497 nodeParameters.put(currentNodeParameter, ((ProducerNodeSectionHandler) aHandler).getProducerNode());
500 throw new ProducerConfigExc("Internal error: unknown section handler '" + aHandler.getClass().getName() + "'" );
504 public Map getNodeParameters() {
505 return nodeParameters;
509 public class ProducerNodeSectionHandler extends SectionHandler {
510 private CompositeProducerNode producerNode;
511 private ProducerNodeBuilder currentBuilder;
512 private String scriptedNodeName;
513 private Set allowedNodeParameterReferences;
515 public ProducerNodeSectionHandler(String aScriptedNodeName, Set anAllowedNodeParameterReferences) {
516 producerNode = new CompositeProducerNode();
517 scriptedNodeName = aScriptedNodeName;
518 allowedNodeParameterReferences = anAllowedNodeParameterReferences;
521 public ProducerNodeSectionHandler() {
522 this("", new HashSet());
525 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
526 if (allowedNodeParameterReferences.contains((aTag))) {
527 if (!anAttributes.isEmpty()) {
528 throw new ProducerConfigExc( "No attributes allowed" );
531 currentBuilder = new DefaultProducerNodeBuilders.ScriptedProducerParameterNodeBuilder(scriptedNodeName, aTag);
532 // producerNode.addSubNode(
533 // new ScriptedProducerNodeDefinition.NodeParameterProducerNode(scriptedNodeName, aTag));
534 return new EmptySectionHandler();
536 else if (scriptedNodeBuilderLibrary.hasBuilderForName(aTag) || builderLibrary.hasBuilderForName((aTag))) {
538 if (scriptedNodeBuilderLibrary.hasBuilderForName(aTag))
539 currentBuilder = scriptedNodeBuilderLibrary.constructBuilder(aTag);
541 currentBuilder = builderLibrary.constructBuilder(aTag);
543 currentBuilder.setAttributes(anAttributes);
544 if (currentBuilder.getAvailableSubNodes().isEmpty()) {
545 return new EmptySectionHandler();
547 if (currentBuilder.getAvailableSubNodes().size()>1)
548 return new MultiProducerNodeSectionHandler(scriptedNodeName, allowedNodeParameterReferences, currentBuilder.getAvailableSubNodes());
549 else if (currentBuilder.getAvailableSubNodes().size()<1)
550 return new EmptySectionHandler();
552 return new ProducerNodeSectionHandler(scriptedNodeName, allowedNodeParameterReferences);
556 throw new ProducerConfigExc("Unknown producer node tag: '" + aTag + "'");
559 public void endElement(SectionHandler aHandler) throws ProducerConfigExc {
560 if (aHandler instanceof ProducerNodeSectionHandler) {
561 currentBuilder.setSubNode((String) (currentBuilder.getAvailableSubNodes().iterator().next()),
562 ((ProducerNodeSectionHandler) aHandler).getProducerNode());
564 else if (aHandler instanceof MultiProducerNodeSectionHandler) {
569 nodeParameters = ((MultiProducerNodeSectionHandler) aHandler).getNodeParameters();
570 i = nodeParameters.entrySet().iterator();
571 while (i.hasNext()) {
572 entry = (Map.Entry) i.next();
573 currentBuilder.setSubNode((String) entry.getKey(), (ProducerNode) entry.getValue());
576 else if (aHandler instanceof EmptySectionHandler) {
577 // deliberately empty: nothing expected, so nothing to process
580 throw new ProducerConfigExc("Internal error: unknown section handler '" + aHandler.getClass().getName() + "'" );
583 producerNode.addSubNode(currentBuilder.constructNode());
584 currentBuilder = null;
587 public ProducerNode getProducerNode() {
588 if (producerNode.getNrSubNodes()==1) {
589 return producerNode.getSubNode(0);
597 public class NodeDefinitionSectionHandler extends SectionHandler {
598 private ScriptedProducerNodeDefinition nodeDefinition;
599 private ProducerNode body;
600 private Map stringParameters;
601 private Map nodeParameters;
604 public NodeDefinitionSectionHandler(String aName) {
606 nodeParameters = null;
607 stringParameters = null;
611 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
612 if (aTag.equals("parameters")) {
613 if (!anAttributes.isEmpty()) {
614 throw new ProducerConfigExc( "No attributes allowed for tag 'parameters'" );
616 if (nodeParameters!=null) {
617 throw new ProducerConfigExc( "Parameters have already been declared" );
620 throw new ProducerConfigExc( "Parameters should come before definition" );
623 return new NodeDefinitionParametersSectionHandler();
625 else if (aTag.equals("definition")) {
626 return new ProducerNodeSectionHandler(name, nodeParameters.keySet());
628 else throw new ProducerConfigExc("Only 'definition' or 'parameters' tags allowed here, '" + aTag + "' encountered.");
631 public void endElement(SectionHandler aHandler) {
632 if (aHandler instanceof NodeDefinitionParametersSectionHandler) {
633 stringParameters = ((NodeDefinitionParametersSectionHandler) aHandler).getStringParameters();
634 nodeParameters = ((NodeDefinitionParametersSectionHandler) aHandler).getNodeParameters();
636 else if (aHandler instanceof ProducerNodeSectionHandler) {
637 body = ((ProducerNodeSectionHandler) aHandler).getProducerNode();
641 public void finishSection() throws ProducerConfigExc {
644 throw new ProducerConfigExc( "Definition missing" );
646 nodeDefinition = new ScriptedProducerNodeDefinition(name);
648 nodeDefinition.setBody(body);
650 i = nodeParameters.keySet().iterator();
651 while (i.hasNext()) {
652 nodeDefinition.addNodeParameter((String) i.next());
655 i = stringParameters.entrySet().iterator();
656 while (i.hasNext()) {
657 Map.Entry entry = (Map.Entry) i.next();
658 nodeDefinition.addParameter((String) entry.getKey(), (String) entry.getValue());
662 public ScriptedProducerNodeDefinition getDefinition() {
663 return nodeDefinition;
667 private final static String NODE_DEFINITION_PARAMETER_NAME_ATTRIBUTE = "name";
668 private final static String NODE_DEFINITION_PARAMETER_DEFAULTVALUE_ATTRIBUTE = "defaultvalue";
669 private final static String[] NODE_DEFINITION_PARAMETER_REQUIRED_ATTRIBUTES = { NODE_DEFINITION_PARAMETER_NAME_ATTRIBUTE };
670 private final static String[] NODE_DEFINITION_PARAMETER_OPTIONAL_ATTRIBUTES = { NODE_DEFINITION_PARAMETER_DEFAULTVALUE_ATTRIBUTE };
671 private final static String[] NODE_DEFINITION_NODE_PARAMETER_OPTIONAL_ATTRIBUTES = { };
673 public class NodeDefinitionParametersSectionHandler extends SectionHandler {
674 private Map nodeParameters;
675 private Map stringParameters;
677 public NodeDefinitionParametersSectionHandler() {
678 nodeParameters = new HashMap();
679 stringParameters = new HashMap();
682 public SectionHandler startElement(String aTag, Map anAttributes) throws ProducerConfigExc {
683 String parameterName;
686 if (aTag.equals("node")) {
687 ReaderTool.checkAttributes(anAttributes, NODE_DEFINITION_PARAMETER_REQUIRED_ATTRIBUTES, NODE_DEFINITION_NODE_PARAMETER_OPTIONAL_ATTRIBUTES);
688 parameterName = (String) anAttributes.get( NODE_DEFINITION_PARAMETER_NAME_ATTRIBUTE );
690 if (nodeParameters.containsKey(parameterName))
691 throw new ProducerConfigExc("Duplicate parameter name: '" + parameterName + "'");
693 ReaderTool.checkValidIdentifier( parameterName );
695 nodeParameters.put(parameterName, parameterName);
697 return new EmptySectionHandler();
699 else if (aTag.equals("string")) {
700 ReaderTool.checkAttributes(anAttributes, NODE_DEFINITION_PARAMETER_REQUIRED_ATTRIBUTES, NODE_DEFINITION_PARAMETER_OPTIONAL_ATTRIBUTES);
701 parameterName = (String) anAttributes.get( NODE_DEFINITION_PARAMETER_NAME_ATTRIBUTE );
703 if (stringParameters.containsKey(parameterName))
704 throw new ProducerConfigExc("Duplicate parameter name: '" + parameterName + "'");
706 ReaderTool.checkValidIdentifier( parameterName );
708 defaultValue = (String) anAttributes.get( NODE_DEFINITION_PARAMETER_DEFAULTVALUE_ATTRIBUTE );
710 stringParameters.put(parameterName, defaultValue);
712 return new EmptySectionHandler();
714 else throw new ProducerConfigExc("Only 'string' and 'node' tags allowed here, '" + aTag + "' encountered.");
718 public void endElement(SectionHandler aHandler) {
721 public void finishSection() {
724 public Map getNodeParameters() {
725 return nodeParameters;
728 public Map getStringParameters() {
729 return stringParameters;
736 / (expecting producers)
737 producers/ (expecting nodedefinition, producer)
738 nodedefinition (expecting parameters, definition)
739 parameters (expecting parameter declarations)
740 definition (expecting nodes, subnodes)