All pastes #259615 Raw Edit

Mine

public text v1 · immutable
#259615 ·published 2006-11-27 16:24 UTC
rendered paste body
/*
 * primitiveDB.java
 *
 * Created on 27. November 2006, 15:41
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package javaapplication5.db;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author kj09
 */
public class primitiveDB {
    public ArrayList db;
   
    /** Creates a new instance of primitiveDB */
    public primitiveDB() {
        db = new ArrayList();
        
    }
    public void add(int row, int col, String data){
        System.out.println("Data added to DB - Column: "+col+" Row: "+row+" Data: "+data);
        //First we will check if a record with this id already exists:
        if(db.size() >= row && row != 0){ //Yes, a record with this id already exists.
            data_base_entry entry = (data_base_entry) db.get(row);
            entry.add(col, data);
        }else{ //No, we will make a full new entry.
            data_base_entry entry = new data_base_entry();
            entry.add(col, data);
            db.add(row, entry);
        }
    }
    public int getLastRow(){ //The LastRow of this db (ID)
        return(db.size()); 
    }
    
    public int getLastCol(int row){
        data_base_entry entry = (data_base_entry) db.get(row);
        return(entry.getLastCol());
    }
    
    
}