001: /**
002: * Copyright (C) 2008 NetMind Consulting Bt.
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.1 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 hu.netmind.persistence;
018:
019: import java.io.Serializable;
020: import java.util.Date;
021:
022: /**
023: * An object of this class represents all persistence related information
024: * about an object, which BeanKeeper is aware of.
025: * @author Brautigam Robert
026: * @version CVS Revision: $Revision$
027: */
028: public class PersistenceMetaData implements Serializable {
029: private Long persistenceId;
030: private Long persistenceStart;
031: private Long persistenceEnd;
032: private Long querySerial;
033: private Class objectClass;
034:
035: /**
036: * Get the creation date of <strong>this version</strong>
037: * of the object. If the object is not yet saved, this
038: * value is null. Only committed creation dates are given.
039: * If the object is saved in a transaction, but the
040: * transaction did not yet commit, then this date will reflect
041: * the last committed creation date of the object (before
042: * the transaction).<br>
043: * Selecting the object later with this date will give
044: * the same version only if this version of the object
045: * lived at least 1 millisecond (it was not deleted
046: * or superseded in that time). If it didn't, then the next
047: * version of the object is selected which lived at least
048: * 1 millisecond.
049: */
050: public Date getCreationDate() {
051: if (getPersistenceStart() == null)
052: return null;
053: return DateSerialUtil
054: .getDate(getPersistenceStart().longValue());
055: }
056:
057: /**
058: * Get the deletion date of <strong>this version</strong>
059: * of the object. If the object was not yet saved, then
060: * this value is null. If the object was not yet deleted,
061: * but it exists in the database, then this date is an extremal
062: * big date. Selecting the object on this date
063: * will select the next version of the object which lived at least
064: * 1 millisecond.
065: */
066: public Date getRemoveDate() {
067: if (getPersistenceEnd() == null)
068: return null;
069: return DateSerialUtil.getDate(getPersistenceEnd().longValue());
070: }
071:
072: /**
073: * Get the persistence id of the object. This id is
074: * available to non-existent objects too, and it does
075: * not ever change. Not if the object does not exist
076: * yet, and not if a new version is saved or the object
077: * is deleted.
078: */
079: public Long getPersistenceId() {
080: return persistenceId;
081: }
082:
083: void setPersistenceId(Long persistenceId) {
084: this .persistenceId = persistenceId;
085: }
086:
087: /**
088: * Get the creation serial number of this version. This is
089: * a unique number based on dates. All versions will have different
090: * serial numbers.
091: */
092: public Long getPersistenceStart() {
093: return persistenceStart;
094: }
095:
096: void setPersistenceStart(Long persistenceStart) {
097: this .persistenceStart = persistenceStart;
098: }
099:
100: /**
101: * Get the end serial. If the object is not deleted, then
102: * this is Long.MAX_VALUE.
103: */
104: public Long getPersistenceEnd() {
105: return persistenceEnd;
106: }
107:
108: void setPersistenceEnd(Long persistenceEnd) {
109: this .persistenceEnd = persistenceEnd;
110: }
111:
112: Long getQuerySerial() {
113: return querySerial;
114: }
115:
116: void setQuerySerial(Long querySerial) {
117: this .querySerial = querySerial;
118: }
119:
120: public Class getObjectClass() {
121: return objectClass;
122: }
123:
124: void setObjectClass(Class objectClass) {
125: this.objectClass = objectClass;
126: }
127: }
|