conditionantName = this.noCaseChangeValue;
// consistency check C09: verify whether is conditionant of the node
if (this.getNode() != null) {
if (!this.isValidConditionant(this.getMEBN(), this.getNode(), conditionantName )) {
// Debug.println("->" + getNode());
throw new InvalidConditionantException();
}
}
} else {
try{
expected("Identifier");
} catch (TableFunctionMalformedException e) {
throw new InvalidConditionantException(e);
}
}
// LOOK FOR = OPERATOR
match('=');
// SCAN FOR CONDITIONANTS' POSSIBLE STATES
scan();
// Debug.println("SCANED FOR CONDITIONANTS' POSSIBLE STATES");
if (token == 'x') {
// TODO the name of the possible value may contain caracters like dots, but this method cannot handle such characters
// consistency check C09: verify whether conditionant has valid values
if (this.getNode() != null) {
if (!this.isValidConditionantValue(this.getMEBN(),conditionantName,this.noCaseChangeValue)) {
throw new InvalidConditionantException();
}
}
} else {
try{
expected("Identifier");
} catch (TableFunctionMalformedException e) {
throw new InvalidConditionantException(e);
}
}
// if code reached here, the condicionant check is ok
// prepare to add current temp table's header's parent (condicionant list)
MultiEntityNode mebnNode = null;
for (INode parent : getNode().getParentNodes()) {
if (parent == null) {
try {
Debug.println(getClass(), getNode() + " contains a null parent...");
} catch (Throwable t) {
t.printStackTrace();
}
continue;
}
String parentName = null;
if (parent instanceof InputNode) {
InputNode inputNode = (InputNode) parent;
if (inputNode.getResidentNodePointer() != null && inputNode.getResidentNodePointer().getResidentNode() != null) {
parentName = inputNode.getResidentNodePointer().getResidentNode().getName();
} else {
try {
Debug.println(getClass(), inputNode + " is not pointing to a resident node...");
} catch (Throwable t) {
t.printStackTrace();
}
}
} else {
parentName = parent.getName();
}
if (conditionantName.equalsIgnoreCase(parentName)
&& (parent instanceof MultiEntityNode)) {
mebnNode = (MultiEntityNode)parent;
}
}
// If not found, its an error!
if (mebnNode == null) {
try{
expected("Identifier");
} catch (TableFunctionMalformedException e) {
throw new InvalidConditionantException(e);
}
}
Entity condvalue = null;
// search for an entity with a name this.value
ResidentNode possibleValueHolder = null;
if (mebnNode instanceof InputNode) {
possibleValueHolder = ((InputNode) mebnNode).getResidentNodePointer().getResidentNode();
} else if (mebnNode instanceof ResidentNode) {
possibleValueHolder = (ResidentNode)mebnNode;
} else {
throw new InvalidConditionantException(this.value + " must be either a resident node or an input node.");
}
for (Entity possibleValue : possibleValueHolder.getPossibleValueListIncludingEntityInstances()) {
if (possibleValue.getName().equalsIgnoreCase(this.value)) {
condvalue = possibleValue;
break;
}
}
// If not found, its an error!
if (condvalue == null) {
try{
expected("Identifier");
} catch (TableFunctionMalformedException e) {
throw new InvalidConditionantException(e);
}
}
// Set temp table's header condicionant
TempTableHeaderParent headerParent = new TempTableHeaderParent(mebnNode, condvalue);
// TODO optimize above code, because its highly redundant (condvalue should be found anyway on that portion of code)