public class PipeBindings extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
PipeBindings.JsDate
interface mapping a javascript date
|
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
CONDITIONAL_STRING |
protected static String |
IF_PREFIX |
static String |
NAME_BINDING
add ${name.pipeName} binding allowing to retrieve pipeName's current resource name
|
static String |
NASHORNSCRIPTENGINE |
static String |
NN_ADDITIONALBINDINGS |
static String |
NN_PROVIDERS |
static String |
PATH_BINDING
add ${path.pipeName} binding allowing to retrieve pipeName's current resource path
|
static String |
PN_ADDITIONALSCRIPTS |
Constructor and Description |
---|
PipeBindings(org.apache.sling.api.resource.Resource resource)
public constructor, built from pipe's resource
|
Modifier and Type | Method and Description |
---|---|
void |
addBinding(String name,
Object value)
add a binding
|
void |
addBindings(Map bindings)
adds additional bindings (global variables to use in child pipes expressions)
|
void |
addScript(org.apache.sling.api.resource.ResourceResolver resolver,
String path)
add a script file to the engine
|
protected String |
computeECMA5Expression(String expr)
Doesn't look like nashorn likes template strings :-(
|
String |
conditionalString(String conditionalExpression)
Return expression, instantiated expression or null if the expression is conditional and evaluation is falsy
|
void |
copyBindings(PipeBindings original)
copy bindings
|
protected Object |
evaluate(String expr)
evaluate a given expression
|
Bindings |
getBindings()
return registered bindings
|
org.apache.sling.api.resource.Resource |
getExecutedResource(String name)
return Pipe
name 's output binding |
String |
instantiateExpression(String expr)
Expression is a function of variables from execution context, that
we implement here as a String
|
Object |
instantiateObject(String expr)
Instantiate object from expression
|
boolean |
isBindingDefined(String name)
check if a given bindings is defined or not
|
boolean |
isPlainString(String expr) |
String |
popCurrentError() |
void |
setCurrentError(String currentError) |
void |
updateBindings(Pipe pipe,
org.apache.sling.api.resource.Resource resource)
Update current resource of a given pipe, and appropriate binding
|
void |
updateStaticBindings(String name,
org.apache.sling.api.resource.Resource resource)
Update all the static bindings related to a given resource
|
public static final String NASHORNSCRIPTENGINE
public static final String NN_ADDITIONALBINDINGS
public static final String PN_ADDITIONALSCRIPTS
public static final String NN_PROVIDERS
public static final String PATH_BINDING
public static final String NAME_BINDING
protected static final String IF_PREFIX
protected static final Pattern CONDITIONAL_STRING
public PipeBindings(org.apache.sling.api.resource.Resource resource) throws ScriptException
resource
- pipe's configuration resourceScriptException
- in case scripts associated with the bindings are not assessablepublic void addBinding(String name, Object value)
name
- binding's namevalue
- binding's valuepublic void addBindings(Map bindings)
bindings
- key/values bindings to add to the existing bindingspublic void addScript(org.apache.sling.api.resource.ResourceResolver resolver, String path)
resolver
- resolver with which the file should be readpath
- path of the script filepublic boolean isPlainString(String expr)
expr
- expression with or without ${} useprotected String computeECMA5Expression(String expr)
expr
- ECMA like expression blah${'some' + 'ecma' + 'expression'}
public void copyBindings(PipeBindings original)
original
- original bindings to copyprotected Object evaluate(String expr) throws ScriptException
expr
- ecma like expressionScriptException
- in case the script fails, an exception is thrown (to let call code the opportunity to stop the execution)public Bindings getBindings()
public org.apache.sling.api.resource.Resource getExecutedResource(String name)
name
's output bindingname
- name of the pipepublic String conditionalString(String conditionalExpression) throws ScriptException
conditionalExpression
- can be static, or dynamic, can be conditional in which case it must be of following
format $if${condition}someString
. someString will be returned if condition is true, otherwise nullScriptException
- in case one of the evaluation went wrongpublic String instantiateExpression(String expr) throws ScriptException
expr
- ecma like expressionScriptException
- in case expression computing went wrongpublic Object instantiateObject(String expr) throws ScriptException
expr
- ecma expressionScriptException
- in case object computing went wrongpublic boolean isBindingDefined(String name)
name
- name of the bindingname
is registeredpublic void updateBindings(Pipe pipe, org.apache.sling.api.resource.Resource resource)
pipe
- pipe we'll extract the output binding fromresource
- current resource in the pipe executionpublic void updateStaticBindings(String name, org.apache.sling.api.resource.Resource resource)
name
- name under which static bindings should be recordedresource
- resource from which static bindings will be builtpublic String popCurrentError()
public void setCurrentError(String currentError)
currentError
- error path to setCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.