001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.record;
025:
026: import jacareto.struct.StructureElement;
027: import jacareto.system.Environment;
028:
029: import java.io.IOException;
030: import java.io.ObjectInputStream;
031: import java.io.ObjectOutputStream;
032: import java.io.Serializable;
033:
034: /**
035: * This is an abstract superclass for elements which can be stored to a record. These record
036: * elements are called "recordables".
037: *
038: * <p>
039: * Subclasses should call the {@link
040: * StructureElement#fireStructureElementEvent(StructureElementEvent)} method whenever the state of
041: * the recordable changes. This method notifies all RecordableChangeListeners added to this object
042: * of the recordable change.
043: * </p>
044: *
045: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
046: * @version 1.04
047: */
048: public abstract class Recordable extends StructureElement implements
049: Serializable {
050: /**
051: * Creates a recordable with the given environment.
052: *
053: * @param env the env object
054: */
055: public Recordable(Environment env) {
056: super (env);
057: setDuration(0L);
058: }
059:
060: /**
061: * Creates a recordable with no environment; the environment should be defined with the method
062: * {@link jacareto.system.EnvironmentMember#setEnvironment(Environment)} before environment
063: * instances will be accessed.
064: */
065: public Recordable() {
066: this (null);
067: }
068:
069: /**
070: * Customized method for serializing recordables
071: *
072: * @param aStream the stream to read from.
073: *
074: * @throws IOException DOCUMENT ME!
075: * @throws ClassNotFoundException DOCUMENT ME!
076: */
077: private void readObject(ObjectInputStream aStream)
078: throws IOException, ClassNotFoundException {
079: aStream.defaultReadObject();
080:
081: //manually deserialize and init superclass
082: Long durationLong = (Long) aStream.readObject();
083: Long procTimeLong = (Long) aStream.readObject();
084: String uuidString = (String) aStream.readObject();
085: setProcTime(procTimeLong.longValue());
086: setDuration(durationLong.longValue());
087: setUUIDString(uuidString);
088: }
089:
090: /**
091: * Customized method for serializing recordables
092: *
093: * @param aStream the stream to write to.
094: *
095: * @throws IOException DOCUMENT ME!
096: */
097: private void writeObject(ObjectOutputStream aStream)
098: throws IOException {
099: aStream.defaultWriteObject();
100:
101: //manually serialize superclass
102: aStream.writeObject(new Long(getDuration()));
103: aStream.writeObject(new Long(getProcTime()));
104: aStream.writeObject(getUUIDString());
105: }
106: }
|