public int updateIntList(int addr, List<String> stringValues) throws SAXException {
int first = addr;
int currLength = this.getLength(this.neIntListType, addr);
int curNode = addr;
int prevNode = 0;
IntRedBlackTree visited = new IntRedBlackTree();
boolean foundCycle = false;
int i =0;
//if (currLength != stringValues.size() ) {
// first = createIntList(stringValues);
if (currLength < stringValues.size()) {
while (cas.getHeapValue(curNode) == neIntListType) {
if (!visited.put(curNode, curNode)) {
foundCycle = true;
break;
}
int value = Integer.parseInt(stringValues.get(i++));
cas.setFeatureValue(curNode,floatHeadFeat, value);
prevNode = curNode;
curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
}
//add nodes for remaining values
if (i < stringValues.size()) {
int emptyListFs = curNode;
//check that first is eintlisttype
while (i < stringValues.size()) {
int newNode = cas.ll_createFS(neIntListType);
int value = Integer.parseInt((String) stringValues.get(i++));
cas.setFeatureValue(newNode,intHeadFeat, value);
cas.setFeatureValue(newNode, intTailFeat, emptyListFs);
cas.setFeatureValue(prevNode, intTailFeat, newNode);
prevNode = newNode;
}
}
} else if (currLength > stringValues.size()) {
while (cas.getHeapValue(curNode) == neIntListType && i < stringValues.size()) {
if (!visited.put(curNode, curNode)) {
foundCycle = true;
break;
}
float value = Integer.parseInt((String) stringValues.get(i++));
cas.setFeatureValue(curNode,intHeadFeat, value);
curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
}
int finalNode = curNode;
//loop till we get a FS that is of type eStringListType
while (cas.getHeapValue(curNode) == neIntListType) {
if (!visited.put(curNode, curNode)) {
foundCycle = true;
break;
//TODO throw exc
}
curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
}
//set the tail feature to eStringListType fs
cas.setFeatureValue(finalNode, intTailFeat, curNode);
} else {
while (cas.getHeapValue(curNode) == neIntListType) {
if (!visited.put(curNode, curNode)) {
foundCycle = true;
break;
}
int value = Integer.parseInt((String) stringValues.get(i++));
cas.setFeatureValue(curNode,intHeadFeat, value );