package net.sourceforge.mayfly.ldbc;

import net.sourceforge.mayfly.*;

import net.sourceforge.mayfly.util.*;
import org.ldbc.parser.*;

import java.util.*;

public class Froms extends Aggregate {

    private List dimensions = new ArrayList();


    public Froms() { }

    public Froms(List dimensions) {
        this.dimensions = dimensions;
    }


    protected Aggregate createNew(Iterable items) {
        return new Froms(new L().slurp(items));
    }

    public Iterator iterator() {
        return dimensions.iterator();
    }

    public Froms add(From from) {
        dimensions.add(from);
        return this;
    }

    public L tableNames() {
        return collect(new GetTableName());
    }


    public static Froms fromSelectTree(Tree selectTree) {
        Tree.Children tables = selectTree.children().ofType(SQLTokenTypes.SELECTED_TABLE);

        List elements = new ArrayList();

        for (Iterator iterator = tables.iterator(); iterator.hasNext();) {
            Tree table = (Tree) iterator.next();

            From from = From.fromSeletedTableTree(table);

            elements.add(from);
        }

        return new Froms(elements);
    }



    public static class GetTableName implements Transformer {
        public Object transform(Object obj) {
            From f = (From) obj;
            return f.tableName();
        }
    }

}

@@ -35,42 +35,8 @@
 c;%0A%0A
-import net.sourceforge.mayfly.*;%0A%0A
 impo
@@ -69,16 +69,17 @@
 util.*;%0A
+%0A
 import o

Remove unused import.