001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer(s): Sebastien Chassande
022: * Contributor(s):
023: *
024: * --------------------------------------------------------------------------
025: * $Id: GenClassElement.java 6673 2005-04-28 16:53:00Z benoitf $
026: * --------------------------------------------------------------------------
027: */
028: package org.objectweb.jonas_ejb.container.jorm;
029:
030: import org.objectweb.jorm.api.PIndexedElem;
031: import org.objectweb.jorm.api.PException;
032: import org.objectweb.jorm.naming.api.PName;
033: import org.objectweb.jorm.type.api.PExceptionTyping;
034: import org.objectweb.jonas_ejb.container.TraceEjb;
035: import org.objectweb.util.monolog.api.BasicLevel;
036:
037: import java.util.Date;
038: import java.io.Serializable;
039: import java.math.BigDecimal;
040:
041: /**
042: * This class is a basic implementation of the PIndexedElem interface used by
043: * the GenClassImpl class. This implementation manages only references (no
044: * primitive elements).
045: *
046: * @author S.Chassande-Barrioz
047: */
048: public class GenClassElement implements PIndexedElem {
049:
050: /**
051: * This field describes the status of the PIndexedElem in according to the
052: * constant defined in the PIndexedElem interface.
053: */
054: public byte status = PIndexedElem.ELEM_UNMODIFIED;
055:
056: public boolean hasBeenCreated = false;
057:
058: /**
059: * This field references the associated pname. This field is never null
060: * after data has been loaded.
061: */
062: public PName pname = null;
063:
064: /**
065: * This field references the user object. This is a PObject which permits
066: * to reach its PName.
067: */
068: public PObject value = null;
069:
070: /**
071: * This field references the GenClass inside which the PIndexedElem is
072: * store.
073: */
074: public GenClassImpl gc = null;
075:
076: public GenClassElement(GenClassImpl gc) {
077: this .gc = gc;
078: }
079:
080: // IMPLEMENTATION OF THE PIndexedElem INTERFACE //
081: //----------------------------------------------//
082:
083: public byte getElemStatus() {
084: return status;
085: }
086:
087: public PName pieGetRefElem() throws PException {
088: if (pname == null) {
089: pname = gc.gcObject2ref(value);
090: }
091: if (TraceEjb.genclass.isLoggable(BasicLevel.DEBUG)) {
092: TraceEjb.genclass.log(BasicLevel.DEBUG, "pn=" + pname);
093: }
094: return pname;
095: }
096:
097: /**
098: * The jorm assignes the PName of the referenced object
099: */
100: public void pieSetRefElem(PName pn) throws PException {
101: pname = pn;
102: value = null;
103: if (TraceEjb.genclass.isLoggable(BasicLevel.DEBUG)) {
104: TraceEjb.genclass.log(BasicLevel.DEBUG, "pn=" + pname);
105: }
106: }
107:
108: public boolean pieGetBooleanElem() throws PException {
109: throw new PExceptionTyping(
110: "Bad elem type: asked: boolean, been: object");
111: }
112:
113: public Boolean pieGetObooleanElem() throws PException {
114: throw new PExceptionTyping(
115: "Bad elem type: asked: Boolean, been: object");
116: }
117:
118: public byte pieGetByteElem() throws PException {
119: throw new PExceptionTyping(
120: "Bad elem type: asked: byte, been: object");
121: }
122:
123: public Byte pieGetObyteElem() throws PException {
124: throw new PExceptionTyping(
125: "Bad elem type: asked: Byte, been: object");
126: }
127:
128: public byte pieGetByteIndexField(String fn) throws PException {
129: throw new PExceptionTyping("No index");
130: }
131:
132: public Byte pieGetObyteIndexField(String fn) throws PException {
133: throw new PExceptionTyping("No index");
134: }
135:
136: public char pieGetCharElem() throws PException {
137: throw new PExceptionTyping(
138: "Bad elem type: asked: char, been: object");
139: }
140:
141: public Character pieGetOcharElem() throws PException {
142: throw new PExceptionTyping(
143: "Bad elem type: asked: Char, been: object");
144: }
145:
146: public char pieGetCharIndexField(String fn) throws PException {
147: throw new PExceptionTyping("No index");
148: }
149:
150: public Character pieGetOcharIndexField(String fn) throws PException {
151: throw new PExceptionTyping("No index");
152: }
153:
154: public short pieGetShortElem() throws PException {
155: throw new PExceptionTyping(
156: "Bad elem type: asked: short, been: object");
157: }
158:
159: public Short pieGetOshortElem() throws PException {
160: throw new PExceptionTyping(
161: "Bad elem type: asked: Short, been: object");
162: }
163:
164: public short pieGetShortIndexField(String fn) throws PException {
165: throw new PExceptionTyping("No index");
166: }
167:
168: public Short pieGetOshortIndexField(String fn) throws PException {
169: throw new PExceptionTyping("No index");
170: }
171:
172: public int pieGetIntElem() throws PException {
173: throw new PExceptionTyping(
174: "Bad elem type: asked: int, been: object");
175: }
176:
177: public Integer pieGetOintElem() throws PException {
178: throw new PExceptionTyping(
179: "Bad elem type: asked: Int, been: object");
180: }
181:
182: public int pieGetIntIndexField(String fn) throws PException {
183: throw new PExceptionTyping("No index");
184: }
185:
186: public Integer pieGetOintIndexField(String fn) throws PException {
187: throw new PExceptionTyping("No index");
188: }
189:
190: public long pieGetLongElem() throws PException {
191: throw new PExceptionTyping(
192: "Bad elem type: asked: long, been: object");
193: }
194:
195: public Long pieGetOlongElem() throws PException {
196: throw new PExceptionTyping(
197: "Bad elem type: asked: Long, been: object");
198: }
199:
200: public long pieGetLongIndexField(String fn) throws PException {
201: throw new PExceptionTyping("No index");
202: }
203:
204: public Long pieGetOlongIndexField(String fn) throws PException {
205: throw new PExceptionTyping("No index");
206: }
207:
208: public float pieGetFloatElem() throws PException {
209: throw new PExceptionTyping(
210: "Bad elem type: asked: float, been: object");
211: }
212:
213: public Float pieGetOfloatElem() throws PException {
214: throw new PExceptionTyping(
215: "Bad elem type: asked: Float, been: object");
216: }
217:
218: public double pieGetDoubleElem() throws PException {
219: throw new PExceptionTyping(
220: "Bad elem type: asked: double, been: object");
221: }
222:
223: public Double pieGetOdoubleElem() throws PException {
224: throw new PExceptionTyping(
225: "Bad elem type: asked: Double, been: object");
226: }
227:
228: public String pieGetStringElem() throws PException {
229: throw new PExceptionTyping(
230: "Bad elem type: asked: String, been: object");
231: }
232:
233: public String pieGetStringIndexField(String fn) throws PException {
234: return null;
235: }
236:
237: public Date pieGetDateElem() throws PException {
238: throw new PExceptionTyping(
239: "Bad elem type: asked: java.util.Date, been: object");
240: }
241:
242: public Date pieGetDateIndexField(String fn) throws PException {
243: throw new PExceptionTyping("No index");
244: }
245:
246: public char[] pieGetCharArrayElem() throws PException {
247: throw new PExceptionTyping(
248: "Bad elem type: asked: char[], been: object");
249: }
250:
251: public byte[] pieGetByteArrayElem() throws PException {
252: throw new PExceptionTyping(
253: "Bad elem type: asked: byte[], been: object");
254: }
255:
256: public Serializable pieGetSerializedElem() throws PException {
257: throw new PExceptionTyping(
258: "Bad elem type: asked: Serializable, been: object");
259: }
260:
261: public void pieSetBooleanElem(boolean value) throws PException {
262: throw new PExceptionTyping(
263: "Bad elem type: asked: boolean, been: object");
264: }
265:
266: public void pieSetObooleanElem(Boolean value) throws PException {
267: throw new PExceptionTyping(
268: "Bad elem type: asked: boolean, been: object");
269: }
270:
271: public void pieSetByteElem(byte value) throws PException {
272: throw new PExceptionTyping(
273: "Bad elem type: asked: byte, been: object");
274: }
275:
276: public void pieSetObyteElem(Byte value) throws PException {
277: throw new PExceptionTyping(
278: "Bad elem type: asked: Byte, been: object");
279: }
280:
281: public void pieSetByteIndexField(String fn, byte value)
282: throws PException {
283: throw new PExceptionTyping("No index");
284: }
285:
286: public void pieSetObyteIndexField(String fn, Byte value)
287: throws PException {
288: throw new PExceptionTyping("No index");
289: }
290:
291: public void pieSetCharElem(char value) throws PException {
292: throw new PExceptionTyping(
293: "Bad elem type: asked: char, been: object");
294: }
295:
296: public void pieSetOcharElem(Character value) throws PException {
297: throw new PExceptionTyping(
298: "Bad elem type: asked: Char, been: object");
299: }
300:
301: public void pieSetCharIndexField(String fn, char value)
302: throws PException {
303: throw new PExceptionTyping("No index");
304: }
305:
306: public void pieSetOcharIndexField(String fn, Character value)
307: throws PException {
308: throw new PExceptionTyping("No index");
309: }
310:
311: public void pieSetShortElem(short value) throws PException {
312: throw new PExceptionTyping(
313: "Bad elem type: asked: short, been: object");
314: }
315:
316: public void pieSetOshortElem(Short value) throws PException {
317: throw new PExceptionTyping(
318: "Bad elem type: asked: Short, been: object");
319: }
320:
321: public void pieSetShortIndexField(String fn, short value)
322: throws PException {
323: throw new PExceptionTyping("No index");
324: }
325:
326: public void pieSetOshortIndexField(String fn, Short value)
327: throws PException {
328: throw new PExceptionTyping("No index");
329: }
330:
331: public void pieSetIntElem(int value) throws PException {
332: throw new PExceptionTyping(
333: "Bad elem type: asked: int, been: object");
334: }
335:
336: public void pieSetOintElem(Integer value) throws PException {
337: throw new PExceptionTyping(
338: "Bad elem type: asked: Int, been: object");
339: }
340:
341: public void pieSetIntIndexField(String fn, int value)
342: throws PException {
343: throw new PExceptionTyping("No index");
344: }
345:
346: public void pieSetOintIndexField(String fn, Integer value)
347: throws PException {
348: throw new PExceptionTyping("No index");
349: }
350:
351: public void pieSetLongElem(long value) throws PException {
352: throw new PExceptionTyping(
353: "Bad elem type: asked: long, been: object");
354: }
355:
356: public void pieSetOlongElem(Long value) throws PException {
357: throw new PExceptionTyping(
358: "Bad elem type: asked: Long, been: object");
359: }
360:
361: public void pieSetLongIndexField(String fn, long value)
362: throws PException {
363: throw new PExceptionTyping("No index");
364: }
365:
366: public void pieSetOlongIndexField(String fn, Long value)
367: throws PException {
368: throw new PExceptionTyping("No index");
369: }
370:
371: public void pieSetFloatElem(float value) throws PException {
372: throw new PExceptionTyping(
373: "Bad elem type: asked: float, been: object");
374: }
375:
376: public void pieSetOfloatElem(Float value) throws PException {
377: throw new PExceptionTyping(
378: "Bad elem type: asked: Float, been: object");
379: }
380:
381: public void pieSetDoubleElem(double value) throws PException {
382: throw new PExceptionTyping(
383: "Bad elem type: asked: double, been: object");
384: }
385:
386: public void pieSetOdoubleElem(Double value) throws PException {
387: throw new PExceptionTyping(
388: "Bad elem type: asked: Double, been: object");
389: }
390:
391: public void pieSetStringElem(String value) throws PException {
392: throw new PExceptionTyping(
393: "Bad elem type: asked: String, been: object");
394: }
395:
396: public void pieSetStringIndexField(String fn, String value)
397: throws PException {
398: throw new PExceptionTyping("No index");
399: }
400:
401: public void pieSetDateElem(Date value) throws PException {
402: throw new PExceptionTyping(
403: "Bad elem type: asked: java.util.Date, been: object");
404: }
405:
406: public void pieSetDateIndexField(String fn, Date value)
407: throws PException {
408: throw new PExceptionTyping("No index");
409: }
410:
411: public void pieSetCharArrayElem(char[] value) throws PException {
412: throw new PExceptionTyping(
413: "Bad elem type: asked: char[], been: object");
414: }
415:
416: public void pieSetByteArrayElem(byte[] value) throws PException {
417: throw new PExceptionTyping(
418: "Bad elem type: asked: byte[], been: object");
419: }
420:
421: public void pieSetSerializedElem(Serializable value)
422: throws PException {
423: throw new PExceptionTyping(
424: "Bad elem type: asked: Serializable, been: object");
425: }
426:
427: public BigDecimal pieGetBigDecimalElem() throws PException {
428: throw new PExceptionTyping(
429: "Bad elem type: asked: BigDecimal, been: object");
430: }
431:
432: public void pieSetBigDecimalElem(BigDecimal value)
433: throws PException {
434: throw new PExceptionTyping(
435: "Bad elem type: asked: BigDecimal, been: object");
436: }
437:
438: public java.math.BigInteger pieGetBigIntegerElem()
439: throws PException {
440: throw new PExceptionTyping(
441: "Bad elem type: asked: BigInteger, been: object");
442: }
443:
444: public void pieSetBigIntegerElem(java.math.BigInteger value)
445: throws PException {
446: throw new PExceptionTyping(
447: "Bad elem type: asked: BigInteger, been: object");
448: }
449: }
|