KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > config > xml > PropertiesHandler


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.core.config.xml;
32
33 import java.util.Properties JavaDoc;
34
35 import org.objectweb.proactive.core.config.ProActiveConfiguration;
36 import org.objectweb.proactive.core.xml.handler.AbstractUnmarshallerDecorator;
37 import org.objectweb.proactive.core.xml.handler.UnmarshallerHandler;
38 import org.objectweb.proactive.core.xml.io.Attributes;
39
40
41 /**
42  * @author adicosta
43  *
44  */

45 public class PropertiesHandler extends AbstractUnmarshallerDecorator
46     implements MasterFileConstants {
47     //protected static Logger logger = Logger.getLogger(PropertiesHandler.class.getName());
48
private Properties JavaDoc properties = null;
49
50     public PropertiesHandler(ProActiveConfiguration config) {
51         super();
52         properties = new Properties JavaDoc();
53         addHandler(PROP_TAG, new PropHandler(properties, config));
54     }
55
56     public Object JavaDoc getResultObject() throws org.xml.sax.SAXException JavaDoc {
57         return properties;
58     }
59
60     public void startContextElement(String JavaDoc name, Attributes attributes)
61         throws org.xml.sax.SAXException JavaDoc {
62     }
63
64     protected void notifyEndActiveHandler(String JavaDoc name,
65         UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException JavaDoc {
66     }
67
68     //-----------------------------------------------------------------------------------------------------------
69
private static class PropHandler extends AbstractUnmarshallerDecorator {
70         private Properties JavaDoc properties = null;
71         private ProActiveConfiguration config;
72
73         PropHandler(Properties JavaDoc properties, ProActiveConfiguration config) {
74             super();
75             this.properties = properties;
76             this.config = config;
77         }
78
79         public Object JavaDoc getResultObject() throws org.xml.sax.SAXException JavaDoc {
80             return properties;
81         }
82
83         public void startContextElement(String JavaDoc name, Attributes attributes)
84             throws org.xml.sax.SAXException JavaDoc {
85             // System.out.println("**** PropHandler");
86
String JavaDoc key = attributes.getValue("key");
87             String JavaDoc value = attributes.getValue("value");
88             PropertiesHandler.logger.debug("Key " + key + " value " + value);
89
90             // System.out.println("Key " + key + " value " + value);
91
// if (checkNonEmpty(key) && checkNonEmpty(value)) {
92
// properties.put(key, value);
93
// }
94
//System.out.println("config is " + config);
95
config.propertyFound(key, value);
96         }
97
98         protected void notifyEndActiveHandler(String JavaDoc name,
99             UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException JavaDoc {
100         }
101     }
102 }
103
Popular Tags