VersionHistorySegment.java :  » Database-DBMS » perst » org » garret » perst » continuous » Java Open Source

Java Open Source » Database DBMS » perst 
perst » org » garret » perst » continuous » VersionHistorySegment.java
package org.garret.perst.continuous;

import org.garret.perst.*;

class VersionHistorySegment extends Persistent 
{ 
    CVersionHistory vh;
    int from;
    int till;

    boolean containsLastVersion() 
    { 
        return vh.getNumberOfVersions() == till;
    }

    CVersion getCurrentVersion(long transId) 
    { 
        CVersion v = vh.getCurrent(transId);
        return v != null && v.id >= from && v.id <= till ? v : null;
    }

    void increment() 
    {
        till += 1;
        store();
    }

    void decrement() 
    {
        from += 1;
        store();
    }

    VersionHistorySegment(CVersion v) 
    { 
        super(v.getStorage());
        vh = v.history;
        Assert.that(vh != null);
        from = till = v.id;
    }

    VersionHistorySegment(CVersionHistory vh, int from, int till) 
    { 
        super(vh.getStorage());
        this.vh = vh;
        this.from = from;
        this.till = till;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.