/**
 * 
 */
package dspl.intermediate.variable;

/**
 * The DSPL Variable type for Strings<p>
 * Strings must be atomic (arrays of Strings not supported). 
 * @author David
 */
public class DSPLString extends Variable {
	/**
	 * Constructor for DSPLString
	 * @param numElements number of elemnts, must be 1, since arrays of strings are not supported
	 */
	public DSPLString(int numElements) {
		super(numElements);
		if (numElements!=1) { 
			throw new Error("Error: numElements!=1 passed to DSPLString. Only atomic instances of String allowed, not arrays"); 
		}
	}
	
	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#isNumeric()
	 */
	public boolean isNumeric() {
		return false;
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#getByteSize()
	 */
	public int getDataTypeByteSize() {
		return 4; //a string is just a memory value (32bit) in the symbol table
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#getVariableDataType()
	 */
	public int getDataType() {
		return Variable.DATA_TYPE_STRING; 
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#convertToObject(java.lang.String)
	 */
	public Object convertToObject(String strValue) {
		return strValue; 
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#convertToObject(java.lang.String, java.lang.String)
	 */
	public Object convertToObject(String strValue1, String strValue2) {
		throw new Error("Error: convertToObject(String, String) called on " + this.getClass().toString()); 
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#isNaturalNum
	 */
	public boolean isNaturalNum() {
		return false; 
	}
}
