/** * This class is not thread safe, changes to the working memory during * iteration may give unexpected results */ public Iterator iterateFactHandles(org.drools.runtime.ObjectFilter filter) { return getObjectStore().iterateFactHandles( filter ); }
/** * This class is not thread safe, changes to the working memory during * iteration may give unexpected results */ public Iterator iterateFactHandles() { return getObjectStore().iterateFactHandles(); }
public static InternalFactHandle[] orderFacts(ObjectStore objectStore) { // this method is just needed for testing purposes, to allow round tripping int size = objectStore.size(); InternalFactHandle[] handles = new InternalFactHandle[size]; int i = 0; for (Iterator<?> it = objectStore.iterateFactHandles(); it.hasNext();) { handles[i++] = (InternalFactHandle) it.next(); } Arrays.sort(handles, new HandleSorter()); return handles; }
public Iterator< ? > iterator() { Iterator it; if ( type == OBJECT ) { if ( filter != null ) { it = store.iterateObjects( filter ); } else { it = store.iterateObjects(); } } else { if ( filter != null ) { it = store.iterateFactHandles( filter ); } else { it = store.iterateFactHandles(); } } return it; }
public static InternalFactHandle[] orderFacts(ObjectStore objectStore) { // this method is just needed for testing purposes, to allow round tripping int size = objectStore.size(); InternalFactHandle[] handles = new InternalFactHandle[size]; int i = 0; for ( Iterator it = objectStore.iterateFactHandles(); it.hasNext(); ) { handles[i++] = (InternalFactHandle) it.next(); } Arrays.sort( handles, new HandleSorter() ); return handles; }
private <K> InternalFactHandle lookupHandleForWrapper( K core ) { for ( WorkingMemoryEntryPoint ep : workingMemory.getEntryPoints().values() ) { ObjectStore store = ((InternalWorkingMemoryEntryPoint) ep).getObjectStore(); Iterator iter = store.iterateFactHandles(); while ( iter.hasNext() ) { InternalFactHandle handle = (InternalFactHandle) iter.next(); if ( handle.isTraitable() && handle.getObject() instanceof CoreWrapper && ( (CoreWrapper) handle.getObject() ).getCore() == core ) { return handle; } } } return null; }
@Test public void testCollection() throws Exception { TypeResolver resolver = new ClassTypeResolver(new HashSet<String>(), Thread.currentThread().getContextClassLoader()); resolver.addImport("org.drools.Cheesery"); resolver.addImport("org.drools.Cheese"); WorkingMemory wm = getWorkingMemory("test_rules2.drl"); ScenarioRunner run = new ScenarioRunner( resolver, getClassLoader(), (InternalWorkingMemory) wm); Scenario scenario = new Scenario(); run.run(scenario); Iterator iterator = ((InternalWorkingMemory) wm).getObjectStore().iterateFactHandles(); while (iterator.hasNext()){ FactHandle next = (FactHandle) iterator.next(); FactHandle next1 = next; } }