Package eu.europa.ted.efx.model
Class ContextStack
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<E>
-
- java.util.Stack<Context>
-
- eu.europa.ted.efx.model.ContextStack
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Context>,Collection<Context>,List<Context>,RandomAccess
public class ContextStack extends Stack<Context>
Used to keep trak of the current evaluation context. Extends Stack<Context> to provide helper methods for pushing directly using a fieldId or a nodeId. The point is to make it easier to use a context stack and reduce the possibility of coding mistakes.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description ContextStack(SymbolResolver symbols)Creates a new ContextStack.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression.PathExpressionabsolutePath()Returns the absolute path of the context that is currently at the top of the stack.BooleanisFieldContext()Returns true if the context at the top of the stack is aContext.FieldContext.BooleanisNodeContext()Returns true if the context at the top of the stack is aContext.NodeContext.Context.FieldContextpushFieldContext(String fieldId)Creates a new Context for the given field and places it at the top of the stack.Context.NodeContextpushNodeContext(String nodeId)Creates a new Context for the given node and places it at the top of the stack.Expression.PathExpressionrelativePath()Returns the relative path of the context that is currently at the top of the stack.Stringsymbol()Returns the [field or node] identifier that was used to create the context that is currently at the top of the stack.-
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Constructor Detail
-
ContextStack
public ContextStack(SymbolResolver symbols)
Creates a new ContextStack.- Parameters:
symbols- the SymbolMap is used to resolve fieldIds and nodeIds.
-
-
Method Detail
-
pushFieldContext
public Context.FieldContext pushFieldContext(String fieldId)
Creates a new Context for the given field and places it at the top of the stack. The new Context is determined by the field itself, and it is made to be relative to the one currently at the top of the stack (or absolute if the stack is empty).
-
pushNodeContext
public Context.NodeContext pushNodeContext(String nodeId)
Creates a new Context for the given node and places it at the top of the stack. The new Context is relative to the one currently at the top of the stack (or absolute if the stack is empty).
-
isFieldContext
public Boolean isFieldContext()
Returns true if the context at the top of the stack is aContext.FieldContext. Does not remove the context from the stack.
-
isNodeContext
public Boolean isNodeContext()
Returns true if the context at the top of the stack is aContext.NodeContext. Does not remove the context from the stack.
-
symbol
public String symbol()
Returns the [field or node] identifier that was used to create the context that is currently at the top of the stack. Does not remove the context from the stack.
-
absolutePath
public Expression.PathExpression absolutePath()
Returns the absolute path of the context that is currently at the top of the stack. Does not remove the context from the stack.
-
relativePath
public Expression.PathExpression relativePath()
Returns the relative path of the context that is currently at the top of the stack. Does not remove the context from the stack.
-
-