001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2004-2005 Julian Hyde
008// Copyright (C) 2005-2009 Pentaho and others
009// All Rights Reserved.
010*/
011package mondrian.rolap;
012
013import mondrian.rolap.agg.GroupingSet;
014
015import java.util.ArrayList;
016import java.util.List;
017
018/**
019 * <p>The <code>GroupingSetsCollector</code> collects the GroupinpSets and pass
020 * the consolidated list to form group by grouping sets sql</p>
021 *
022 * @author Thiyagu
023 * @since 06-Jun-2007
024 */
025public class GroupingSetsCollector {
026
027    private final boolean useGroupingSets;
028
029    private ArrayList<GroupingSet> groupingSets = new ArrayList<GroupingSet>();
030
031    public GroupingSetsCollector(boolean useGroupingSets) {
032        this.useGroupingSets = useGroupingSets;
033    }
034
035    public boolean useGroupingSets() {
036        return useGroupingSets;
037    }
038
039    public void add(GroupingSet aggInfo) {
040        assert groupingSets.isEmpty()
041            || groupingSets.get(0).getColumns().length
042            >= aggInfo.getColumns().length;
043        groupingSets.add(aggInfo);
044    }
045
046    public List<GroupingSet> getGroupingSets() {
047        return groupingSets;
048    }
049}
050
051// End GroupingSetsCollector.java