public void endGet() throws IOException { for (ILookupManagerUnit<B> orderedBeanLookup : lookupList) { orderedBeanLookup.close(); } clear(); lookupList = null; }
public void lookup(B key) throws IOException { waitingNext = false; if (matchingMode == MATCHING_MODE.ALL_MATCHES) { lookupIndex = 0; for (int lookupIndexLocal = 0; lookupIndexLocal < lookupListSize; lookupIndexLocal++) { ILookupManagerUnit<B> tempLookup = lookupList[lookupIndexLocal]; tempLookup.lookup(key); } } else { try { if (lookupKey.compareTo(key) == 0 && previousResultRetrieved) { nextIsPreviousResult = true; } else { previousResultRetrieved = false; previousResult = null; } } catch (NullPointerException e) { previousResultRetrieved = false; previousResult = null; } noMoreNext = false; } key.copyDataTo(lookupKey); lookupKeyIsInitialized = true; }
public B next() throws IOException { if (nextIsPreviousResult) { nextIsPreviousResult = false; noMoreNext = true; return previousResult; } if (waitingNext) { waitingNext = false; previousResult = currLookup.next(); if (matchingMode == MATCHING_MODE.LAST_MATCH || matchingMode == MATCHING_MODE.FIRST_MATCH) { previousResultRetrieved = true; noMoreNext = true; } return previousResult; } else { throw new NoSuchElementException(); } }
public boolean hasNext() throws IOException { if (waitingNext || nextIsPreviousResult) { return true; } if (!lookupKeyIsInitialized || noMoreNext) { return false; } if (matchingMode == MATCHING_MODE.LAST_MATCH || matchingMode == MATCHING_MODE.UNIQUE_MATCH) { for (int lookupIndexLocal = lookupListSize - 1; lookupIndexLocal >= 0; lookupIndexLocal--) { ILookupManagerUnit<B> tempLookup = lookupList[lookupIndexLocal]; // System.out.println("########################################"); // System.out.println(lookupKey); // System.out.println("lookupIndexLocal=" + lookupIndexLocal); tempLookup.lookup(lookupKey); if (tempLookup.hasNext()) { // System.out.println("Found in " + lookupIndexLocal); currLookup = tempLookup; waitingNext = true; noMoreNext = true; previousResultRetrieved = false; return true; } } noMoreNext = true; return false; } else if (matchingMode == MATCHING_MODE.ALL_MATCHES) { for (; lookupIndex < lookupListSize; lookupIndex++) { ILookupManagerUnit<B> tempLookup = lookupList[lookupIndex]; if (tempLookup.hasNext()) { currLookup = tempLookup; waitingNext = true; return true; } } return false; } else if (matchingMode == MATCHING_MODE.FIRST_MATCH) { for (int lookupIndexLocal = 0; lookupIndexLocal < lookupListSize; lookupIndexLocal++) { ILookupManagerUnit<B> tempLookup = lookupList[lookupIndexLocal]; tempLookup.lookup(lookupKey); if (tempLookup.hasNext()) { currLookup = tempLookup; waitingNext = true; noMoreNext = true; previousResultRetrieved = false; return true; } } noMoreNext = true; return false; } else { if (currLookup.hasNext()) { waitingNext = true; return true; } lookupIndex++; return false; } }