package Ext_Tools;
import java.util.Iterator;
import java.util.Vector;
/**
*
* Task of this class
* It represents a row value constructor which can be a row value constructor element (value expression)
* or a row value constructor list (comma separated and in brackets).
*/
public class ValueExprList {
private Vector VEL;
public ValueExprList(ValueExpr newElem) {
VEL = new Vector();
VEL.add(newElem);
}
public ValueExprList addElement(ValueExpr newElem) {
this.VEL.add(newElem);
return this;
}
/**
*
* Task of this method
* it is needed to check whether this object contains a value constructor element or a
* value constructor list.
* @return true if it is an value constructor element
*/
public boolean moreThanOne() {
return (this.VEL.size() > 1);
}
/**
*
* Task of this method
* it returns the ValueExpr of the list. moreThanOne() needs to be checked beforehand and
* must be positive
* @return
*/
public ValueExpr getValueExpr() {
return this.VEL.get(0);
}
public boolean containsSub() {
boolean result = false;
if (this.VEL.size() == 1)
result = this.VEL.get(0).containsSub();
return result;
}
/**
*
* Task of this method
* returns the ValueExprList as a String
* @return
*/
public String getValueExprList() {
Iterator it;
String result = "";
it = this.VEL.iterator();
if (it.hasNext())
result = it.next().getStrValueExpr();
while (it.hasNext())
result += ", " + it.next().getStrValueExpr();
if (this.VEL.size() > 1)
result = "[" + result + "]";
return result;
}
}