Enum FieldType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<FieldType>

    public enum FieldType
    extends java.lang.Enum<FieldType>
    Semantic type of a user-editable field, used by FieldValidationService to apply a dedicated validation or sanitization strategy.

    This type is independent from any particular feature: it can be reused by any form (site properties, plugin configuration, admin forms, etc.) that needs a per-type validation. The mapping between a concrete field or datastore key and its FieldType is the responsibility of the caller.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      COLOR
      CSS color value (#RGB, #RRGGBB, #RRGGBBAA, rgb()/rgba()).
      EMAIL
      Email address, validated against the email format.
      HTML
      HTML content, sanitized with the XSS sanitizer allowlist.
      TEXT
      Plain text, left under the responsibility of the global XSS sanitizer filter.
      URL
      URL or resource path, validated structurally, on its scheme and on its query parameter values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean requiresXssBypass()
      Indicates whether a field of this type must bypass the global XSS sanitizer filter of the form.
      static FieldType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static FieldType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • TEXT

        public static final FieldType TEXT
        Plain text, left under the responsibility of the global XSS sanitizer filter.
      • EMAIL

        public static final FieldType EMAIL
        Email address, validated against the email format.
      • URL

        public static final FieldType URL
        URL or resource path, validated structurally, on its scheme and on its query parameter values.
      • COLOR

        public static final FieldType COLOR
        CSS color value (#RGB, #RRGGBB, #RRGGBBAA, rgb()/rgba()).
      • HTML

        public static final FieldType HTML
        HTML content, sanitized with the XSS sanitizer allowlist.
    • Method Detail

      • values

        public static FieldType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (FieldType c : FieldType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static FieldType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • requiresXssBypass

        public boolean requiresXssBypass()
        Indicates whether a field of this type must bypass the global XSS sanitizer filter of the form.

        The global filter strips a configured set of characters (see lutece.safe.request.site.xssCharacters, typically <>#"&). A type requires the bypass only when its legitimate content contains such characters: a URL carries = and & in its query string, a COLOR starts with #, and HTML carries markup. EMAIL and TEXT do not require the bypass: a valid email contains none of the filtered characters and is only validated, and plain text stays under the global filter.

        Returns:
        true for URL, COLOR and HTML, false otherwise