Interface OfficeStamperConfiguration

All Known Implementing Classes:
DocxStamperConfiguration

public interface OfficeStamperConfiguration
Interface representing the configuration for the Office Stamper functionality.
  • Method Details

    • exposeInterfaceToExpressionLanguage

      OfficeStamperConfiguration exposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation)
      Exposes an interface to the expression language.
      Parameters:
      interfaceClass - the interface class to be exposed
      implementation - the implementation object of the interface
      Returns:
      the updated OfficeStamperConfiguration object
    • addCommentProcessor

      OfficeStamperConfiguration addCommentProcessor(Class<?> interfaceClass, CommentProcessorFactory commentProcessorFactory)

      Adds a comment processor to the OfficeStamperConfiguration.

      A comment processor is responsible for processing comments in the document and performing specific operations based on the comment content.

      Parameters:
      interfaceClass - the interface class associated with the comment processor
      commentProcessorFactory - a factory that creates a CommentProcessor object
      Returns:
      the updated OfficeStamperConfiguration object
    • addPreprocessor

      void addPreprocessor(PreProcessor preprocessor)

      Adds a pre-processor to the OfficeStamperConfiguration.

      A pre-processor is responsible for processing the document before the actual processing takes place.

      Parameters:
      preprocessor - the pre-processor to add
    • getEvaluationContextFactory

      @Deprecated(since="3.4", forRemoval=true) EvaluationContextFactory getEvaluationContextFactory()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since version 3.4, use alternative configuration method getSpelSecurityMode()
      Retrieves the EvaluationContextFactory for creating Spring Expression Language (SpEL) EvaluationContext instances used by the office stamper.
      Returns:
      the EvaluationContextFactory for creating SpEL EvaluationContext instances.
    • setEvaluationContextFactory

      @Deprecated(since="3.4", forRemoval=true) OfficeStamperConfiguration setEvaluationContextFactory(EvaluationContextFactory evaluationContextFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since version 3.4, use alternative configuration method setSpelSecurityMode(SecurityMode)
      Sets the EvaluationContextFactory for creating Spring Expression Language (SpEL) EvaluationContext instances.
      Parameters:
      evaluationContextFactory - the EvaluationContextFactory for creating SpEL EvaluationContext instances.
      Returns:
      the updated OfficeStamperConfiguration object.
    • getExpressionFunctions

      Map<Class<?>,Object> getExpressionFunctions()
      Retrieves the map of expression functions associated with their corresponding classes.
      Returns:
      a map containing the expression functions as values and their corresponding classes as keys.
    • getCommentProcessors

      Map<Class<?>, CommentProcessorFactory> getCommentProcessors()
      Returns a map of comment processors associated with their respective classes.
      Returns:
      The map of comment processors. The keys are the classes, and the values are the corresponding comment processor factories.
    • getPreprocessors

      List<PreProcessor> getPreprocessors()
      Retrieves the list of pre-processors.
      Returns:
      The list of pre-processors.
    • getResolvers

      List<ObjectResolver> getResolvers()
      Retrieves the list of ObjectResolvers.
      Returns:
      The list of ObjectResolvers.
    • setResolvers

      Sets the list of object resolvers for the OfficeStamper configuration.
      Parameters:
      resolvers - the list of object resolvers to be set
      Returns:
      the updated OfficeStamperConfiguration instance
    • addResolver

      Adds an ObjectResolver to the OfficeStamperConfiguration.
      Parameters:
      resolver - The ObjectResolver to add to the configuration.
      Returns:
      The updated OfficeStamperConfiguration.
    • getExceptionResolver

      ExceptionResolver getExceptionResolver()
      Retrieves the instance of the ExceptionResolver.
      Returns:
      the ExceptionResolver instance used to handle exceptions
    • setExceptionResolver

      OfficeStamperConfiguration setExceptionResolver(ExceptionResolver exceptionResolver)
      Sets the exception resolver to be used by the OfficeStamperConfiguration. The exception resolver determines how exceptions will be handled during the processing of office documents.
      Parameters:
      exceptionResolver - the ExceptionResolver instance to set
      Returns:
      the current instance of OfficeStamperConfiguration for method chaining
    • customFunctions

      List<CustomFunction> customFunctions()
      Retrieves a list of custom functions.
      Returns:
      a List containing instances of CustomFunction.
    • addCustomFunction

      void addCustomFunction(String name, Supplier<?> implementation)
      Adds a custom function to the system with the specified name and implementation.
      Parameters:
      name - the unique name of the custom function to be added
      implementation - a Supplier that provides the implementation of the custom function
    • addCustomFunction

      <T> CustomFunction.NeedsFunctionImpl<T> addCustomFunction(String name, Class<T> class0)
      Adds a custom function with the specified name and associated class type. This method allows users to define custom behavior by associating a function implementation with a given name and type.
      Type Parameters:
      T - The type associated with the custom function.
      Parameters:
      name - The name of the custom function to be added.
      class0 - The class type of the custom function.
      Returns:
      An instance of NeedsFunctionImpl parameterized with the type of the custom function.
    • addCustomFunction

      <T,U> CustomFunction.NeedsBiFunctionImpl<T,U> addCustomFunction(String name, Class<T> class0, Class<U> class1)
      Adds a custom bi-function with the specified name and the provided parameter types.
      Type Parameters:
      T - the type of the first parameter
      U - the type of the second parameter
      Parameters:
      name - the name of the custom function to be added
      class0 - the class type for the first parameter of the bi-function
      class1 - the class type for the second parameter of the bi-function
      Returns:
      an instance of NeedsBiFunctionImpl parameterized with the provided types
    • addCustomFunction

      <T,U,V> CustomFunction.NeedsTriFunctionImpl<T,U,V> addCustomFunction(String name, Class<T> class0, Class<U> class1, Class<V> class2)
      Adds a custom function with the specified parameters.
      Type Parameters:
      T - the type of the first parameter
      U - the type of the second parameter
      V - the type of the third parameter
      Parameters:
      name - the name of the custom function
      class0 - the class type of the first parameter
      class1 - the class type of the second parameter
      class2 - the class type of the third parameter
      Returns:
      an instance of NeedsTriFunctionImpl for the provided parameter types
    • getPostprocessors

      List<PostProcessor> getPostprocessors()
      Retrieves the list of post-processors associated with this instance.
      Returns:
      a list of PostProcessor objects.
    • addPostprocessor

      void addPostprocessor(PostProcessor postProcessor)
      Adds a postprocessor to modify or enhance data or operations during the processing lifecycle.
      Parameters:
      postProcessor - the PostProcessor instance to be added
    • getParserConfiguration

      org.springframework.expression.spel.SpelParserConfiguration getParserConfiguration()
      Retrieves the parser configuration used by the office stamper.
      Returns:
      the SpelParserConfiguration instance.
    • setParserConfiguration

      OfficeStamperConfiguration setParserConfiguration(org.springframework.expression.spel.SpelParserConfiguration parserConfiguration)
      Sets the parser configuration to be used by the office stamper.
      Parameters:
      parserConfiguration - the SpelParserConfiguration instance to set.
      Returns:
      the updated OfficeStamperConfiguration object.
    • getSpelSecurityMode

      SecurityMode getSpelSecurityMode()

      Gets the current SpEL security mode.

      Defaults to SecurityMode.RESTRICTED, which hardens the evaluation context to mitigate risks such as type access, bean resolution, and constructor invocation.

      Returns:
      the current SecurityMode used for SpEL evaluation
    • setSpelSecurityMode

      OfficeStamperConfiguration setSpelSecurityMode(SecurityMode mode)

      Sets the SpEL security mode.

      Use SecurityMode.RESTRICTED for untrusted templates (default). Use SecurityMode.PERMISSIVE only for trusted inputs when you need full SpEL capabilities.

      Parameters:
      mode - the desired SecurityMode
      Returns:
      the updated OfficeStamperConfiguration object
    • getSvgSecurityMode

      SecurityMode getSvgSecurityMode()

      Indicates whether SVG safe mode is enabled.

      Defaults to SecurityMode.RESTRICTED, which performs SVG parsing with hardened XML parser settings to mitigate XXE/DTD and related risks. When disabled, a more permissive parser is used.

      Returns:
      the current SecurityMode used for SVG parsing
    • setSvgSecurityMode

      OfficeStamperConfiguration setSvgSecurityMode(SecurityMode mode)

      Enables or disables SVG safe mode.

      Safe mode is enabled by default to ensure secure SVG parsing. Disable only if you fully trust the SVG inputs and need permissive behavior.

      Parameters:
      mode - the desired SecurityMode
      Returns:
      the updated OfficeStamperConfiguration object