Class CallStack


  • public class CallStack
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      CallStack()  
      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​(com.yahoo.statistics.Statistics statistics, com.yahoo.jdisc.Metric metric)
      Creates an empty stack
      CallStack​(java.lang.String name)  
      CallStack​(java.lang.String name, com.yahoo.statistics.Statistics manager, com.yahoo.jdisc.Metric metric)
      Creates an empty stack with a name
      CallStack​(java.lang.String name, java.util.Collection<DocumentProcessor> docprocs, com.yahoo.statistics.Statistics manager, 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CallStack addAfter​(Call after, Call call)
      Adds an element just after the first occurence of some other element on the stack.
      CallStack addAfter​(Call after, CallStack callStack)
      Adds multiple elements just after another given element on the stack.
      CallStack addAfter​(Call after, DocumentProcessor processor)
      Adds an element just after the first occurence of some other element on the stack.
      CallStack addBefore​(Call before, Call call)
      Adds an element just before the first occurence of some other element on the stack.
      CallStack addBefore​(Call before, CallStack callStack)
      Adds multiple elements just before the first occurence of some element on the stack.
      CallStack addBefore​(Call before, DocumentProcessor processor)
      Adds an element just before the first occurence of some element on the stack.
      CallStack addLast​(Call call)
      Adds an element as the last element on this stack
      CallStack addLast​(CallStack callStack)
      Adds multiple elements as the last elements on this stack
      CallStack addLast​(DocumentProcessor processor)
      Adds an element as the last element on this stack
      CallStack addNext​(Call call)
      Push an element as the next element on this stack
      CallStack addNext​(CallStack callStack)
      Push multiple elements as the next elements on this stack
      CallStack addNext​(DocumentProcessor processor)
      Push an element as the next element on this stack
      void clear()  
      boolean contains​(Call call)
      Returns whether this stack has this call (left)
      Call findCall​(com.yahoo.component.ComponentId processorId)
      Returns the next call to this processor id, or null if no such calls are left
      Call findCall​(DocumentProcessor processor)
      Returns the next call to this processor, or null if no such calls are left
      Call getLastPopped()
      Returns the element that was last popped from this stack, or null if none have been popped or the stack is empty
      com.yahoo.jdisc.Metric getMetric()  
      java.lang.String getName()
      Returns the name of this stack, or null if it is not named
      com.yahoo.statistics.Statistics getStatistics()  
      java.util.ListIterator<Call> iterator()
      Returns a modifiable ListIterator over all the remaining elements of this stack, starting by the next element
      Call peek()
      Returns the next element without removing it, or null if there are no more elements
      Call pop()
      Returns and removes the next element, or null if there are no more elements
      CallStack remove​(Call call)
      Removes the given call.
      void setName​(java.lang.String name)
      Sets the name of this stack
      int size()
      Returns the number of remaining elements in this stack
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CallStack

        public CallStack()
      • CallStack

        public CallStack​(java.lang.String name)
      • CallStack

        public CallStack​(com.yahoo.statistics.Statistics statistics,
                         com.yahoo.jdisc.Metric metric)
        Creates an empty stack
      • CallStack

        public CallStack​(java.lang.String name,
                         com.yahoo.statistics.Statistics manager,
                         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​(java.lang.String name,
                         java.util.Collection<DocumentProcessor> docprocs,
                         com.yahoo.statistics.Statistics manager,
                         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 Detail

      • getName

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

        public void setName​(java.lang.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 java.util.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getStatistics

        public com.yahoo.statistics.Statistics getStatistics()
      • getMetric

        public com.yahoo.jdisc.Metric getMetric()