Class CallStack

java.lang.Object
com.yahoo.docproc.CallStack

public class CallStack extends Object
A stack of the processors to call next in this processing. To push which processor to call next, call addNext, to get and remove the next processor, call pop. This is not thread safe.
Author:
bratseth
  • Constructor Details

    • CallStack

      public CallStack()
    • CallStack

      public CallStack(String name)
    • CallStack

      public CallStack(com.yahoo.jdisc.Metric metric)
      Creates an empty stack
    • CallStack

      public CallStack(String name, com.yahoo.jdisc.Metric metric)
      Creates an empty stack with a name
    • CallStack

      public CallStack(CallStack stackToCopy)
      Creates a stack from another stack (starting at the next of the given callstack) This does a deep copy of the stack.
    • CallStack

      public CallStack(String name, Collection<DocumentProcessor> docprocs, com.yahoo.jdisc.Metric metric)
      Creates a stack (with a given name) based on a collection of document processors, which are added to the stack in the iteration order of the collection.
      Parameters:
      name - the name of the stack
      docprocs - the document processors to call
  • Method Details

    • getName

      public String getName()
      Returns the name of this stack, or null if it is not named
    • setName

      public void setName(String name)
      Sets the name of this stack
    • addNext

      public CallStack addNext(Call call)
      Push an element as the next element on this stack
      Returns:
      this for convenience
    • addNext

      public CallStack addNext(DocumentProcessor processor)
      Push an element as the next element on this stack
      Returns:
      this for convenience
    • addNext

      public CallStack addNext(CallStack callStack)
      Push multiple elements as the next elements on this stack
      Returns:
      this for convenience
    • addLast

      public CallStack addLast(Call call)
      Adds an element as the last element on this stack
      Returns:
      this for convenience
    • addLast

      public CallStack addLast(DocumentProcessor processor)
      Adds an element as the last element on this stack
      Returns:
      this for convenience
    • addLast

      public CallStack addLast(CallStack callStack)
      Adds multiple elements as the last elements on this stack
      Returns:
      this for convenience
    • addBefore

      public CallStack addBefore(Call before, Call call)
      Adds an element just before the first occurence of some other element on the stack. This can not be called during an iteration.
      Parameters:
      before - the call to add this before. If this call is not present (the same object instance), new processor is added as the last element
      call - the call to add
      Returns:
      this for convenience
    • addBefore

      public CallStack addBefore(Call before, DocumentProcessor processor)
      Adds an element just before the first occurence of some element on the stack. This can not be called during an iteration.
      Parameters:
      before - the call to add this before. If this call is not present (the same object instance), the new processor is added as the last element
      processor - the processor to add
      Returns:
      this for convenience
    • addBefore

      public CallStack addBefore(Call before, CallStack callStack)
      Adds multiple elements just before the first occurence of some element on the stack. This can not be called during an iteration.
      Parameters:
      before - the call to add this before. If this call is not present (the same object instance), the new processor is added as the last element
      callStack - the calls to add
      Returns:
      this for convenience
    • addAfter

      public CallStack addAfter(Call after, Call call)
      Adds an element just after the first occurence of some other element on the stack. This can not be called during an iteration.
      Parameters:
      after - the call to add this before. If this call is not present, (the same object instance), the new processor is added as the last element
      call - the call to add
      Returns:
      this for convenience
    • addAfter

      public CallStack addAfter(Call after, DocumentProcessor processor)
      Adds an element just after the first occurence of some other element on the stack. This can not be called during an iteration.
      Parameters:
      after - the call to add this after. If this call is not present, (the same object instance), the new processor is added as the last element
      processor - the processor to add
      Returns:
      this for convenience
    • addAfter

      public CallStack addAfter(Call after, CallStack callStack)
      Adds multiple elements just after another given element on the stack. This can not be called during an iteration.
      Parameters:
      after - the call to add this before. If this call is not present, (the same object instance), the new processor is added as the last element
      callStack - the calls to add
      Returns:
      this for convenience
    • remove

      public CallStack remove(Call call)
      Removes the given call. Does nothing if the call is not present.
      Parameters:
      call - the call to remove
      Returns:
      this for convenience
    • contains

      public boolean contains(Call call)
      Returns whether this stack has this call (left)
      Parameters:
      call - the call to check
      Returns:
      true if the call is present, false otherwise
    • findCall

      public Call findCall(com.yahoo.component.ComponentId processorId)
      Returns the next call to this processor id, or null if no such calls are left
    • findCall

      public Call findCall(DocumentProcessor processor)
      Returns the next call to this processor, or null if no such calls are left
    • pop

      public Call pop()
      Returns and removes the next element, or null if there are no more elements
    • peek

      public Call peek()
      Returns the next element without removing it, or null if there are no more elements
    • getLastPopped

      public Call getLastPopped()
      Returns the element that was last popped from this stack, or null if none have been popped or the stack is empty
    • clear

      public void clear()
    • iterator

      public ListIterator<Call> iterator()
      Returns a modifiable ListIterator over all the remaining elements of this stack, starting by the next element
    • size

      public int size()
      Returns the number of remaining elements in this stack
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMetric

      public com.yahoo.jdisc.Metric getMetric()