org.specrunner.context
Interface IContext

All Superinterfaces:
Collection<IBlock>, Deque<IBlock>, IBlock, IBlockFactory, Iterable<IBlock>, Queue<IBlock>
All Known Implementing Classes:
ContextImpl

public interface IContext
extends Deque<IBlock>, IBlock, IBlockFactory

Stands for the plugin/test runtime environment.

Author:
Thiago Santos

Field Summary
static String UPACCESS
          String to label variable up context access.
 
Method Summary
 void addMetadata()
          Add metadata from block context.
 void clearGlobal(String global)
          Removes a variable name from global context.
 void clearLocal(String local)
          Removes a variable name from local context.
 void clearScoped(String scope, String local)
          Removes a scoped variable.
 void clearStrict(String name)
          Clear the context peek mapping from name.
 IBlock getByElement(Class<? extends nu.xom.Node> type)
          Search a block by element type.
 Object getByName(String name)
          Search a value by its name, from the most restricted block to the outermost (i.e. the root XML element).
 IBlock getByPlugin(Class<? extends IPlugin> type)
          Search a block by plugin type.
 ISource getCurrentSource()
          Get current source.
 Map<String,Object> getObjects()
          A map of all objects in context.
 IBlock getParentByElement(Class<? extends nu.xom.Node> type)
          Strict parent search by element type.
 Object getParentByName(String name)
          A strict parent search a value by its name, from the most restricted block to the outermost (i.e. the root XML element).
 IBlock getParentByPlugin(Class<? extends IPlugin> type)
          Strict parent search by plugin type.
 IRunner getRunner()
          The runner related to the context.
 Deque<ISource> getSources()
          Queue of sources.
 void saveGlobal(String global, Object obj)
          Saves a variable with the given name to the global context (outermost block).
 void saveLocal(String local, Object obj)
          Saves a variable with the given name to the local context.
 void saveScoped(String scope, String local, Object obj)
          Saves a variable to the given scope.
 void saveStrict(String name, Object value)
          Save the value to the current context peek, no matter what type of node it is.
 
Methods inherited from interface java.util.Deque
add, addFirst, addLast, contains, descendingIterator, element, getFirst, getLast, iterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 
Methods inherited from interface org.specrunner.context.IBlock
getMap, getNode, getPlugin, hasChildren, hasMap, hasNode, hasPlugin, isChanged, isValid, setChanged, setMap, setNode, setPlugin
 
Methods inherited from interface org.specrunner.context.IBlockFactory
newBlock, newBlock
 

Field Detail

UPACCESS

static final String UPACCESS
String to label variable up context access. I.e. _$index, look for first index access, if found, move context down an look for the occurrence.

See Also:
Constant Field Values
Method Detail

getSources

Deque<ISource> getSources()
Queue of sources. On file inclusion this queue is changed according and is used to avoid cyclic dependency.

Returns:
The queue.

getCurrentSource

ISource getCurrentSource()
Get current source.

Returns:
The top source.

getRunner

IRunner getRunner()
The runner related to the context.

Returns:
The runner.

saveGlobal

void saveGlobal(String global,
                Object obj)
Saves a variable with the given name to the global context (outermost block).

Parameters:
global - The variable name.
obj - The value.

clearGlobal

void clearGlobal(String global)
Removes a variable name from global context.

Parameters:
global - The variable name.

saveLocal

void saveLocal(String local,
               Object obj)
Saves a variable with the given name to the local context. The local context is defined as the immediate parent of the current node.

Parameters:
local - The variable name.
obj - The value.

clearLocal

void clearLocal(String local)
Removes a variable name from local context.

Parameters:
local - The variable name.

saveStrict

void saveStrict(String name,
                Object value)
Save the value to the current context peek, no matter what type of node it is.

Parameters:
name - The name.
value - The value.

clearStrict

void clearStrict(String name)
Clear the context peek mapping from name.

Parameters:
name - The name.

saveScoped

void saveScoped(String scope,
                String local,
                Object obj)
Saves a variable to the given scope.

Parameters:
scope - Indicates where to bind the value, i.e. when saveScope("body","name","value") is used in a "span" tag, this method searches for the "body" backward tag to add variable.
local - The variable name.
obj - The value.

clearScoped

void clearScoped(String scope,
                 String local)
Removes a scoped variable.

Parameters:
scope - The scope to unbound.
local - The variable name.

getByElement

IBlock getByElement(Class<? extends nu.xom.Node> type)
Search a block by element type.

Parameters:
type - The type.
Returns:
The nearest block that matches the type.

getParentByElement

IBlock getParentByElement(Class<? extends nu.xom.Node> type)
Strict parent search by element type.

Parameters:
type - The type.
Returns:
The nearest parent block that matches the type.

getByPlugin

IBlock getByPlugin(Class<? extends IPlugin> type)
Search a block by plugin type.

Parameters:
type - The type.
Returns:
The nearest block that matches the type.

getParentByPlugin

IBlock getParentByPlugin(Class<? extends IPlugin> type)
Strict parent search by plugin type.

Parameters:
type - The type.
Returns:
The nearest parent block that matches the type.

getByName

Object getByName(String name)
Search a value by its name, from the most restricted block to the outermost (i.e. the root XML element).

Parameters:
name - The name.
Returns:
The nearest block that matches the type.

getParentByName

Object getParentByName(String name)
A strict parent search a value by its name, from the most restricted block to the outermost (i.e. the root XML element).

Parameters:
name - The name.
Returns:
The nearest block that matches the type.

getObjects

Map<String,Object> getObjects()
A map of all objects in context. Names are resolved from most specific to most general.

Returns:
The naming mapping for this context.

addMetadata

void addMetadata()
Add metadata from block context.



Copyright © 2014. All rights reserved.