Enum Class PredefinedAnnotationRenderStrategy

java.lang.Object
java.lang.Enum<PredefinedAnnotationRenderStrategy>
com.levigo.jadice.web.shared.model.settings.strategy.PredefinedAnnotationRenderStrategy
All Implemented Interfaces:
Serializable, Comparable<PredefinedAnnotationRenderStrategy>, Constable

public enum PredefinedAnnotationRenderStrategy extends Enum<PredefinedAnnotationRenderStrategy>
This class publishes the available AnnotationRenderStrategy as enum values.

It also provides helper methods to store/retrieve the strategy for a document via getStrategyFrom(Document) and applyToDocument(Document) respectively.

General background
The annotation render strategies will be used on client and server side. By using this enum, no serialization / reflection is needed to get the strategy.

To apply an AnnotationRenderStrategy, the DocumentDataProvider implementation must set the desired PredefinedAnnotationRenderStrategy on a document. The client and server side renderers will then use this strategy to check if they should render the annotation.

To apply a strategy in a renderer implementation, the following 3 steps are required:

  • Enum Constant Details

    • CLIENT

      public static final PredefinedAnnotationRenderStrategy CLIENT
      Annotations shall always be rendered on the client side, regardless of their permissions.
    • SERVER_SIDE_MASKING

      public static final PredefinedAnnotationRenderStrategy SERVER_SIDE_MASKING
      Annotations shall be rendered on server side, if the DENY.REMOVE and DENY.CHANGE permissions are present on the annotation. This represents the default behavior.
  • Field Details

  • Method Details

    • values

      public static PredefinedAnnotationRenderStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PredefinedAnnotationRenderStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getStrategy

      public AnnotationRenderStrategy getStrategy()
      Returns the underlying AnnotationRenderStrategy, which defined the rendering behavior of the annotations.
      Returns:
      the AnnotationRenderStrategy
    • getStrategyFrom

      public static AnnotationRenderStrategy getStrategyFrom(Document document)
      Returns the AnnotationRenderStrategy for the given document. If there is an entry in the document properties with key PROPERTY_KEY, that value will be used to return the AnnotationRenderStrategy to apply. If no property entry is present, or the entry does not point to a valid enum name, the default strategy will be returned.

      This method mainly is for JWT-internal use.

      Parameters:
      document - The document
      Returns:
      the AnnotationRenderStrategy to use for this document (never null)
    • getPredefinedStrategyFrom

      public static PredefinedAnnotationRenderStrategy getPredefinedStrategyFrom(Document document)
      Returns the PredefinedAnnotationRenderStrategy for the given document. If there is an entry in the document properties with key PROPERTY_KEY, that value will be used. If no entry is present, or the entry does not point to a valid enum name, the DEFAULT_STRATEGY will be returned.

      This method may come handy when the integrating application needs client-side access to the render strategy in order to enforce different behaviour depending on the strategy that was configured server-side.

      Parameters:
      document - The document
      Returns:
      the PredefinedAnnotationRenderStrategy to use (never null). One of CLIENT, SERVER_SIDE_MASKING and DEFAULT_STRATEGY.
    • applyToDocument

      public void applyToDocument(Document document)
      This server-side call applies one of the PredefinedAnnotationRenderStrategies to the given document. Make sure this call is made very early from within DocumentDataProvider.read(com.levigo.jadice.document.read.Reader, com.levigo.jadice.web.shared.model.Source) , before reading any document streams.
      Parameters:
      document - The document to apply the current PredefinedAnnotationRenderStrategy to. Transportation takes place in a document property.