Half-commit. Not finished.
package horaris;
import ogdl.OgdlParser;
import ogdl.parser.*;
import java.util.Vector;
import java.util.Hashtable;
public class Horaro extends ParserHandlerBase
{
private final int S_RADIKO = 0;
private final int S_TAGOJ = 1;
private final int S_ENTAGO = 2;
private final int S_LOKOJ = 3;
private final int S_SENCOJ = 4;
private final int S_FINO = 5;
public Vector tagoj;
public int defaulttago = 0;
public Vector lokoj;
public Vector sencoj;
public Hashtable sencolokoj;
private int state;
private int nivelo;
public Horaro()
{
tagoj = new Vector();
lokoj = new Vector();
sencoj = new Vector();
}
private void addTago(String s)
{
tagoj.addElement(s);
}
private void addLoko(String s)
{
lokoj.addElement(s);
}
private void addSenco(String s)
{
sencoj.addElement(s);
}
private void add(String s)
{
if (nivelo == 0)
{
System.err.println("Nivelo 0: " + s);
if (s.equals("Dies"))
state = S_TAGOJ;
else if (s.equals("Sentits"))
state = S_SENCOJ;
else if (s.equals("Llocs"))
state = S_LOKOJ;
else if (s.equals("Comboi"))
state = S_FINO;
} else if (nivelo == 1)
{
System.err.println("Nivelo 1: " + s);
switch(state)
{
case S_TAGOJ:
addTago(s);
break;
case S_LOKOJ:
addLoko(s);
break;
case S_SENCOJ:
addSenco(s);
break;
}
} else if (nivelo == 2) {
System.err.println("Nivelo 2");
}
}
public boolean event(int speco, int level, String s)
{
if (speco != OgdlParser.CONTENT)
return true;
if (s == null) return true;
nivelo = level;
add(s);
if (state == S_FINO)
return false;
else
return true;
}
}