001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.commons.math.ode.sampling; 019 020 021 /** 022 * This class is a step handler that does nothing. 023 024 * <p>This class is provided as a convenience for users who are only 025 * interested in the final state of an integration and not in the 026 * intermediate steps. Its handleStep method does nothing.</p> 027 * 028 * <p>Since this class has no internal state, it is implemented using 029 * the Singleton design pattern. This means that only one instance is 030 * ever created, which can be retrieved using the getInstance 031 * method. This explains why there is no public constructor.</p> 032 * 033 * @see StepHandler 034 * @version $Revision: 786881 $ $Date: 2009-06-20 14:53:08 -0400 (Sat, 20 Jun 2009) $ 035 * @since 1.2 036 */ 037 038 public class DummyStepHandler implements StepHandler { 039 040 /** Private constructor. 041 * The constructor is private to prevent users from creating 042 * instances (Singleton design-pattern). 043 */ 044 private DummyStepHandler() { 045 } 046 047 /** Get the only instance. 048 * @return the only instance 049 */ 050 public static DummyStepHandler getInstance() { 051 return instance; 052 } 053 054 /** Determines whether this handler needs dense output. 055 * Since this handler does nothing, it does not require dense output. 056 * @return always false 057 */ 058 public boolean requiresDenseOutput() { 059 return false; 060 } 061 062 /** Reset the step handler. 063 * Initialize the internal data as required before the first step is 064 * handled. 065 */ 066 public void reset() { 067 } 068 069 /** 070 * Handle the last accepted step. 071 * This method does nothing in this class. 072 * @param interpolator interpolator for the last accepted step. For 073 * efficiency purposes, the various integrators reuse the same 074 * object on each call, so if the instance wants to keep it across 075 * all calls (for example to provide at the end of the integration a 076 * continuous model valid throughout the integration range), it 077 * should build a local copy using the clone method and store this 078 * copy. 079 * @param isLast true if the step is the last one 080 */ 081 public void handleStep(final StepInterpolator interpolator, final boolean isLast) { 082 } 083 084 /** The only instance. */ 085 private static final DummyStepHandler instance = new DummyStepHandler(); 086 087 }