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.olap4j;
011
012import mondrian.olap.QueryTiming;
013import mondrian.spi.ProfileHandler;
014
015import org.olap4j.OlapStatement;
016
017import java.io.PrintWriter;
018
019/**
020 * Access to non-public methods in the package of the mondrian olap4j driver.
021 *
022 * <p>All methods in this class are subject to change without notice.
023 *
024 * @author jhyde
025 * @since October, 2010
026 */
027public final class Unsafe {
028    public static final Unsafe INSTANCE = new Unsafe();
029
030    private Unsafe() {
031    }
032
033    public void setStatementProfiling(
034        OlapStatement statement,
035        final PrintWriter pw)
036    {
037        ((MondrianOlap4jStatement) statement).enableProfiling(
038            new ProfileHandler() {
039                public void explain(String plan, QueryTiming timing) {
040                    pw.println(plan);
041                    if (timing != null) {
042                        pw.println(timing);
043                    }
044                }
045            }
046        );
047    }
048}
049
050// End Unsafe.java