001: /**
002: * Copyright (C) 2001-2004 France Telecom R&D
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package org.objectweb.speedo.genclass.api;
018:
019: import org.objectweb.jorm.type.api.PType;
020: import org.objectweb.jorm.api.PBinding;
021: import org.objectweb.util.monolog.api.Logger;
022: import org.objectweb.speedo.genclass.api.SpeedoGenClassCoherence;
023: import org.objectweb.speedo.genclass.api.SpeedoGenClassListener;
024: import org.objectweb.speedo.mim.api.PersistentObjectItf;
025:
026: /**
027: * This interfaces represents a PersistentObjectItf for a generic class (Collectio, Set,
028: * Map, ...)
029: * It permits to specify the mapper throught the generic class is persistent.
030: * The Mapper name permits to know the type of GenClassMapping and
031: * GenClassBinding (rdb, fos, ...).
032: *
033: * The PType of the generic class permit to known which is GenClassMapping
034: * instance to use.
035: *
036: * @author S.Chassande-Barrioz
037: */
038: public interface SpeedoGenClassPO extends PersistentObjectItf,
039: SpeedoGenClassCoherence {
040:
041: /**
042: * Assignes the PType of the generic class.
043: * @param ptype of the generic class
044: */
045: void speedoSetPType(PType ptype);
046:
047: /**
048: * @return the PType of the generic class.
049: */
050: PType speedoGetPType();
051:
052: /**
053: * @return a string which represents the fully path of the persistent field
054: * of the class with wich the generic class is persistent.
055: * If the linked fiekf is the 'f1' provided by the class 'com.foo.Bar'
056: * then the returned string will be 'com.foo.Bar/f1'
057: */
058: String speedoGetGenClassId();
059:
060: /**
061: * Assignes the linked field name for this generic class.
062: * @param lf is tring which represents the fully path of the persistent
063: * field of the class with wich the generic class is persistent.
064: * If the linked fiekf is the 'f1' provided by the class 'com.foo.Bar'
065: * then the expected string is 'com.foo.Bar/f1'
066: */
067: void speedoSetLinkedField(String lf);
068:
069: /**
070: * assignes the PBinding to use to load/store the generic class
071: * Call this method with null value means that the generic is no more
072: * persistent.
073: * @param pb is the PBinding.
074: */
075: void speedoSetPBinding(PBinding pb);
076:
077: /**
078: * @return the pbinding associated to the generic class. The value is not
079: * used if the generic class is not persistent.
080: */
081: PBinding speedoGetPBinding();
082:
083: /**
084: * Assignes the new value of the generic class (Collection, Map or Array
085: * or ...).
086: */
087: void setElements(Object o);
088:
089: Object createGenClass();
090:
091: /**
092: * Sets the id of this gen class instance (id of the field that references
093: * this instance).
094: *
095: * @param gcid the new id of this gen class instance.
096: */
097: void speedoSetGcId(int gcid);
098:
099: /**
100: * Adds a listener to this gen class instance. This listener will be
101: * notified each time an element is added or removed for this gen class.
102: *
103: * @param l a gen class listener.
104: */
105: void speedoAddGenClassListener(SpeedoGenClassListener l);
106:
107: /**
108: * Notifies the listeners of this gen class that an element has been added
109: * to this gen class.
110: *
111: * @param elem the element that has been added.
112: */
113: void fireSpeedoElementAdded(Object elem);
114:
115: /**
116: * Notifies the listeners of this gen class that an element has been removed
117: * to this gen class.
118: *
119: * @param elem the element that has been removed.
120: */
121: void fireSpeedoElementRemoved(Object elem);
122:
123: void clear();
124:
125: /**
126: * Initializes a Genclass instance
127: * @param ptype is the PType of the genclass
128: * @param linkedField is the name of the field referencing the genclass
129: * @param pnameHints is a helper using for the identifier allocation (export)
130: * persistent
131: * @param logger is the logger instance for logging.
132: */
133: void init(PType ptype, String linkedField, Object pnameHints,
134: Logger logger);
135:
136: /**
137: * Assignes the hints needed to build the PName of the persistent object
138: * during the export action.
139: */
140: void speedoSetPNameHints(Object hints);
141: }
|