public class ContextImpl extends LinkedList<IBlock> implements IContext
| Modifier and Type | Field and Description |
|---|---|
protected IChannel |
channel
The context channel.
|
protected static int |
CURRENT
Node index.
|
protected static int |
PARENT
Parent index.
|
protected IRunner |
runner
The runner.
|
protected Deque<ISource> |
sources
Queue of sources.
|
modCount| Constructor and Description |
|---|
ContextImpl(ISource source,
IRunner runner)
Creates a context from a source and a runner.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected Object |
findName(int start,
String name)
Find an object by name.
|
protected IBlock |
findNode(int start,
Class<? extends nu.xom.Node> type)
Find a node type.
|
protected IBlock |
findPlugin(int start,
Class<? extends IPlugin> type)
Find a plugin by type.
|
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.
|
IBlock |
getByPlugin(Class<? extends IPlugin> type)
Search a block by plugin type.
|
ISource |
getCurrentSource()
Get current source.
|
Map<String,Object> |
getMap()
Mapping of elements related to the block.
|
nu.xom.Node |
getNode()
Returns the specification node object related to the block.
|
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.
|
IBlock |
getParentByPlugin(Class<? extends IPlugin> type)
Strict parent search by plugin type.
|
IPlugin |
getPlugin()
The plugin related to the block.
|
IRunner |
getRunner()
The runner related to the context.
|
Deque<ISource> |
getSources()
Queue of sources.
|
boolean |
hasChildren()
Indicates if the block node has children.
|
boolean |
hasMap()
Indicates if block has a mapping or not.
|
boolean |
hasName(String name)
Check if name is present in context.
|
boolean |
hasNode()
Indicates if block has been created form a specification or not.
|
boolean |
hasPlugin()
Indicates if block has a plugin or not.
|
boolean |
isChanged()
Indicates if a given block has changed.
|
boolean |
isValid()
A valid block has node (
hasNode) or plugin (
hasPlugin). |
IBlock |
newBlock(nu.xom.Node node,
IPlugin plugin)
Creates a new block.
|
IBlock |
newBlock(nu.xom.Node node,
IPlugin plugin,
Map<String,Object> map)
Create a new block.
|
IBlock |
pop() |
void |
push(IBlock e) |
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 local,
Object obj)
Save the value to the current context peek, no matter what type of node
it is.
|
void |
setChanged(boolean changed)
Sets the changed status.
|
void |
setMap(Map<String,Object> map)
Sets the block mapping of object.
|
void |
setNode(nu.xom.Node node)
Change block node.
|
void |
setPlugin(IPlugin plugin)
Sets the block plugin.
|
void |
setRunner(IRunner runner)
Sets the runner.
|
void |
setSources(Deque<ISource> sources)
Sets the sources.
|
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArrayiteratorequals, hashCode, listIterator, removeRange, subListcontainsAll, isEmpty, removeAll, retainAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitadd, addFirst, addLast, contains, descendingIterator, element, getFirst, getLast, iterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, sizeaddAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArraycontainsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subListprotected static final int PARENT
protected static final int CURRENT
protected IChannel channel
protected IRunner runner
public ContextImpl(ISource source, IRunner runner) throws ContextException
source - The source.runner - The runner.ContextException - On creation errors.public void push(IBlock e)
public IBlock pop()
public Deque<ISource> getSources()
IContextgetSources in interface IContextpublic ISource getCurrentSource()
IContextgetCurrentSource in interface IContextpublic void setSources(Deque<ISource> sources)
sources - The sources.public IRunner getRunner()
IContextpublic void setRunner(IRunner runner)
runner - The runner.public void saveGlobal(String global, Object obj)
IContextsaveGlobal in interface IContextglobal - The variable name.obj - The value.public void clearGlobal(String global)
IContextclearGlobal in interface IContextglobal - The variable name.public void saveLocal(String local, Object obj)
IContextpublic void clearLocal(String local)
IContextclearLocal in interface IContextlocal - The variable name.public void saveStrict(String local, Object obj)
IContextsaveStrict in interface IContextlocal - The name.obj - The value.public void clearStrict(String name)
IContextclearStrict in interface IContextname - The name.public void saveScoped(String scope, String local, Object obj)
IContextsaveScoped in interface IContextscope - 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.public void clearScoped(String scope, String local)
IContextclearScoped in interface IContextscope - The scope to unbound.local - The variable name.public IBlock getByElement(Class<? extends nu.xom.Node> type)
IContextgetByElement in interface IContexttype - The type.public IBlock getParentByElement(Class<? extends nu.xom.Node> type)
IContextgetParentByElement in interface IContexttype - The type.protected IBlock findNode(int start, Class<? extends nu.xom.Node> type)
start - The start index.type - The type.public IBlock getByPlugin(Class<? extends IPlugin> type)
IContextgetByPlugin in interface IContexttype - The type.public IBlock getParentByPlugin(Class<? extends IPlugin> type)
IContextgetParentByPlugin in interface IContexttype - The type.protected IBlock findPlugin(int start, Class<? extends IPlugin> type)
start - The start index.type - The type.public boolean hasName(String name)
IContextpublic Object getByName(String name)
IContextpublic Object getParentByName(String name)
IContextgetParentByName in interface IContextname - The name.protected Object findName(int start, String name)
start - The start index.name - The object name.public Map<String,Object> getObjects()
IContextgetObjects in interface IContextpublic boolean isValid()
IBlockhasNode) or plugin (
hasPlugin). They cannot be both 'null'.public boolean hasChildren()
IBlockhasChildren in interface IBlockpublic boolean isChanged()
IBlockpublic void setChanged(boolean changed)
IBlocksetChanged in interface IBlockchanged - The new status.public boolean hasNode()
IBlockpublic nu.xom.Node getNode()
IBlockpublic void setNode(nu.xom.Node node)
IBlockpublic boolean hasPlugin()
IBlockpublic IPlugin getPlugin()
IBlockpublic void setPlugin(IPlugin plugin)
IBlockpublic boolean hasMap()
IBlockpublic Map<String,Object> getMap()
IBlockpublic void setMap(Map<String,Object> map)
IBlockpublic IBlock newBlock(nu.xom.Node node, IPlugin plugin)
IBlockFactorynewBlock in interface IBlockFactorynode - A node.plugin - A plugin.public IBlock newBlock(nu.xom.Node node, IPlugin plugin, Map<String,Object> map)
IBlockFactorynewBlock in interface IBlockFactorynode - A node.plugin - A plugin.map - An object mapping.public void addMetadata()
IContextaddMetadata in interface IContextCopyright © 2016. All rights reserved.