KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > query > jorm > lib > BasicJormExtent


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2004 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre, S. Chassande-Barrioz
22  */

23 package org.objectweb.medor.query.jorm.lib;
24
25 import org.objectweb.jorm.api.PMapper;
26 import org.objectweb.medor.api.MedorException;
27 import org.objectweb.medor.api.TupleStructure;
28 import org.objectweb.medor.datasource.api.DataStore;
29 import org.objectweb.medor.lib.BasicTupleStructure;
30 import org.objectweb.medor.query.api.OrderField;
31 import org.objectweb.medor.query.api.QueryLeaf;
32 import org.objectweb.medor.query.jorm.api.JormExtent;
33 import org.objectweb.medor.query.jorm.api.JormField;
34
35 import java.util.Iterator JavaDoc;
36 import java.util.Map JavaDoc;
37
38 /**
39  * This class is the common implementation of the jorm leaves (ClassExtent,
40  * GenClassExtent).
41  *
42  * @author S.Chassande-Barrioz
43  */

44 public abstract class BasicJormExtent
45     extends BasicTupleStructure
46     implements JormExtent, QueryLeaf, TupleStructure {
47     /**
48      * Node name
49      */

50     protected String JavaDoc name;
51
52     /**
53      * Name of the field which is the PName of the extent
54      */

55     protected String JavaDoc pnFieldName;
56
57     protected PNameField identifier = null;
58
59     /**
60      * The datastore of the extent
61      */

62     protected DataStore myStore;
63
64     /**
65      * The mapper of the extent.
66      */

67     protected PMapper mapper;
68
69     protected String JavaDoc projectName = null;
70
71     /**
72      * Are objects of subclasses included.
73      */

74     protected boolean includeSubclasses = false;
75
76     public BasicJormExtent() {
77     }
78
79     public BasicJormExtent(String JavaDoc _name, String JavaDoc pnFieldName) {
80         this.name = (_name == null ? "" : _name);
81         this.pnFieldName = pnFieldName;
82     }
83
84     public Object JavaDoc clone(Object JavaDoc clone,
85                         Map JavaDoc obj2clone) throws CloneNotSupportedException JavaDoc {
86         clone = super.clone(clone, obj2clone);
87         BasicJormExtent bje = (BasicJormExtent) clone;
88         bje.name = name;
89         bje.pnFieldName = pnFieldName;
90         bje.identifier = (PNameField) getClone(identifier, obj2clone);
91         bje.myStore = myStore;
92         bje.mapper = mapper;
93         bje.projectName = projectName;
94         bje.includeSubclasses = includeSubclasses;
95         return clone;
96     }
97
98     public Iterator JavaDoc iterateFields() {
99         return fields.iterator();
100     }
101
102     public String JavaDoc getFieldName(String JavaDoc nodeName, String JavaDoc fieldName) {
103         if (nodeName == null || nodeName.length() == 0)
104             return fieldName;
105         else
106             return nodeName + "." + fieldName;
107     }
108
109     // IMPLEMENTATION OF THE JormExtent INTERFACE //
110
//--------------------------------------------//
111

112     public PMapper getPMapper() {
113         return mapper;
114     }
115
116     public void setPMapper(PMapper m, String JavaDoc projectName) {
117         mapper = m;
118         this.projectName = projectName;
119     }
120
121     public String JavaDoc getProjectName() {
122         return projectName;
123     }
124
125     public void setProjectName(String JavaDoc projectName) {
126         this.projectName = projectName;
127     }
128
129     public void setDataStore(DataStore ds) {
130         myStore = ds;
131     }
132
133     public String JavaDoc getPNameFieldName() {
134         return getFieldName(name, pnFieldName);
135     }
136
137     public abstract String JavaDoc getJormName();
138
139     public JormField getIdentifierField() {
140         return identifier;
141     }
142
143     public boolean withSubClasses() {
144         return includeSubclasses;
145     }
146
147     public void setWithSubClasses(boolean incSubClasses) {
148         includeSubclasses = incSubClasses;
149     }
150
151     // IMPLEMENTATION OF THE QueryLeaf INTERFACE //
152
//-------------------------------------------//
153

154     public String JavaDoc getName() {
155         return this.name;
156     }
157
158     /**
159      * Methods inherited from QueryTree
160      */

161     public TupleStructure getTupleStructure() {
162         return this;
163     }
164
165     /**
166      * Methods inherited from QueryLeaf
167      */

168     public DataStore getDataStore() {
169         return myStore;
170     }
171
172     public void setDistinct(boolean d) throws MedorException {
173         throw new MedorException("Cannot set distinct on a JORM Leaf");
174     }
175
176     public boolean getDistinct() {
177         return false;
178     }
179
180     public void setOrderBy(OrderField[] orderfields) throws MedorException {
181         throw new MedorException("Order by not supported on JormExtent");
182     }
183
184     public OrderField[] getOrderBy() {
185         return null;
186     }
187
188 }
189
Popular Tags