package edu.stanford.rt.datatype;
import edu.stanford.rt.util.*;
/**
* @author Ninghui Li, Sandra Qiu
*
* A SingletonValueSet object is a value set that
* conatins a single value of SimpleType
.
*/
public class SingletonValueSet extends ValueSet
{
private DataValue value;
/**
* Constructor for SingletonValueSet.
*/
public SingletonValueSet(SimpleType type, DataValue value)
{
super(type);
if (! type.isValidValue(value))
{
throw new IllegalArgumentException("Value type does not match");
}
this.value = value;
}
/**
* Method getValue.
* @return DataValue
*/
public DataValue getValue()
{
return this.value;
}
/* (non-Javadoc)
* @see edu.stanford.rt.datatype.ValueSet#toString(String)
*/
public String toString(String indent)
{
String thisIndent = indent + " ";
StringBuffer sb = new StringBuffer();
sb.append(thisIndent).append("SingletonValueSet: \n");
sb.append(thisIndent+" ").append(getType().toString()).append("\n");
sb.append(thisIndent+" ").append(value.toString());
return sb.toString();
}
}