public interface GenerationContext extends GenerationScriptContext, Evaluator
BaseContext.Env
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT_VARIABLE_NAME
With this variable name one can get an instance of this class from a template:
GenerationContext gc = (GenerationContext) |
CLASSLOADER_VARIABLE, GLOBAL_VARIABLE, MATH_CONTEXT_VARIABLE
Modifier and Type | Method and Description |
---|---|
void |
addCloseable(Closeable closeable)
Add a
Closeable to the generation context |
void |
addDataToContext(DataProvider provider)
Add a
DataProvider to the generation context |
void |
close()
Close all registered closeables.
|
String |
getBasePath()
Provides the base path for this generation.
|
CharacterReplacer |
getCharacterReplacer(boolean quote)
Get a character replacer instance for replacing special characters in the content that will be generated
|
Context |
getContext(String name)
Return a
Context by given name. |
Dataset |
getDataset()
Returns the first
Dataset if this page is a content page, otherwise null . |
boolean |
getDebugMode()
If debug mode is switched on java stack traces are included in the template log.
|
boolean |
getDeleteDirectory()
Return if the target directory should be deleted before the generation
|
String |
getEncoding()
Get file encoding.
|
Evaluator |
getEvaluator()
The current evaluator.
|
FileHandle |
getFileHandle(String path)
Reurn a
FileHandle for the given path |
Font |
getFont(String name)
Return a
Font for the given name |
JsonSettings |
getJson()
Retrieves the json settings for this generation context.
|
Language |
getLanguage()
Returns the current
Language of this generation context |
Page |
getLanguageSpecificPage(Page page)
Get the
Page for the current language |
IDProvider |
getNavigationContext()
Returns the origin node for relative urls.
|
ContentProducer |
getNode()
Provides the currently processed node, e.g., a
PageRef . |
Page |
getPage()
Return the current
Page that is used in the generation context |
Context |
getPageContext()
Return the page context if set.
|
int |
getPageIndex()
Provides the actual page index in case of multi-pages.
|
PageParams |
getPageParams()
Get the page params of the page which is generated.
|
ScheduleContext |
getScheduleContext()
Get the actual schedule context - this is only set when the generate process is initiated from the scheduler.
|
Date |
getStartTime()
Start time of generate process.
|
TemplateSet |
getTemplateSet()
Get the current template set that is used in the generation context
|
String |
getTopStackElement()
The actual evaluated expression as string - for debugging.
|
UrlCreator |
getUrlCreator()
The currently used url creator instance.
|
UrlCreatorProvider |
getUrlCreatorProvider()
Return the current
UrlCreatorProvider that is used in the generation context |
boolean |
getUseMasterLanguageForData()
If a page is not
translated ,
the project master language is used
for data mapping. |
UserService |
getUserService()
Returns the
UserService belonging to the generation context |
boolean |
isForceEditorIds()
Returns whether or not the editor identifier should be generated regardless of the current environment.
|
boolean |
isHtmlMode()
Returns whether or not the context is currently generating html code (default is
true ). |
boolean |
isPreview()
Is the actual generation is a preview generation?
|
boolean |
isPreviewRulesEvaluation()
Returns whether or not rules should be evaluated for the editor identifiers.
|
boolean |
isRelease()
Indicates whether this generation context is based on a release version.
|
void |
mediaReferenced(Media media,
Language language,
Resolution resolution)
Prints a referenced media to the generation target, if it was not yet printed.
|
void |
setDebugMode(boolean value)
If debug mode is switched on java stack traces are included in the template log.
|
void |
setForceEditorIds(boolean value)
Tells the generation context whether or not the editor identifier should be generated regardless
of the current environment.
|
void |
setHtmlMode(boolean value)
Tells the generation context whether or not html code will be generated currently.
|
void |
setPage(Page value)
Set the page that is to be used in the generation context
|
void |
setPreviewRulesEvaluation(boolean value)
Tells the generation context whether or not rules should be evaluated for the editor identifiers.
|
void |
setUseMasterLanguageForData(boolean value)
Set if the master language should be used for the data mapping for not translated pages.
|
boolean |
showWebeditButtons()
Deprecated.
since 5.0.101 - no replacement.
|
getGenerationContext, toString
getProject
getConnection, getProperties, getProperty, logDebug, logError, logError, logInfo, logWarning, removeProperty, setProperty
is
requestSpecialist, requireSpecialist
getAttribute, getContext, getDefaultExpression, getLocale, getLocaleKey, getOut, getStack, getTemplate, getVariableValue, include, invokeMethod, isDebugging, logDebug, logError, logError, logError, logError, logInfo, logWarning, parse, parse, popContext, print, print, pushContext, pushContext, pushContext, pushContext, resolveReference, setDefaultExpression, setErrorOut, setErrorOut, setLocale, setLocaleKey, setMaxStackSize, setOut, setVariableValue
static final String CONTEXT_VARIABLE_NAME
GenerationContext gc = (GenerationContext) Evaluator.getVariableValue(String)
evaluator.getVariableValue(GenerationContext.CONTEXT_VARIABLE_NAME);
UserService getUserService()
UserService
belonging to the generation contextgetUserService
in interface ProjectScriptContext
UrlCreator getUrlCreator()
UrlCreator
.UrlCreator
that is currently usedUrlCreatorProvider getUrlCreatorProvider()
UrlCreatorProvider
that is used in the generation contextUrlCreatorProvider
that is currently usedboolean isRelease()
isRelease
in interface GenerationScriptContext
true
this context is based on a release versionLanguage getLanguage()
Language
of this generation contextgetLanguage
in interface GenerationScriptContext
Language
boolean getUseMasterLanguageForData()
translated
,
the project master language
is used
for data mapping.void setUseMasterLanguageForData(boolean value)
value
- Whether to use the master language true
or use the current language false
getUseMasterLanguageForData()
TemplateSet getTemplateSet()
getTemplateSet
in interface GenerationScriptContext
TemplateSet
that is used in the generation contextContentProducer getNode()
PageRef
.@Nullable IDProvider getNavigationContext()
getNode()
, but this
may also be a Media
for references from a
parsed media
.@ApiDoc(comment="The actual page index (for multi-pages e.g. for content-store based pages)", since="4.0.0") int getPageIndex()
boolean isPreview()
isPreview
in interface GenerationScriptContext
true
if this is a preview generationEvaluator getEvaluator()
Evaluator
instanceCharacterReplacer getCharacterReplacer(boolean quote)
quote
- true
if the CharacterReplacer
should replace quotesCharacterReplacer
instancevoid addDataToContext(DataProvider provider)
DataProvider
to the generation contextprovider
- The data providing element
.Page getPage()
Page
that is used in the generation contextPage
void setPage(Page value)
value
- The Page
that should be used in the generation context@ApiDoc(comment="get file encoding (shortcut for \"getLanguage().getEncoding()\"), returns e.g. \"UTF-8\"", since="4.0") String getEncoding()
getLanguage()
.
Language.getHTMLEncoding()
, returns e.g. "UTF-8".String getTopStackElement()
getTopStackElement
in interface Evaluator
@Nullable @ApiDoc(comment="get the page context (if set)", since="4.0") Context getPageContext()
null
Context
of the page. Can be null
@Nullable @ApiDoc(comment="get a context by its name (e.g. \"PAGE\", \"SECTION\")", since="4.0") Context getContext(String name)
Context
by given name. Can return null
name
- The name of the Context
that should be returned. Can be null
boolean getDeleteDirectory()
true
if directory should be deleted before generation, false
otherwisevoid addCloseable(Closeable closeable)
Closeable
to the generation contextvoid close() throws IOException
IOException
- on errorString getBasePath()
@ApiDoc(comment="toggle debug mode - if switched on, error logging is more verbose", since="4.0.0") void setDebugMode(boolean value)
value
- toggle debug mode - if switched on, error logging is more verbosegetDebugMode()
@ApiDoc(comment="get debug mode - if switched on, error logging is more verbose", since="4.0.0") boolean getDebugMode()
setDebugMode(boolean)
@ApiDoc(comment="toggle html mode - if switched off, template inspection will be disabled", since="5.1.304") void setHtmlMode(boolean value)
TemplateSet.isTemplateInspectionEnabled()
,
to determine whether or not the generated html should be enhanced with template identifying
html attributes. It might be necessary to set this value for certain JSP or JavaScript fragments,
to avoid corrupt html on statements like out.println("<img ...");
.value
- no html@ApiDoc(comment="get html mode - if switched off, template inspection will be disabled", since="5.1.304") boolean isHtmlMode()
true
).
This value will be used in combination with TemplateSet.isTemplateInspectionEnabled()
,
to determine whether or not the generated html should be enhanced with template identifying
html attributes. It might be necessary to set this value for certain JSP or JavaScript fragments,
to avoid corrupt html on statements like out.println("<img ...");
.@ApiDoc(comment="toggle forced editorId generation - if switched off, the editorIds will only be generated in a preview environment", since="5.2.13") void setForceEditorIds(boolean value)
isPreview()
to
determine if the editor identifier should be generated or not.value
- forced editorId generation@ApiDoc(comment="get state of forced editorIds - if switched off, the editorIds will only be generated in a preview environment", since="5.2.13") boolean isForceEditorIds()
isPreview()
to determine if the editor identifier
should be generated or not.@ApiDoc(comment="toggle rules evaluation for editorIds - if switched off, the rules will not be evaluated for editorIds", since="5.2.180905") void setPreviewRulesEvaluation(boolean value)
Env#WEBEDIT
environments, for visualization of FormData
validation
problems in the preview. Modifying this setting may be useful in some cases for performance reasons.value
- true
for enabled rules evaluation, false
otherwise.@ApiDoc(comment="get state of rules evaluation for editorIds - if switched off, the rules will not be evaluated for editorIds", since="5.2.180905") boolean isPreviewRulesEvaluation()
Env#WEBEDIT
environments, for visualization of FormData
validation
problems in the preview.true
for enabled rules evaluation, false
otherwise.void mediaReferenced(@NotNull Media media, @Nullable Language language, @Nullable Resolution resolution) throws IOException
media
- The medium referenced.language
- The desired language of the medium.resolution
- The desired resolution of the medium.IOException
@Nullable FileHandle getFileHandle(String path) throws IOException
FileHandle
for the given pathpath
- The path for the FileHandle
that should be returnedFileHandle
for the given pathIOException
@NotNull Page getLanguageSpecificPage(@NotNull Page page)
Page
for the current language@ApiDoc(comment="start time of generate process", since="4.1") @NotNull Date getStartTime()
Date
object for the start time of the generation process@Deprecated boolean showWebeditButtons()
false
.@ApiDoc(comment="Get the actual schedule context - delivers \'null\' in preview", since="4.1.42") @Nullable ScheduleContext getScheduleContext()
schedule context
or null
during preview@ApiDoc(comment="Get the page params of the page which is generated", since="5.0.3") @NotNull PageParams getPageParams()
@ApiDoc(comment="Get the first dataset if this page is a content page", since="5.0.11") @Nullable Dataset getDataset()
Dataset
if this page is a content page, otherwise null
.Dataset
or null
.@ApiDoc(comment="Retrieve the json settings for this generation context.", since="5.2.190507") JsonSettings getJson()
Copyright © 2021 e-Spirit AG. All Rights Reserved. Build 5.2.210210