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
FieldsModifier and TypeFieldDescriptionstatic final StringWith 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 TypeMethodDescriptionvoidaddCloseable(Closeable closeable) Add aCloseableto the generation contextvoidaddDataToContext(DataProvider provider) Add aDataProviderto the generation contextvoidclose()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 ContextgetContext(String name) Return aContextby given name.@Nullable DatasetReturns the firstDatasetif this page is a content page, otherwisenull.booleanIf debug mode is switched on java stack traces are included in the template log.booleanReturn if the target directory should be deleted before the generationGet file encoding.The current evaluator.@Nullable FileHandlegetFileHandle(String path) Reurn aFileHandlefor the given pathReturn aFontfor the given namegetJson()Retrieves the json settings for this generation context.Returns the currentLanguageof this generation context@NotNull PagegetLanguageSpecificPage(@NotNull Page page) Get thePagefor the current language@Nullable IDProviderReturns the origin node for relative urls.getNode()Provides the currently processed node, e.g., aPageRef.getPage()Return the currentPagethat is used in the generation context@Nullable ContextReturn the page context if set.intProvides the actual page index in case of multi-pages.@NotNull PageParamsGet the page params of the page which is generated.@Nullable ScheduleContextGet the actual schedule context - this is only set when the generate process is initiated from the scheduler.@NotNull DateStart 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 currentUrlCreatorProviderthat is used in the generation contextbooleanIf a page is nottranslated, theproject master languageis used for data mapping.Returns theUserServicebelonging to the generation contextbooleanReturns whether or not the editor identifier should be generated regardless of the current environment.booleanReturns whether or not the context is currently generating html code (default istrue).booleanIs the actual generation is a preview generation?booleanReturns whether or not rules should be evaluated for the editor identifiers.booleanIndicates whether this generation context is based on a release version.voidmediaReferenced(@NotNull Media media, @Nullable Language language, @Nullable Resolution resolution) Prints a referenced media to the generation target, if it was not yet printed.voidsetDebugMode(boolean value) If debug mode is switched on java stack traces are included in the template log.voidsetForceEditorIds(boolean value) Tells the generation context whether or not the editor identifier should be generated regardless of the current environment.voidsetHtmlMode(boolean value) Tells the generation context whether or not html code will be generated currently.voidSet the page that is to be used in the generation contextvoidsetPreviewRulesEvaluation(boolean value) Tells the generation context whether or not rules should be evaluated for the editor identifiers.voidsetUseMasterLanguageForData(boolean value) Set if the master language should be used for the data mapping for not translated pages.Methods inherited from interface de.espirit.firstspirit.access.BaseContext
isMethods 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, setVariableValueMethods inherited from interface de.espirit.firstspirit.access.GenerationScriptContext
getGenerationContext, toStringMethods inherited from interface de.espirit.firstspirit.access.project.ProjectScriptContext
getProjectMethods inherited from interface de.espirit.firstspirit.access.ScriptContext
getConnection, getProperties, getProperty, logDebug, logError, logError, logInfo, logWarning, removeProperty, setPropertyMethods 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 theUserServicebelonging to the generation context- Specified by:
getUserServicein 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
UrlCreatorthat is currently used - Since:
- 4.0.17
-
getUrlCreatorProvider
UrlCreatorProvider getUrlCreatorProvider()Return the currentUrlCreatorProviderthat is used in the generation context- Returns:
- The
UrlCreatorProviderthat 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:
isReleasein interfaceGenerationScriptContext- Returns:
truethis context is based on a release version- Since:
- 4.0.17
-
getLanguage
Language getLanguage()Returns the currentLanguageof this generation context- Specified by:
getLanguagein interfaceGenerationScriptContext- Returns:
- The current
Language - Since:
- 4.0.17
-
getUseMasterLanguageForData
boolean getUseMasterLanguageForData()If a page is nottranslated, theproject master languageis 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 languagetrueor 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:
getTemplateSetin interfaceGenerationScriptContext- Returns:
- The current
TemplateSetthat 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:
isPreviewin interfaceGenerationScriptContext- Returns:
trueif this is a preview generation- Since:
- 4.0.17
-
getEvaluator
Evaluator getEvaluator()The current evaluator.- Returns:
- An
Evaluatorinstance - Since:
- 4.0.17
-
getCharacterReplacer
Get a character replacer instance for replacing special characters in the content that will be generated- Parameters:
quote-trueif theCharacterReplacershould replace quotes- Returns:
- A
CharacterReplacerinstance - Since:
- 4.0.17
-
addDataToContext
Add aDataProviderto the generation context- Parameters:
provider- The data providingelement.- Since:
- 4.0.120
-
getPage
Page getPage()Return the currentPagethat 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- ThePagethat 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 aFontfor the given name -
getTopStackElement
String getTopStackElement()The actual evaluated expression as string - for debugging.- Specified by:
getTopStackElementin 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
Contextof 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 aContextby given name. Can returnnull- Parameters:
name- The name of theContextthat should be returned. Can benull- Since:
- 4.0.17
-
getDeleteDirectory
boolean getDeleteDirectory()Return if the target directory should be deleted before the generation- Returns:
trueif directory should be deleted before generation,falseotherwise- Since:
- 4.0.52
-
addCloseable
Add aCloseableto the generation context- Since:
- 4.0.52
-
close
Close all registered closeables.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein 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.WEBEDITenvironments, for visualization ofFormDatavalidation problems in the preview. Modifying this setting may be useful in some cases for performance reasons.- Parameters:
value-truefor enabled rules evaluation,falseotherwise.- 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.WEBEDITenvironments, for visualization ofFormDatavalidation problems in the preview.- Returns:
truefor enabled rules evaluation,falseotherwise.- 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 aFileHandlefor the given path- Parameters:
path- The path for theFileHandlethat should be returned- Returns:
- The
FileHandlefor the given path - Throws:
IOException- Since:
- 4.0.120
-
getLanguageSpecificPage
Get thePagefor 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
Dateobject for the start time of the generation process - Since:
- 4.0.126
-
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 contextornullduring 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 firstDatasetif this page is a content page, otherwisenull.- Returns:
- First
Datasetornull. - 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
-