Code:
public static IStructResult coercionToStruct(IAbstractQueryResult res){
IStructResult s=null;
s=(IStructResult)res;
System.out.println(s.toString());
return s;
}
QResStack qres = new QResStack();
qres.push(new IntegerResult(1)); // (1)
qres.push(new DoubleResult(2.1)); // (2)
{ // (3)
IAbstractQueryResult resRight = qres.pop();
IAbstractQueryResult resLeft = qres.pop();
//iloczyn kartezjanski - operator przecinka
IBagResult commaRes = QExecUtils.cartesianProduct(resLeft, resRight);
qres.push(commaRes);
}
qres.push(new IntegerResult(3)); // (4)
qres.push(new IntegerResult(4)); // (5)
{ // (6)
IntegerResult resRight = (IntegerResult) qres.pop();
IntegerResult resLeft = (IntegerResult) qres.pop();
IntegerResult plusRes = new IntegerResult(resLeft.getValue() + resRight.getValue());
qres.push(plusRes);
}
{ // (7)
IAbstractQueryResult resRight = qres.pop();
IAbstractQueryResult resLeft = qres.pop();
//iloczyn kartezjanski - operator przecinka
IBagResult commaRes = QExecUtils.cartesianProduct(resLeft, resRight);
qres.push(commaRes);
}
{ // (8)
IAbstractQueryResult res = qres.pop();
//sprawdzenie i ew. zamiana pojedynczego elementu
//na strukture jednoelementowa
[B]IStructResult struct = QExecUtils.coercionToStruct(res);[/B] [B]<--- here i get null pointer exception[/B]
IBagResult bagRes = new BagResult();
for(ISingleResult sr : struct.elements()) {
bagRes.getElements().add(sr);
}
qres.push(bagRes);
}
Comment