Package de.espirit.firstspirit.access
Interface GenerationContext
- All Superinterfaces:
AutoCloseable
,BaseContext
,Closeable
,Evaluator
,GenerationScriptContext
,ProjectScriptContext
,ScriptContext
,SpecialistsBroker
Context definition for generation tasks.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.espirit.firstspirit.access.BaseContext
BaseContext.Env
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
With this variable name one can get an instance of this class from a template:
GenerationContext gc = (GenerationContext)
Evaluator.getVariableValue(String)
evaluator.getVariableValue(GenerationContext.CONTEXT_VARIABLE_NAME);Fields inherited from interface de.espirit.firstspirit.access.template.Evaluator
CLASSLOADER_VARIABLE, GLOBAL_VARIABLE, MATH_CONTEXT_VARIABLE, RESOLUTION_TAGS_VARIABLE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseable
(Closeable closeable) Add aCloseable
to the generation contextvoid
addDataToContext
(DataProvider provider) Add aDataProvider
to the generation contextvoid
close()
Close all registered closeables.Provides the base path for this generation.getCharacterReplacer
(boolean quote) Get a character replacer instance for replacing special characters in the content that will be generated@Nullable Context
getContext
(String name) Return aContext
by given name.@Nullable Dataset
Returns the firstDataset
if this page is a content page, otherwisenull
.boolean
If debug mode is switched on java stack traces are included in the template log.boolean
Return if the target directory should be deleted before the generationGet file encoding.The current evaluator.@Nullable FileHandle
getFileHandle
(String path) Reurn aFileHandle
for the given pathReturn aFont
for the given namegetJson()
Retrieves the json settings for this generation context.Returns the currentLanguage
of this generation context@NotNull Page
getLanguageSpecificPage
(@NotNull Page page) Get thePage
for the current language@Nullable IDProvider
Returns the origin node for relative urls.getNode()
Provides the currently processed node, e.g., aPageRef
.getPage()
Return the currentPage
that is used in the generation context@Nullable Context
Return the page context if set.int
Provides the actual page index in case of multi-pages.@NotNull PageParams
Get the page params of the page which is generated.@Nullable ScheduleContext
Get the actual schedule context - this is only set when the generate process is initiated from the scheduler.@NotNull Date
Start time of generate process.Get the current template set that is used in the generation contextThe actual evaluated expression as string - for debugging.The currently used url creator instance.Return the currentUrlCreatorProvider
that is used in the generation contextboolean
If a page is nottranslated
, theproject master language
is used for data mapping.Returns theUserService
belonging to the generation contextboolean
Returns whether or not the editor identifier should be generated regardless of the current environment.boolean
Returns whether or not the context is currently generating html code (default istrue
).boolean
Is the actual generation is a preview generation?boolean
Returns whether or not rules should be evaluated for the editor identifiers.boolean
Indicates whether this generation context is based on a release version.void
mediaReferenced
(@NotNull Media media, @Nullable Language language, @Nullable 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
Set the page that is to be used in the generation contextvoid
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
Deprecated, for removal: This API element is subject to removal in a future version.since 5.0.101 - no replacement.Methods inherited from interface de.espirit.firstspirit.access.BaseContext
is
Methods inherited from interface de.espirit.firstspirit.access.template.Evaluator
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
Methods inherited from interface de.espirit.firstspirit.access.GenerationScriptContext
getGenerationContext, toString
Methods inherited from interface de.espirit.firstspirit.access.project.ProjectScriptContext
getProject
Methods inherited from interface de.espirit.firstspirit.access.ScriptContext
getConnection, getProperties, getProperty, logDebug, logError, logError, logInfo, logWarning, removeProperty, setProperty
Methods inherited from interface de.espirit.firstspirit.agency.SpecialistsBroker
requestSpecialist, requireSpecialist
-
Field Details
-
CONTEXT_VARIABLE_NAME
With this variable name one can get an instance of this class from a template:
GenerationContext gc = (GenerationContext)
Evaluator.getVariableValue(String)
evaluator.getVariableValue(GenerationContext.CONTEXT_VARIABLE_NAME);- Since:
- 4.0.17
- See Also:
-
-
Method Details
-
getUserService
UserService getUserService()Returns theUserService
belonging to the generation context- Specified by:
getUserService
in interfaceProjectScriptContext
- Returns:
- An user service instance
- Since:
- 4.1.27
-
getUrlCreator
UrlCreator getUrlCreator()The currently used url creator instance. Before FirstSpirit 5.0.3 this method returned an instance ofUrlCreator
.- Returns:
- An instance of
UrlCreator
that is currently used - Since:
- 4.0.17
-
getUrlCreatorProvider
UrlCreatorProvider getUrlCreatorProvider()Return the currentUrlCreatorProvider
that is used in the generation context- Returns:
- The
UrlCreatorProvider
that is currently used - Since:
- 4.1.27
-
isRelease
boolean isRelease()Indicates whether this generation context is based on a release version. All stores of the belonging userservice will be loaded using this flag to get the release or the current version.- Specified by:
isRelease
in interfaceGenerationScriptContext
- Returns:
true
this context is based on a release version- Since:
- 4.0.17
-
getLanguage
Language getLanguage()Returns the currentLanguage
of this generation context- Specified by:
getLanguage
in interfaceGenerationScriptContext
- Returns:
- The current
Language
- Since:
- 4.0.17
-
getUseMasterLanguageForData
boolean getUseMasterLanguageForData()If a page is nottranslated
, theproject master language
is used for data mapping.- Returns:
- If the master language is used for the data mapping
- Since:
- 4.0.96
-
setUseMasterLanguageForData
void setUseMasterLanguageForData(boolean value) Set if the master language should be used for the data mapping for not translated pages.- Parameters:
value
- Whether to use the master languagetrue
or use the current languagefalse
- Since:
- 4.0.96
- See Also:
-
getTemplateSet
TemplateSet getTemplateSet()Get the current template set that is used in the generation context- Specified by:
getTemplateSet
in interfaceGenerationScriptContext
- Returns:
- The current
TemplateSet
that is used in the generation context - Since:
- 4.0.17
-
getNode
ContentProducer getNode()Provides the currently processed node, e.g., aPageRef
.- Returns:
- The node.
- Since:
- 4.0.17
-
getPageIndex
@ApiDoc(comment="The actual page index (for multi-pages e.g. for content-store based pages)", since="4.0.0") int getPageIndex()Provides the actual page index in case of multi-pages.- Returns:
- The page index.
- Since:
- 4.0.17
-
isPreview
boolean isPreview()Is the actual generation is a preview generation?- Specified by:
isPreview
in interfaceGenerationScriptContext
- Returns:
true
if this is a preview generation- Since:
- 4.0.17
-
getEvaluator
Evaluator getEvaluator()The current evaluator.- Returns:
- An
Evaluator
instance - Since:
- 4.0.17
-
getCharacterReplacer
Get a character replacer instance for replacing special characters in the content that will be generated- Parameters:
quote
-true
if theCharacterReplacer
should replace quotes- Returns:
- A
CharacterReplacer
instance - Since:
- 4.0.17
-
addDataToContext
Add aDataProvider
to the generation context- Parameters:
provider
- The data providingelement
.- Since:
- 4.0.120
-
getPage
Page getPage()Return the currentPage
that is used in the generation context- Returns:
- The currently used
Page
- Since:
- 4.0.17
-
setPage
Set the page that is to be used in the generation context- Parameters:
value
- ThePage
that should be used in the generation context- Since:
- 4.0.17
-
getEncoding
@ApiDoc(comment="get file encoding (shortcut for \"getLanguage().getEncoding()\"), returns e.g. \"UTF-8\"", since="4.0") String getEncoding()Get file encoding. Shortcut forgetLanguage()
.Language.getHTMLEncoding()
, returns e.g. "UTF-8".- Returns:
- The name of the encoding
- Since:
- 4.0.17
-
getFont
Return aFont
for the given name -
getTopStackElement
String getTopStackElement()The actual evaluated expression as string - for debugging.- Specified by:
getTopStackElement
in interfaceEvaluator
- Returns:
- The evaluated expression
- Since:
- 4.0.17
-
getPageContext
@Nullable @ApiDoc(comment="get the page context (if set)", since="4.0") @Nullable Context getPageContext()Return the page context if set. Can benull
- Returns:
- The
Context
of the page. Can benull
- Since:
- 4.0.17
-
getContext
@Nullable @ApiDoc(comment="get a context by its name (e.g. \"PAGE\", \"SECTION\")", since="4.0") @Nullable Context getContext(String name) Return aContext
by given name. Can returnnull
- Parameters:
name
- The name of theContext
that should be returned. Can benull
- Since:
- 4.0.17
-
getDeleteDirectory
boolean getDeleteDirectory()Return if the target directory should be deleted before the generation- Returns:
true
if directory should be deleted before generation,false
otherwise- Since:
- 4.0.52
-
addCloseable
Add aCloseable
to the generation context- Since:
- 4.0.52
-
close
Close all registered closeables.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- on error- Since:
- 4.0.52
-
getBasePath
String getBasePath()Provides the base path for this generation.- Returns:
- The base path.
- Since:
- 4.0.52
-
setDebugMode
@ApiDoc(comment="toggle debug mode - if switched on, error logging is more verbose", since="4.0.0") void setDebugMode(boolean value) If debug mode is switched on java stack traces are included in the template log.- Parameters:
value
- toggle debug mode - if switched on, error logging is more verbose- Since:
- 4.0.52
- See Also:
-
getDebugMode
@ApiDoc(comment="get debug mode - if switched on, error logging is more verbose", since="4.0.0") boolean getDebugMode()If debug mode is switched on java stack traces are included in the template log.- Since:
- 4.0.52
- See Also:
-
setHtmlMode
@ApiDoc(comment="toggle html mode - if switched off, template inspection will be disabled", since="5.1.304") void setHtmlMode(boolean value) Tells the generation context whether or not html code will be generated currently. This value will be used in combination withTemplateSet.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 likeout.println("<img ...");
.- Parameters:
value
- no html- Since:
- 5.1.304
-
isHtmlMode
@ApiDoc(comment="get html mode - if switched off, template inspection will be disabled", since="5.1.304") boolean isHtmlMode()Returns whether or not the context is currently generating html code (default istrue
). This value will be used in combination withTemplateSet.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 likeout.println("<img ...");
.- Returns:
- no html
- Since:
- 5.1.304
-
setForceEditorIds
@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) Tells the generation context whether or not the editor identifier should be generated regardless of the current environment. This value will be used in combination withisPreview()
to determine if the editor identifier should be generated or not.- Parameters:
value
- forced editorId generation- Since:
- 5.2.13
-
isForceEditorIds
@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()Returns whether or not the editor identifier should be generated regardless of the current environment. This value will be used in combination withisPreview()
to determine if the editor identifier should be generated or not.- Returns:
- forced editorId generation
- Since:
- 5.2.13
-
setPreviewRulesEvaluation
@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) Tells the generation context whether or not rules should be evaluated for the editor identifiers. This value might be used inBaseContext.Env.WEBEDIT
environments, for visualization ofFormData
validation problems in the preview. Modifying this setting may be useful in some cases for performance reasons.- Parameters:
value
-true
for enabled rules evaluation,false
otherwise.- Since:
- 5.2.180905
-
isPreviewRulesEvaluation
@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()Returns whether or not rules should be evaluated for the editor identifiers. This value might be used inBaseContext.Env.WEBEDIT
environments, for visualization ofFormData
validation problems in the preview.- Returns:
true
for enabled rules evaluation,false
otherwise.- Since:
- 5.2.180905
-
mediaReferenced
void mediaReferenced(@NotNull @NotNull Media media, @Nullable @Nullable Language language, @Nullable @Nullable Resolution resolution) throws IOException Prints a referenced media to the generation target, if it was not yet printed.- Parameters:
media
- The medium referenced.language
- The desired language of the medium.resolution
- The desired resolution of the medium.- Throws:
IOException
- Since:
- 4.0.120
-
getFileHandle
Reurn aFileHandle
for the given path- Parameters:
path
- The path for theFileHandle
that should be returned- Returns:
- The
FileHandle
for the given path - Throws:
IOException
- Since:
- 4.0.120
-
getLanguageSpecificPage
Get thePage
for the current language -
getStartTime
@ApiDoc(comment="start time of generate process", since="4.1") @NotNull @NotNull Date getStartTime()Start time of generate process.- Returns:
- The
Date
object for the start time of the generation process - Since:
- 4.0.126
-
showWebeditButtons
Deprecated, for removal: This API element is subject to removal in a future version.since 5.0.101 - no replacement.In FirstSpirit 4 this method returns whether the preview inline edit buttons should be visible. In WebEdit 5 there is no mode to switch between visible and invisible inline edit buttons.- Returns:
- always
false
. - Since:
- 4.2.200
-
getScheduleContext
@ApiDoc(comment="Get the actual schedule context - delivers \'null\' in preview", since="4.1.42") @Nullable @Nullable ScheduleContext getScheduleContext()Get the actual schedule context - this is only set when the generate process is initiated from the scheduler.- Returns:
- the actual
schedule context
ornull
during preview - Since:
- 4.2.42
-
getPageParams
@ApiDoc(comment="Get the page params of the page which is generated", since="5.0.3") @NotNull @NotNull PageParams getPageParams()Get the page params of the page which is generated.- Returns:
- The page params of the page which is generated.
- Since:
- 5.0.3
-
getDataset
@ApiDoc(comment="Get the first dataset if this page is a content page", since="5.0.11") @Nullable @Nullable Dataset getDataset()Returns the firstDataset
if this page is a content page, otherwisenull
.- Returns:
- First
Dataset
ornull
. - Since:
- 5.0.11
-
getJson
@ApiDoc(comment="Retrieve the json settings for this generation context.", since="5.2.190507") JsonSettings getJson()Retrieves the json settings for this generation context.- Returns:
- the json settings.
- Since:
- 5.2.190507
-