LeftTuple entry = tuple;
// Add all the FactHandles except the root DroolQuery object
while ( entry.getIndex() > 0 ) {
InternalFactHandle handle = entry.getLastHandle();
handles[entry.getIndex()] = new DisconnectedFactHandle( handle.getId(),
handle.getIdentityHashCode(),
handle.getObjectHashCode(),
handle.getRecency(),
handle.getObject() );
entry = entry.getParent();
}
// Get the Query object
InternalFactHandle handle = entry.getLastHandle();
DroolsQuery query = (DroolsQuery) handle.getObject();
// Copy of it's arguments for unification variables.
Object[] args = query.getElements();
Object[] newArgs = new Object[args.length];
for ( int i = 0, length = args.length; i < length; i++ ) {
if ( args[i] instanceof Variable ) {
newArgs[i] = ((Variable) args[i]).getValue();
} else {
newArgs[i] = args[i];
}
}
handles[entry.getIndex()] = new DisconnectedFactHandle( handle.getId(),
handle.getIdentityHashCode(),
handle.getObjectHashCode(),
handle.getRecency(),
new ArrayElements( newArgs ) );