[Biojava-l] I get an IndexOutOfBoundsException with visitFilter in WalkerFactory

Benjamin Schuster-Boeckler benjamins at Biomax.de
Fri Jan 9 05:30:05 EST 2004


Hy.

I'm trying to handle the nodes of the filter tree with the visitFilter 
method now. To do so, I wrote a FilterHandler class that looks like:

--------------------------- snip -----------------------------
public final class FilterHandler implements 
org.biojava.utils.walker.Visitor {

    public String and( FeatureFilter.And ffa, String ch1, String ch2 ) {
        return ch1 + " AND " + ch2;
    }

    public String or( FeatureFilter.Or ffo, String ch1, String ch2 ) {
        return ch1 + " OR " + ch2;
    }

    public String not( FeatureFilter.Not ffn, String ch1 ) {
         return "NOT " + ch1;
    }

    public String byAncestor( FeatureFilter.ByAncestor ffb, String ch1) {
        return "BYANCESTOR" + ch1;
    }

    public String byClass( FeatureFilter.ByClass ffc ) {
        return ffc.getTestClass().getName();
    }

    public String byType( FeatureFilter.ByType fft ) {
       return fft.getType();
    }

    public String overlapsLocation( FeatureFilter.OverlapsLocation ffo ) {
       return "["+ffo.getLocation().getMin()+", 
"+ffo.getLocation().getMax()+"]";
    }
}
--------------------------- snap -----------------------------

Of course, this is just a test yet, so later these methods should do 
something more useful ;-) Now, what I get is

--------------------------- snip -----------------------------

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
	at java.util.ArrayList.RangeCheck(ArrayList.java:507)
	at java.util.ArrayList.get(ArrayList.java:324)
	at org.biojava.utils.walker.WalkerFactory.generateWalker(WalkerFactory.java:299)
	at org.biojava.utils.walker.WalkerFactory.getWalker(WalkerFactory.java:61)
	at org.biojava.bio.seq.FilterUtils.visitFilter(FilterUtils.java:988)

	at com.biomax.pedant3.das.ContigSequence.filter(ContigSequence.java:132)

--------------------------- snap -----------------------------

the filter that was passed to visitFilter was

Not(ByAncestor(ByClass(org.biojava.bio.seq.ComponentFeature))) <- 
gathered by toString()

but from debugging I found out that the error happened while evaluating 
the "and" method in WalkerFactory.getWalker. In line 299, the getWalker 
method tries to get as many elements out of the vector "wrappedLVs" as 
there are parameters to the handler-method, but wrappedLVs only has 1 
element, which is null I think. How can this be?!

Greetings, Benjamin





More information about the Biojava-l mailing list