Interface GenerationContext

All Superinterfaces:
AutoCloseable, BaseContext, Closeable, Evaluator, GenerationScriptContext, ProjectScriptContext, ScriptContext, SpecialistsBroker

public interface GenerationContext extends GenerationScriptContext, Evaluator, Closeable
Context definition for generation tasks.
Since:
4.0
  • Field Details

    • CONTEXT_VARIABLE_NAME

      static final String 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 the UserService belonging to the generation context
      Specified by:
      getUserService in interface ProjectScriptContext
      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 of UrlCreator.
      Returns:
      An instance of UrlCreator that is currently used
      Since:
      4.0.17
    • getUrlCreatorProvider

      UrlCreatorProvider getUrlCreatorProvider()
      Return the current UrlCreatorProvider 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 interface GenerationScriptContext
      Returns:
      true this context is based on a release version
      Since:
      4.0.17
    • getLanguage

      Language getLanguage()
      Returns the current Language of this generation context
      Specified by:
      getLanguage in interface GenerationScriptContext
      Returns:
      The current Language
      Since:
      4.0.17
    • getUseMasterLanguageForData

      boolean getUseMasterLanguageForData()
      If a page is not translated, the project 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 language true or use the current language false
      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 interface GenerationScriptContext
      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., a PageRef.
      Returns:
      The node.
      Since:
      4.0.17
    • getNavigationContext

      @Nullable @Nullable IDProvider getNavigationContext()
      Returns the origin node for relative urls. This may be the same store element as getNode(), but this may also be a Media for references from a parsed media.
      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 interface GenerationScriptContext
      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

      CharacterReplacer getCharacterReplacer(boolean quote)
      Get a character replacer instance for replacing special characters in the content that will be generated
      Parameters:
      quote - true if the CharacterReplacer should replace quotes
      Returns:
      A CharacterReplacer instance
      Since:
      4.0.17
    • addDataToContext

      void addDataToContext(DataProvider provider)
      Add a DataProvider to the generation context
      Parameters:
      provider - The data providing element.
      Since:
      4.0.120
    • getPage

      Page getPage()
      Return the current Page that is used in the generation context
      Returns:
      The currently used Page
      Since:
      4.0.17
    • setPage

      void setPage(Page value)
      Set the page that is to be used in the generation context
      Parameters:
      value - The Page 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 for getLanguage(). Language.getHTMLEncoding(), returns e.g. "UTF-8".
      Returns:
      The name of the encoding
      Since:
      4.0.17
    • getFont

      Font getFont(String name)
      Return a Font for the given name
      Parameters:
      name - The name of the Font
      Returns:
      The Font instance for the given name
      Since:
      4.0.17
    • getTopStackElement

      String getTopStackElement()
      The actual evaluated expression as string - for debugging.
      Specified by:
      getTopStackElement in interface Evaluator
      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 be null
      Returns:
      The Context of the page. Can be null
      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 a Context by given name. Can return null
      Parameters:
      name - The name of the Context that should be returned. Can be null
      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

      void addCloseable(Closeable closeable)
      Add a Closeable to the generation context
      Since:
      4.0.52
    • close

      void close() throws IOException
      Close all registered closeables.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      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 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 ...");.
      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 is 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 ...");.
      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 with isPreview() 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 with isPreview() 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 in BaseContext.Env.WEBEDIT environments, for visualization of FormData 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 in BaseContext.Env.WEBEDIT environments, for visualization of FormData 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

      @Nullable @Nullable FileHandle getFileHandle(String path) throws IOException
      Reurn a FileHandle for the given path
      Parameters:
      path - The path for the FileHandle that should be returned
      Returns:
      The FileHandle for the given path
      Throws:
      IOException
      Since:
      4.0.120
    • getLanguageSpecificPage

      @NotNull @NotNull Page getLanguageSpecificPage(@NotNull @NotNull Page page)
      Get the Page for the current language
      Parameters:
      page - The Page that should be returned in the specific language version
      Returns:
      A Page in the current language
      Since:
      4.0.102
    • 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 boolean showWebeditButtons()
      Deprecated.
      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 or null 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 first Dataset if this page is a content page, otherwise null.
      Returns:
      First Dataset or null.
      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