01: /*
02: * $Id: PropertiesHandler.java 265 2004-04-15 13:08:31Z 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:
19: import java.io.ByteArrayInputStream;
20: import java.io.IOException;
21: import java.io.InputStream;
22: import java.util.*;
23:
24: public class PropertiesHandler extends ScopeHandler {
25: private StringBuffer text = new StringBuffer();
26: private Properties properties;
27:
28: public PropertiesHandler() {
29: }
30:
31: public Properties getProperties() {
32: return properties;
33: }
34:
35: public void startElement(String uri, String localName,
36: String qName, Attributes attributes) throws SAXException {
37: }
38:
39: public void characters(char ch[], int start, int length)
40: throws SAXException {
41: text.append(new String(ch, start, length));
42: }
43:
44: public void endElement(String uri, String localName, String qName)
45: throws SAXException {
46: try {
47: properties = new Properties();
48: InputStream in = new ByteArrayInputStream(text.toString()
49: .getBytes());
50: properties.load(in);
51: } catch (IOException e) {
52: e.printStackTrace();
53: }
54: }
55:
56: public ScopeHandler getHandler(String localName, String qName) {
57: throw new RuntimeException("unexpected tag " + localName + " "
58: + qName);
59: }
60:
61: public void fetchChild(ScopeHandler handler) {
62: }
63: }
|