net.sourceforge.openforecast.input
Class AbstractBuilder

java.lang.Object
  extended by net.sourceforge.openforecast.input.AbstractBuilder
All Implemented Interfaces:
Builder
Direct Known Subclasses:
CSVBuilder, ResultSetBuilder, TimeSeriesBuilder

public abstract class AbstractBuilder
extends Object
implements Builder

Defines an abstract Builder class that provides some common functionality and helper methods for use by sub-classes.

Since:
0.4
Author:
Steven R. Gould

Constructor Summary
AbstractBuilder()
           
 
Method Summary
protected  void addVariable(String name)
          Adds the variable name to the end of the list of variables currently defined for this Builder.
protected  int getNumberOfVariables()
          Returns the number of variables currently defined in this AbstractBuilder.
protected  String getVariableName(int index)
          Returns the variable name with the given index.
protected  void setNumberOfVariables(int n)
          Sets the number of variables to be defined/referenced by this AbstractBuilder.
protected  void setVariableName(int index, String name)
          Sets the name for the variable with the given index to the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.openforecast.input.Builder
build
 

Constructor Detail

AbstractBuilder

public AbstractBuilder()
Method Detail

addVariable

protected void addVariable(String name)
Adds the variable name to the end of the list of variables currently defined for this Builder.

Parameters:
name - the name of the new variable.

setVariableName

protected void setVariableName(int index,
                               String name)
Sets the name for the variable with the given index to the given name.

Parameters:
index - the index of the variable whose name to set.
name - the name of the given variable.

getNumberOfVariables

protected int getNumberOfVariables()
Returns the number of variables currently defined in this AbstractBuilder.

Returns:
the number of variables currently defined.

setNumberOfVariables

protected void setNumberOfVariables(int n)
Sets the number of variables to be defined/referenced by this AbstractBuilder. If no variable names are later defined, then this is used to return the number of variables defined.

Parameters:
n - the number of variables to be defined.

getVariableName

protected String getVariableName(int index)
Returns the variable name with the given index. If one or more variable names have already been defined, then this method will only return one of the variable names that were previously defined. If a variable name for the given index does not exist, then an IndexOutOfBoundsException will be thrown.

If no variable names have been defined, then it is assumed that the "default" names, xi, should be used. In this case, an exception will only be thrown if the index number requested exceeds the number of variables set using a previous call to setNumberOfVariables(int).

Parameters:
index - the index of the variable whose name to get.
Throws:
IndexOutOfBoundsException - if one or more variable names have been specified, but not one with the given index; or the number of variables has been defined (with no variable names being specified) and the index exceeds the number of variables defined.


OpenForecast, Copyright (c) Steven Gould, 2002-2011