01: package org.mandarax.xkb.framework;
02:
03: /**
04: * Copyright (C) 2002 Jens Dietrich (mailto:mandarax@jbdietrich.com)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: import java.util.Map;
21:
22: import javax.sql.DataSource;
23:
24: import org.jdom.Element;
25: import org.mandarax.kernel.LogicFactory;
26: import org.mandarax.xkb.XKBException;
27:
28: /**
29: * An adapter class for data source.
30: * This adapter uses the object adapter. In particular the log writer property
31: * might be a potenial problem.
32: * @see javax.sql.DataSource
33: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
34: * @version 3.4 <7 March 05>
35: * @since 1.6
36: * @deprecated from v 3.4 - support for new features such as validation will not be added to XKB, please use ZKB instead
37: */
38: public class XMLAdapter4DataSources extends CachedXMLAdapter {
39: public static final String DATA_SOURCE = "data_source";
40:
41: /**
42: * Export an object, i.e., convert it to an element in the DOM.
43: * @param obj an object
44: * @param driver the generic driver
45: * @param cache a cache used in order to associate the same
46: * id with various occurences of the same object
47: * @exception an XKBException is thrown if export fails
48: */
49: protected Element _exportObject(Object obj, GenericDriver driver,
50: Map cache) throws XKBException {
51: check(obj, DataSource.class);
52: Element e = new Element(DATA_SOURCE);
53: Element eo = exportObject(obj, GenericDriver.OBJECT, driver,
54: cache);
55: e.addContent(eo);
56: return e;
57: }
58:
59: /**
60: * Build an object from an XML element.
61: * @param e an element
62: * @param driver the generic driver
63: * @param cache a cache used to identify objects that have the same id
64: * @param lfactory the logic factory used to create objects
65: * @exception an XKBException is thrown if import fails
66: */
67: protected Object _importObject(Element e, GenericDriver driver,
68: Map cache, LogicFactory lfactory) throws XKBException {
69: return (DataSource) importChild(e, GenericDriver.OBJECT,
70: driver, cache, lfactory);
71: }
72:
73: /**
74: * Get the name of the associated tag (element).
75: * @return a string
76: */
77: public String getTagName() {
78: return DATA_SOURCE;
79: }
80:
81: /**
82: * Get the kind of object the adapter can export/import.
83: * @return a string
84: */
85: public String getKindOfObject() {
86: return GenericDriver.DATA_SOURCE;
87: }
88: }
|