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) 2011-2011 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.calc.impl; 011 012import mondrian.calc.TupleCursor; 013import mondrian.olap.Evaluator; 014import mondrian.olap.Member; 015 016/** 017 * Abstract implementation of {@link mondrian.calc.TupleIterator}. 018 * 019 * <p>Derived classes need to implement only {@link #forward()}. 020 * 021 * @author jhyde 022 */ 023public abstract class AbstractTupleCursor implements TupleCursor { 024 protected final int arity; 025 026 public AbstractTupleCursor(int arity) { 027 super(); 028 this.arity = arity; 029 } 030 031 public void setContext(Evaluator evaluator) { 032 evaluator.setContext(current()); 033 } 034 035 public void currentToArray(Member[] members, int offset) { 036 if (offset == 0) { 037 current().toArray(members); 038 } else { 039 //noinspection SuspiciousSystemArraycopy 040 System.arraycopy(current().toArray(), 0, members, offset, arity); 041 } 042 } 043 044 public int getArity() { 045 return arity; 046 } 047 048 public Member member(int column) { 049 return current().get(column); 050 } 051} 052 053// End AbstractTupleCursor.java