Example usage for org.apache.commons.collections.iterators ObjectArrayIterator ObjectArrayIterator

List of usage examples for org.apache.commons.collections.iterators ObjectArrayIterator ObjectArrayIterator

Introduction

In this page you can find the example usage for org.apache.commons.collections.iterators ObjectArrayIterator ObjectArrayIterator.

Prototype

public ObjectArrayIterator(Object[] array) 

Source Link

Document

Constructs an ObjectArrayIterator that will iterate over the values in the specified array.

Usage

From source file:org.archive.crawler.frontier.WorkQueueFrontier.java

/**
 * This method compiles a human readable report on the status of the frontier
 * at the time of the call.// www  .j a  v  a  2  s. c o  m
 * @param name Name of report.
 * @param writer Where to write to.
 */
@Override
public synchronized void reportTo(PrintWriter writer) {
    int allCount = allQueues.size();
    int inProcessCount = inProcessQueues.size();
    int readyCount = readyClassQueues.size();
    int snoozedCount = getSnoozedCount();
    int activeCount = inProcessCount + readyCount + snoozedCount;
    int inactiveCount = getTotalInactiveQueues();
    int retiredCount = getRetiredQueues().size();
    int exhaustedCount = allCount - activeCount - inactiveCount - retiredCount;

    writer.print("Frontier report - ");
    writer.print(ArchiveUtils.get12DigitDate());
    writer.print("\n");
    writer.print(" Job being crawled: ");
    writer.print(controller.getMetadata().getJobName());
    writer.print("\n");
    writer.print("\n -----===== STATS =====-----\n");
    writer.print(" Discovered:    ");
    writer.print(Long.toString(discoveredUriCount()));
    writer.print("\n");
    writer.print(" Queued:        ");
    writer.print(Long.toString(queuedUriCount()));
    writer.print("\n");
    writer.print(" Finished:      ");
    writer.print(Long.toString(finishedUriCount()));
    writer.print("\n");
    writer.print("  Successfully: ");
    writer.print(Long.toString(succeededFetchCount()));
    writer.print("\n");
    writer.print("  Failed:       ");
    writer.print(Long.toString(failedFetchCount()));
    writer.print("\n");
    writer.print("  Disregarded:  ");
    writer.print(Long.toString(disregardedUriCount()));
    writer.print("\n");
    writer.print("\n -----===== QUEUES =====-----\n");
    writer.print(" Already included size:     ");
    writer.print(Long.toString(uriUniqFilter.count()));
    writer.print("\n");
    writer.print("               pending:     ");
    writer.print(Long.toString(uriUniqFilter.pending()));
    writer.print("\n");
    writer.print("\n All class queues map size: ");
    writer.print(Long.toString(allCount));
    writer.print("\n");
    writer.print("             Active queues: ");
    writer.print(activeCount);
    writer.print("\n");
    writer.print("                    In-process: ");
    writer.print(inProcessCount);
    writer.print("\n");
    writer.print("                         Ready: ");
    writer.print(readyCount);
    writer.print("\n");
    writer.print("                       Snoozed: ");
    writer.print(snoozedCount);
    writer.print("\n");
    writer.print("           Inactive queues: ");
    writer.print(inactiveCount);
    writer.print(" (");
    Map<Integer, Queue<String>> inactives = getInactiveQueuesByPrecedence();
    boolean betwixt = false;
    for (Integer k : inactives.keySet()) {
        if (betwixt) {
            writer.print("; ");
        }
        writer.print("p");
        writer.print(k);
        writer.print(": ");
        writer.print(inactives.get(k).size());
        betwixt = true;
    }
    writer.print(")\n");
    writer.print("            Retired queues: ");
    writer.print(retiredCount);
    writer.print("\n");
    writer.print("          Exhausted queues: ");
    writer.print(exhaustedCount);
    writer.print("\n");

    State last = lastReachedState;
    writer.print("\n             Last state: " + last);

    writer.print("\n -----===== MANAGER THREAD =====-----\n");
    ToeThread.reportThread(managerThread, writer);

    writer.print("\n -----===== " + largestQueues.size() + " LONGEST QUEUES =====-----\n");
    appendQueueReports(writer, "LONGEST", largestQueues.getEntriesDescending().iterator(), largestQueues.size(),
            largestQueues.size());

    writer.print("\n -----===== IN-PROCESS QUEUES =====-----\n");
    Collection<WorkQueue> inProcess = inProcessQueues;
    ArrayList<WorkQueue> copy = extractSome(inProcess, maxQueuesPerReportCategory);
    appendQueueReports(writer, "IN-PROCESS", copy.iterator(), copy.size(), maxQueuesPerReportCategory);

    writer.print("\n -----===== READY QUEUES =====-----\n");
    appendQueueReports(writer, "READY", this.readyClassQueues.iterator(), this.readyClassQueues.size(),
            maxQueuesPerReportCategory);

    writer.print("\n -----===== SNOOZED QUEUES =====-----\n");
    Object[] objs = snoozedClassQueues.toArray();
    DelayedWorkQueue[] qs = Arrays.copyOf(objs, objs.length, DelayedWorkQueue[].class);
    Arrays.sort(qs);
    appendQueueReports(writer, "SNOOZED", new ObjectArrayIterator(qs), getSnoozedCount(),
            maxQueuesPerReportCategory);

    writer.print("\n -----===== INACTIVE QUEUES =====-----\n");
    SortedMap<Integer, Queue<String>> sortedInactives = getInactiveQueuesByPrecedence();
    for (Integer prec : sortedInactives.keySet()) {
        Queue<String> inactiveQueues = sortedInactives.get(prec);
        appendQueueReports(writer, "INACTIVE-p" + prec, inactiveQueues.iterator(), inactiveQueues.size(),
                maxQueuesPerReportCategory);
    }

    writer.print("\n -----===== RETIRED QUEUES =====-----\n");
    appendQueueReports(writer, "RETIRED", getRetiredQueues().iterator(), getRetiredQueues().size(),
            maxQueuesPerReportCategory);

    writer.flush();
}

