/*
 * $Source: /usr/local/cvsroot/erserver/erserver/java/src/com/postgres/replic/util/struct/SnapshotDataRow.java,v $
 * $Author: asullivan $ $Revision: 1.1.1.1 $ $Date: 2003/08/26 19:02:31 $
 *
 */

package com.postgres.replic.util.struct;

import java.util.*;

public class SnapshotDataRow  implements  DataConst {

    // Key uniquely identifying the row (for deletes - this is the only
    // parameter necessary):
    private String key;
    private long lastsid;
    private boolean useoid;

    // Possible values of lastsid:
    public static final int THIS = -999;
    public static final int ANY = -9999;

    // Array list of Strings containing data for update or insert:
    private ArrayList dataArray = new ArrayList();

    public SnapshotDataRow(String key, long lastsid, boolean useoid)
    throws Exception {
        this.key = key;
        this.lastsid = lastsid;
    }

    public boolean useOid() {
        return this.useoid;
    }

    public void setUseOid(boolean useoid) {
        this.useoid = useoid;
    }

    public void setLastSid(long lastsid) {
        this.lastsid = lastsid;
    }

    public long getLastSid() {
        return lastsid;
    }

    public void add(String data) {
         dataArray.add(data);
    }

    public String get(int i) {
         return (String) dataArray.get(i);
    }

    public long getLong(int i) {
         return (new Long((String) dataArray.get(i))).longValue();
    }

    public void remove(int i) {
         dataArray.remove(i);
    }

    public int size() {
        return dataArray.size();
    }

    public String getKey(){
        return key;
    }

    public long getKeyLong(){
        return key == null ? 0 : new Long(key).longValue();
    }

    public int getKeyInt(){
        return key == null ? 0 : new Integer(key).intValue();
    }
}
