Package com.yahoo.docproc
Class CallStack
- java.lang.Object
-
- com.yahoo.docproc.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 stackCallStack(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 nameCallStack(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 stackCallStack
addLast(CallStack callStack)
Adds multiple elements as the last elements on this stackCallStack
addLast(DocumentProcessor processor)
Adds an element as the last element on this stackCallStack
addNext(Call call)
Push an element as the next element on this stackCallStack
addNext(CallStack callStack)
Push multiple elements as the next elements on this stackCallStack
addNext(DocumentProcessor processor)
Push an element as the next element on this stackvoid
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 leftCall
findCall(DocumentProcessor processor)
Returns the next call to this processor, or null if no such calls are leftCall
getLastPopped()
Returns the element that was last popped from this stack, or null if none have been popped or the stack is emptycom.yahoo.jdisc.Metric
getMetric()
java.lang.String
getName()
Returns the name of this stack, or null if it is not namedcom.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 elementCall
peek()
Returns the next element without removing it, or null if there are no more elementsCall
pop()
Returns and removes the next element, or null if there are no more elementsCallStack
remove(Call call)
Removes the given call.void
setName(java.lang.String name)
Sets the name of this stackint
size()
Returns the number of remaining elements in this stackjava.lang.String
toString()
-
-
-
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 stackdocprocs
- 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 elementcall
- 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 elementprocessor
- 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 elementcallStack
- 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 elementcall
- 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 elementprocessor
- 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 elementcallStack
- 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 classjava.lang.Object
-
getStatistics
public com.yahoo.statistics.Statistics getStatistics()
-
getMetric
public com.yahoo.jdisc.Metric getMetric()
-
-