KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > mi2xml > lib > BasicMappingDomtreeBuilder


1 /**
2  * JORM: an implementation of a generic mapping system for persistent Java
3  * objects. Two mapping are supported: to RDBMS and to binary files.
4  * Copyright (C) 2001-2003 France Telecom R&D - INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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  * Contact: jorm-team@objectweb.org
21  *
22  */

23
24 package org.objectweb.jorm.mi2xml.lib;
25
26 import org.objectweb.jorm.util.api.Loggable;
27 import org.objectweb.jorm.mi2xml.api.MappingDomtreeBuilder;
28 import org.objectweb.jorm.metainfo.api.Class;
29 import org.objectweb.jorm.metainfo.api.ClassMapping;
30 import org.objectweb.jorm.metainfo.api.GenClassMapping;
31 import org.objectweb.jorm.api.PException;
32 import org.objectweb.util.monolog.api.Logger;
33 import org.objectweb.util.monolog.api.LoggerFactory;
34 import org.w3c.dom.Element JavaDoc;
35 import org.w3c.dom.Document JavaDoc;
36
37 import java.util.Map JavaDoc;
38 import java.util.Hashtable JavaDoc;
39
40 /**
41  * BasicMappingDomtreeBuilder implements the MappingDomtreeBuilder interface.
42  */

43 public abstract class BasicMappingDomtreeBuilder implements MappingDomtreeBuilder, Loggable {
44
45     /**
46      * The current Class object.
47      */

48     protected Class JavaDoc currentClass;
49
50     /**
51      * This HashTable associates a MetaObject with an id value.
52      */

53     protected Map JavaDoc metaobject2idvalue = new Hashtable JavaDoc();
54
55     /**
56      * a simple logger to log
57      */

58     protected Logger logger;
59
60     /**
61      * a logger factory to create other loggers if needed
62      */

63     protected LoggerFactory loggerFactory;
64
65     ///////////////////////////////////////////////////////////////////
66
// from MappingDomtreeBuilder interface
67
///////////////////////////////////////////////////////////////////
68

69     /**
70      * Assigns the current Class object to the MappingDomtreeBuilder object.
71      *
72      * @param currentClass the Jorm meta-object associated to the parsed class.
73      */

74     public void setCurrentClass(Class JavaDoc currentClass) {
75         this.currentClass = currentClass;
76     }
77
78     /**
79      * Assigns an HashTable object to the MappingDomtreeBuilder object.
80      *
81      * @param metaobject2idvalue an HashTable that associates a MetaObject with an id value.
82      */

83     public void setmetaobject2idvalue(Map JavaDoc metaobject2idvalue) {
84         this.metaobject2idvalue = metaobject2idvalue;
85     }
86
87     /**
88      * Adds a class mapping element to a mapping element.
89      * @param document an org.w3c.dom.Document object,
90      * mappingElement a mapping element,
91      * classMapping a <tt>ClassMapping</tt> object.
92      */

93     public abstract void processClassMapping(Document JavaDoc document, Element JavaDoc mappingElement,
94                                              ClassMapping classMapping) throws PException;
95
96     /**
97      * Adds a generic class mapping element to a mapping element.
98      * @param document an org.w3c.dom.Document object,
99      * mappingElement a mapping element,
100      * genClassMapping a <tt>GenClassMapping</tt> object.
101      */

102     public abstract void processGenClassMapping(Document JavaDoc document, Element JavaDoc mappingElement,
103                                                 GenClassMapping genClassMapping) throws PException;
104
105     ///////////////////////////////////////////////////////////////////
106
// from Loggable interface
107
///////////////////////////////////////////////////////////////////
108

109     /**
110      * Defines a logger object.
111      *
112      * @param logger the logger object
113      */

114     public void setLogger(Logger logger) {
115         this.logger = logger;
116     }
117
118     /**
119      * Defines the logger factory to obtain new loggers.
120      *
121      * @param loggerfactory The LoggerFactory object to obtain a logger object
122      */

123     public void setLoggerFactory(LoggerFactory loggerfactory) {
124         this.loggerFactory = loggerfactory;
125         if (logger == null && loggerFactory != null) {
126             logger = loggerFactory.getLogger("org.objectweb.jorm.mi2xml.rdb");
127         }
128     }
129
130     public Logger getLogger() {
131         return logger;
132     }
133
134     public LoggerFactory getLoggerFactory() {
135         return loggerFactory;
136     }
137 }
138
Popular Tags