PDA

View Full Version : in memory table - arraylist


BubikolRamios
02-05-2010, 09:41 PM
OK, probably somebody did this already but I can't find it ....

The point: have 4 column of data,
then be able to find somethng like with sql like


select col2 where col1 = param


This already works, suggestions for code shrinking ... ?
Or source of better code that already is doing this ...



package xx;

import java.util.ArrayList;

public class czs
{
ArrayList start_arr = new ArrayList();
ArrayList al_char = new ArrayList();
ArrayList al_friend = new ArrayList();
ArrayList al_numeric = new ArrayList();
ArrayList al_hex = new ArrayList();

public czs()
{

start_arr.add("À|À|À|À");
start_arr.add("à|à|à|à");
//etc ....

java.util.Iterator it1 = start_arr.iterator();

while (it1.hasNext())
{
this.al_char.add(((String)it1.next()).split("\\|")[0]);
this.al_friend.add(((String)it1.next()).split("\\|")[1]);
this.al_numeric.add(((String)it1.next()).split("\\|")[2]);
this.al_hex.add(((String)it1.next()).split("\\|")[3]);
}
}

// this forinstance for str '#268' returns 'č'
public String numerical_to_character(String str)
{
int pos = this.al_numeric.indexOf(str);
return String.valueOf(this.al_char.get(pos));
}


}