From source file:org.lockss.filter.pdf.TestTransformEachPage.java

public void testGetSelectedPages() throws Exception {
    final PdfPage[] pages = new PdfPage[] { new MockPdfPage(), new MockPdfPage(), new MockPdfPage(), };
    MockPdfDocument mockPdfDocument = new MockPdfDocument() {
        public PdfPage getPage(int index) {
            return pages[index];
        }/*from  w w w .  j  a  v  a  2s.co  m*/

        public ListIterator getPageIterator() {
            return new ObjectArrayListIterator(pages);
        }
    };

    TransformSelectedPages documentTransform = new TransformEachPage(
            new PageTransformUtil.IdentityPageTransform());
    assertIsomorphic(new ObjectArrayIterator(pages), documentTransform.getSelectedPages(mockPdfDocument));
}

From source file:org.lockss.servlet.LockssServlet.java

/** Common page setup. */
protected Page newPage() {
    // Compute heading
    String heading = getHeading();
    if (heading == null) {
        heading = "Box Administration";
    }/*  w  w  w . j  a va 2 s .c  o  m*/

    // Create page and layout header
    Page page = ServletUtil.doNewPage(getPageTitle(), isFramed());
    Iterator inNavIterator;
    if (myServletDescr().hasNoNavTable()) {
        inNavIterator = CollectionUtil.EMPTY_ITERATOR;
    } else {
        inNavIterator = new FilterIterator(new ObjectArrayIterator(getServletDescrs()), new Predicate() {
            public boolean evaluate(Object obj) {
                return isServletInNav((ServletDescr) obj);
            }
        });
    }
    ServletUtil.layoutHeader(this, page, heading, isLargeLogo(), getMachineName(), getMachineIpAddr(),
            getLockssApp().getStartDate(), inNavIterator);
    String warnMsg = servletMgr.getWarningMsg();
    if (warnMsg != null) {
        Composite warning = new Composite();
        warning.add("<center><font color=red size=+1>");
        warning.add(warnMsg);
        warning.add("</font></center><br>");
        page.add(warning);
    }
    return page;
}

From source file:org.lockss.servlet.ProxyAndContent.java

private Iterator getDescriptors_Content() {
    return new ObjectArrayIterator(new LinkWithExplanation[] {
            makeDescriptor("Edit Default Access Group", BAD_ACTION,
                    "Edit the members of the default access group."),
            makeDescriptor("Edit Access Group", BAD_ACTION, "Edit the members of an access group."),
            makeDescriptor("Create Access Group", BAD_ACTION, "Create an access group."),
            makeDescriptor("Delete Access Group", BAD_ACTION, "Delete an access group."),
            makeDescriptor("Configure AU Access", BAD_ACTION,
                    "Select the access groups associated with an archival unit."), });
}

From source file:org.lockss.servlet.UiHome.java

protected Iterator getDescriptors() {
    // Iterate over the servlet descriptors...
    Iterator iterateOverDescr = new ObjectArrayIterator(getServletDescrs());

    // ...select those that appear in UiHome...
    Predicate selectUiHome = new Predicate() {
        public boolean evaluate(Object obj) {
            ServletDescr d = (ServletDescr) obj;
            return isServletDisplayed(d) && d.isInUiHome(UiHome.this);
        }// ww  w.  ja  v a 2  s. c  om
    };

    // ...and transform them into LinkWithExplanation pairs
    Transformer fromDescrToLink = new Transformer() {
        public Object transform(Object obj) {
            ServletDescr d = (ServletDescr) obj;
            return new LinkWithExplanation(srvLink(d, d.heading), d.getExplanation());
        }
    };

    return new TransformIterator(new FilterIterator(iterateOverDescr, selectUiHome), fromDescrToLink);
}

From source file:org.lockss.test.LockssTestCase.java

/**
 * <p>Returns a test suite with the combined tests in all the
 * nested classes found in <code>thisClass</code> that extend
 * the <code>extendedClass</code> class.</p>
 * <p>Typically this will lead to the parameters being
 * <code>(myTestCase, myTestCase)</code> or
 * <code>(myTestCase, myTesterClass)</code>.</p>
 * @param thisClass     The class whose variant nested classes are
 *                      being extracted by reflection.
 * @param extendedClass The class that variant classes have to extend
 *                      in order to be extracted by reflection.
 * @return A test suite incorporating the tests of all the extracted
 *         nested classes.//from  ww  w .j  ava  2s .c  om
 * @see #variantSuites(Class[])
 */
public static Test variantSuites(Class thisClass, Class extendedClass) {
    ArrayList list = new ArrayList();
    for (Iterator iter = new ObjectArrayIterator(thisClass.getDeclaredClasses()); iter.hasNext();) {
        Class cla = (Class) iter.next();
        if (extendedClass.isAssignableFrom(cla)) {
            list.add(cla);
        }
    }

    Class[] classes = new Class[list.size()];
    list.toArray(classes);
    return variantSuites(classes);
}

From source file:org.lockss.util.PdfUtil.java

public static Iterator getPdf16Operators() {
    return UnmodifiableIterator.decorate(new ObjectArrayIterator(PDF_1_6_OPERATORS));
}