/*
 * $Id$
 */

package au.id.chenery.mapyrus;

import java.lang.String;

/**
 * An argument is a literal value or variable name.
 * Each field read from a dataset is an argument.
 * Several arguments can be combined with operators to make an expression
 * For example, '2 * a + 7' contains three arguments.
 */
public class Argument
{
	public static final int NUMERIC = 0;
	public static final int STRING = 1;
	public static final int VARIABLE = 2;
	public static final int GEOMETRY = 3;
	
	private int mType;
	private double mNumericValue;
	private String mStringValue;
	private String mVarname;
	private double []mGeometryValue;
	
	/**
	 * Create a new numeric argument.
	 * @param d is value for this argument.
	 */
	public Argument(double d)
	{
		mType = NUMERIC;
		mNumericValue = d;
	}
	
	/**
	 * Create a new string argument or variable name.
	 * @param type is STRING to create a string argument, or VARIABLE to create
	 * a reference to a variable.
	 */
	public Argument(int type, String s)
	{
		mType = type;
		if (type == STRING)
			mStringValue = s;
		else
			mVarname = s;
	}

	/**
	 * Create a new numeric argument.
	 * @param d is value for this argument.
	 */
	public Argument(double []coords)
	{
		mType = GEOMETRY;
		mGeometryValue = coords;
	}

	/**
	 * Returns type of argument.
	 * @return either NUMERIC, STRING, VARIABLE, or GEOMETRY.
	 */	
	public int getType()
	{
		return(mType);
	}
	
	/**
	 * Returns value of numeric argument.
	 * @return numeric argument value.
	 */
	public double getNumericValue()
	{
		return(mNumericValue);
	}
	
	/**
	 * Returns value of string argument.
	 * @return string argument value.
	 */
	public String getStringValue()
	{
		return(mStringValue);
	}

	/**
	 * Returns variable name reference of argument.
	 * @return name of variable containing value for this argument.
	 */	
	public String getVariableName()
	{
		return(mVarname);
	}

	/**
	 * Returns value of geometry argument.
	 * @return geometry argument value.
	 */	
	public double []getGeometryValue()
	{
		return(mGeometryValue);
	}
	
	/**
	 * Set argument to a numeric value.
	 * @param d value to set.
	 */	
	public void setNumericValue(double d)
	{
		mType = NUMERIC;
		mNumericValue = d;
	}
	
	/**
	 * Set argument to a string.
	 * @param s value to set.
	 */	
	public void setStringValue(String s)
	{
		mType = STRING;
		mStringValue = s;
	}
	
	/**
	 * Set argument to geometry.
	 * @param coords is geometry to set.
	 */
	public void setGeometryValue(double []coords)
	{
		mType = GEOMETRY;
		mGeometryValue = coords;
	}
}

@@ -482,17 +482,558 @@
 RY = 3;%0A
-%09
+%0A%09/**%0A%09 * Constant for numeric value zero.%0A%09 * Avoids allocating many arguments for this commonly used value.%0A%09 */%0A%09public static final Argument numericZero = new Argument(0.0);%0A%0A%09/**%0A%09 * Constant for numeric value one.%0A%09 * Avoids allocating many arguments for this commonly used value.%0A%09 */%0A%09public static final Argument numericOne = new Argument(1.0);%0A%0A%09/**%0A%09 * Constant for empty string.%0A%09 * Avoids allocating many arguments for this commonly used value.%0A%09 */%0A%09public static final Argument emptyString = new Argument(Argument.STRING, %22%22);%0A
 %0A%09privat
@@ -2588,500 +2588,6 @@
 %0A%09%7D%0A
-%09%0A%09/**%0A%09 * Set argument to a numeric value.%0A%09 * @param d value to set.%0A%09 */%09%0A%09public void setNumericValue(double d)%0A%09%7B%0A%09%09mType = NUMERIC;%0A%09%09mNumericValue = d;%0A%09%7D%0A%09%0A%09/**%0A%09 * Set argument to a string.%0A%09 * @param s value to set.%0A%09 */%09%0A%09public void setStringValue(String s)%0A%09%7B%0A%09%09mType = STRING;%0A%09%09mStringValue = s;%0A%09%7D%0A%09%0A%09/**%0A%09 * Set argument to geometry.%0A%09 * @param coords is geometry to set.%0A%09 */%0A%09public void setGeometryValue(double %5B%5Dcoords)%0A%09%7B%0A%09%09mType = GEOMETRY;%0A%09%09mGeometryValue = coords;%0A%09%7D%0A
 %7D%0A

Add constants for 0, 1, "". Chop out set methods, they are too dangerous as an argument may be changed, even though another argument pointing to the same object does not want the value to be changed!