KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > mapper > fos > metainfo > FosMapping


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.mapper.fos.metainfo;
25
26 import org.objectweb.jorm.metainfo.lib.BasicMapping;
27 import org.objectweb.jorm.metainfo.api.MetaObject;
28 import org.objectweb.jorm.metainfo.api.GenClassRef;
29 import org.objectweb.jorm.metainfo.api.ClassMapping;
30 import org.objectweb.util.monolog.api.BasicLevel;
31
32 /**
33  * @author P. Dechamboux
34  */

35 public class FosMapping extends BasicMapping {
36     /**
37      * Builds a new BasicRdbMapping object.
38      * This object contains the mapping structures of a class.
39      * The parent object is a Project object.
40      * @param mapperName the mapper name,
41      * parent the parent of the current object.
42      */

43     public FosMapping(String JavaDoc mapperName, MetaObject parent) {
44         super(mapperName, parent);
45     }
46
47     /**
48      * Creates a new BasicRdbClassMapping object.
49      * @param ruleName the name of the rule used to map the class,
50      * linkedMO the Class object referenced by the current object,
51      * parent the parent object of the current object.
52      * @return an RdbClassMapping object.
53      */

54     public ClassMapping createClassMapping(String JavaDoc ruleName) {
55         FosClassMapping res = (FosClassMapping) getClassMapping();
56         if (res == null) {
57             res = new FosClassMapping(getParent().getParent(), this);
58             setClassMapping(res);
59             res.setLogger(logger);
60         } else {
61             res.setRuleName(ruleName);
62         }
63         return res;
64     }
65
66     /**
67      * Creates a new BasicFosGenClassMapping object.
68      * @param ruleName the name of the rule used to map the class,
69      * linkedMO the GenClassRef object referenced by the current
70      * object,
71      * parent the parent object of the current object.
72      * @return an BasicFosGenClassMapping object.
73      */

74     public FosGenClassMapping createGenClassMapping(String JavaDoc ruleName,
75                                                          MetaObject linkedMO) {
76         String JavaDoc gcid = ((GenClassRef) linkedMO).getGenClassId();
77         if (logger.isLoggable(BasicLevel.DEBUG)) {
78             logger.log(BasicLevel.DEBUG, "(gcid " + gcid + ")");
79         }
80         FosGenClassMapping res = (FosGenClassMapping) getGenClassMapping(gcid);
81         if (res == null) {
82             res = new FosGenClassMapping(linkedMO, this);
83             res.setLogger(logger);
84             addGenClassMapping(gcid, res);
85         } else {
86             res.setRuleName(ruleName);
87             res.setLinkedMO(linkedMO);
88         }
89         return res;
90     }
91 }
92
Popular Tags