public class TransformContext extends Object
Besides general properties, the context contains information about the data being transformed; e.g. the URI of the page or component and derived from that the publication id.
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_TAG_POSTPROCESSORS
Tag post-processors parameter.
|
static String |
PARAM_USER
User parameter.
|
static String |
PARAM_WEB_CONTEXT
Web context parameter.
|
Modifier | Constructor and Description |
---|---|
protected |
TransformContext(String codeBlockStartMarker,
String codeBlockEndMarker)
Creates a transform context using the given markers for inline code blocks.
|
protected |
TransformContext(String codeBlockStartMarker,
String codeBlockEndMarker,
Map configurationProperties,
Map<String,String> renderParameters)
Creates a transform context using the given markers for inline code blocks and with the internal
properties set from the [configurationProperties].
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String name)
Checks if a certain property is available.
|
Object |
get(String name,
Object defaultValue)
Deprecated.
As of 2013 SP1 release, replaced by
getProperty(K, V) |
boolean |
getBoolean(String name,
boolean defaultValue)
Deprecated.
As of 2013 SP1 release, replaced by
getProperty(K, V) |
String |
getCodeBlockEndMarker()
Returns the configured marker to use to end a code block e.g.
|
String |
getCodeBlockStartMarker()
Returns the configured marker to use to start a code block e.g.
|
TransformContext |
getEnclosingContext()
Returns
TransformContext of the enclosing Tag . |
TransformContext |
getGlobalContext()
Returns the global
TransformContext . |
Optional<GlobalExecutionArguments> |
getGlobalExecutionArguments()
Get execution arguments from the context object.
|
int |
getInt(String name,
int defaultValue)
Deprecated.
As of 2013 SP1 release, replaced by
getProperty(K, V) |
String |
getItemURI()
Returns the itemURI that was set earlier or null if none was set.
|
<K,T,V extends T> |
getProperty(K name,
V defaultValue)
Returns value of the property from the contexts available.
|
int |
getPublicationId()
Returns the publication id that was derived from the itemURI or -1 if no valid itemURI was set.
|
TCMURI |
getPublicationURI()
Returns the publication URI derived from the itemURI or null if no valid itemURI was set.
|
Map<String,String> |
getRenderParameters() |
String |
getString(String name,
String defaultValue)
Deprecated.
As of 2013 SP1 release, replaced by
getProperty(K, V) |
boolean |
isRootContext()
Returns True if this is a Root Context.
|
boolean |
isTagBodyCodeBlock()
Returns true if resulting body from the current tag will be wrapped in an inline code block
Note that this method should rarely be required for implementers of TagHandlers, all code block marking
is handled by the engine.
|
static TransformContext |
nullContext()
Returns an instance of null TransformContext.
|
void |
remove(String name)
Removes property with name as key.
|
void |
set(String name,
Object value)
Deprecated.
As of 2013 SP1 release, replaced by
setGlobalProperty(K, V) |
void |
setBoolean(String name,
boolean value)
Deprecated.
As of 2013 SP1 release, replaced by
setGlobalProperty(K, V) |
void |
setGlobalExecutionArguments(GlobalExecutionArguments globalExecutionArguments) |
<K,V> void |
setGlobalProperty(K name,
V value)
Sets property on the global
TransformContext . |
void |
setInt(String name,
int value)
Deprecated.
As of 2013 SP1 release, replaced by
setGlobalProperty(K, V) |
void |
setItemURI(String itemURI)
Sets the Item URI of the item that is being transformed.
|
<K,V> void |
setProperty(K name,
V value)
Sets property on the currently active
TransformContext . |
void |
setString(String name,
String value)
Deprecated.
As of 2013 SP1 release, replaced by
setGlobalProperty(K, V) |
protected void |
setTagBodyIsCodeBlock(boolean inside)
The framework maintains whether the current tag body will be wrapped in a code block.
|
public static final String PARAM_USER
public static final String PARAM_TAG_POSTPROCESSORS
public static final String PARAM_WEB_CONTEXT
protected TransformContext(String codeBlockStartMarker, String codeBlockEndMarker, Map configurationProperties, Map<String,String> renderParameters)
codeBlockStartMarker
- marker to start an inline code blockcodeBlockEndMarker
- marker to end an inline code blockconfigurationProperties
- properties to inheritrenderParameters
- The rendering parameters to be used during rendering of contentprotected TransformContext(String codeBlockStartMarker, String codeBlockEndMarker)
codeBlockStartMarker
- marker to start an inline code blockcodeBlockEndMarker
- marker to end an inline code blockpublic Optional<GlobalExecutionArguments> getGlobalExecutionArguments()
public void setGlobalExecutionArguments(GlobalExecutionArguments globalExecutionArguments)
public static TransformContext nullContext()
public TransformContext getEnclosingContext()
TransformContext
of the enclosing Tag
.
If there is no enclosing Tag, it returns an instance of NullTransformContext
.public String getCodeBlockStartMarker()
public String getCodeBlockEndMarker()
protected void setTagBodyIsCodeBlock(boolean inside)
inside
- true when the current tag will be wrapped in a code blockpublic boolean isTagBodyCodeBlock()
public String getItemURI()
public void setItemURI(String itemURI)
itemURI
- URI for this transformationpublic int getPublicationId()
public TCMURI getPublicationURI()
public boolean contains(String name)
name
- name of the property to check fortrue
if it contains a key with this name, false
otherwise.public void remove(String name)
name
- the property to removepublic <K,T,V extends T> T getProperty(K name, V defaultValue)
First of all, it performs a lookup in the active local context. If not found, it incrementally searches enclosing contexts till it reaches root context. In effect, it performs lookup in all the available enclosing contexts (including global context). If the property is not set in any context, then defaultValueis returned
K
- type of name of the propertyT
- type of value of the property.V
- type of default value of the property. It can be subtype of the actual value stored.name
- name of the propertydefaultValue
- default value to return when the property is not foundpublic <K,V> void setGlobalProperty(K name, V value)
TransformContext
. Please note that for the
transformation of a complete document, a globalTransformContext gets
created, which stores state applicable for the entire transformation.K
- type of key of the propertyV
- type of value of the propertyname
- name of the propertyvalue
- value of the propertypublic <K,V> void setProperty(K name, V value)
TransformContext
. TransformContext
supports scoping, which in essence creates a local context for each Tag. setProperty
gets the currently active scope/context and saves property. On the other hand, setGlobalProperty(K, V)
saves property in the global context.K
- type of key of the propertyV
- type of value of the propertyname
- name of the propertyvalue
- value of the propertypublic boolean isRootContext()
public TransformContext getGlobalContext()
TransformContext
.@Deprecated public void setString(String name, String value)
setGlobalProperty(K, V)
name
- property to retrievevalue
- value for the property@Deprecated public void setInt(String name, int value)
setGlobalProperty(K, V)
TransformContext
to set property value.name
- property to retrievevalue
- value for the property@Deprecated public int getInt(String name, int defaultValue)
getProperty(K, V)
name
- property to retrievedefaultValue
- value to return when the property is not set@Deprecated public void set(String name, Object value)
setGlobalProperty(K, V)
TransformContext
to set property value.name
- property to retrievevalue
- value for the property@Deprecated public void setBoolean(String name, boolean value)
setGlobalProperty(K, V)
TransformContext
to set property value.name
- property to retrievevalue
- value for the property@Deprecated public boolean getBoolean(String name, boolean defaultValue)
getProperty(K, V)
name
- property to retrievedefaultValue
- value to return when the property is not set@Deprecated public Object get(String name, Object defaultValue)
getProperty(K, V)
name
- property to retrievedefaultValue
- value to return when the property is not set@Deprecated public String getString(String name, String defaultValue)
getProperty(K, V)
name
- property to retrievedefaultValue
- value to return when the property is not setCopyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries