01: /*
02: * $Id: LoaderHandler.java 341 2004-08-11 08:15:27Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.sf.net).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.model.cpd;
15:
16: import org.xml.sax.Attributes;
17: import org.xml.sax.SAXException;
18: import org.concern.model.Loader;
19:
20: public class LoaderHandler extends ScopeHandler {
21: private Loader loader;
22: private TextHandler descriptionHandler = new TextHandler();
23: private EnvironmentEntryHandler environmentEntryHandler = new EnvironmentEntryHandler();
24:
25: public LoaderHandler() {
26: }
27:
28: public Loader getLoader() {
29: return loader;
30: }
31:
32: public void startElement(String uri, String localName,
33: String qName, Attributes attributes) throws SAXException {
34: loader = new Loader(attributes.getValue("name"));
35: loader.setImplementation(attributes.getValue("class"));
36: }
37:
38: public void characters(char ch[], int start, int length)
39: throws SAXException {
40: }
41:
42: public void endElement(String uri, String localName, String qName)
43: throws SAXException {
44: }
45:
46: public ScopeHandler getHandler(String localName, String qName) {
47: if ("description".equals(qName))
48: return descriptionHandler;
49: else if ("env-entry".equals(qName))
50: return environmentEntryHandler;
51: else
52: throw new RuntimeException("unexpected tag " + localName
53: + " " + qName);
54: }
55:
56: public void fetchChild(ScopeHandler handler) {
57: if (handler == descriptionHandler)
58: loader.setDescription(descriptionHandler.getText());
59: else if (handler == environmentEntryHandler)
60: loader.getEnvironment().add(
61: environmentEntryHandler.getEnvironmentEntry());
62: }
63: }
|