Package org.codelibs.fess.taglib
Class FessFunctions
java.lang.Object
org.codelibs.fess.taglib.FessFunctions
Utility class providing static functions for Fess JSP/JSTL expressions and tag libraries.
This class contains various helper methods for formatting, parsing, and manipulating data
in Fess web templates, including date formatting, localization, file operations, and
query parameter handling.
- Since:
- 1.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPrivate constructor to prevent instantiation of this utility class. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncodes a string to URL-safe Base64 format.static DateConverts a Long timestamp to a Date object.static StringEscapes a string so it can be safely embedded inside a JavaScript string literal.static StringGenerates hidden HTML form fields for facet filtering.static StringGenerates URL query parameters for facet filtering.static List<FacetQueryView> Retrieves the list of facet query view objects for display.static booleanfileExists(String path) Checks if a file exists at the specified path within the servlet context.static StringformatCode(String prefix, String style, String mimetype, String input) Formats code content with syntax highlighting and line numbers.static StringformatDate(LocalDateTime date) Formats a LocalDateTime object to ISO datetime string format.static StringformatDate(ZonedDateTime date, String format) Formats a ZonedDateTime object using the specified format pattern.static StringformatDate(Date date) Formats a Date object to ISO datetime string format in UTC timezone.static StringformatDuration(long durationMillis) Formats a duration in milliseconds to a human-readable string.static StringformatFileSize(long value) Formats a file size in bytes to a human-readable string with appropriate units.static StringformatNumber(long value, String pattern) Formats a number using the specified pattern and user's locale.static StringgeoForm()Generates hidden HTML form fields for geographic filtering.static StringgeoQuery()Generates URL query parameters for geographic filtering.static StringgetMessage(String key, String defaultValue) Retrieves a localized message for the given key.static booleanhasActionRole(String role) Checks if the current user has the specified action role or administrative privileges.static Stringhtml(boolean isOpen) Generates an HTML opening or closing tag with appropriate language attribute.static StringJoins array or list elements into a single space-separated string.static StringRetrieves the localized label value for the given key from the current request's label map.static BooleanlabelExists(String value) Checks if a label with the specified key exists in the current request's label map.static StringMasks email addresses in the input string for privacy protection.static StringpagingQuery(String query) Generates URL query parameters for pagination, excluding the specified query parameter.static DateParses a date string using the default date format.static DateParses a date string using the specified format.static StringReplaces all occurrences of a regular expression pattern in the input string.static StringEncodes a string for similar document hash processing.static StringGenerates a complete URL with context path and cache-busting timestamp.
-
Constructor Details
-
FessFunctions
protected FessFunctions()Private constructor to prevent instantiation of this utility class. This class is intended to be used only through its static methods.
-
-
Method Details
-
html
Generates an HTML opening or closing tag with appropriate language attribute.- Parameters:
isOpen- true to generate opening HTML tag, false for closing tag- Returns:
- HTML opening tag with language attribute or closing tag
-
labelExists
Checks if a label with the specified key exists in the current request's label map.- Parameters:
value- the label key to check- Returns:
- true if the label exists, false otherwise
-
label
Retrieves the localized label value for the given key from the current request's label map.- Parameters:
value- the label key to retrieve- Returns:
- the localized label value, or the key itself if not found
-
date
Converts a Long timestamp to a Date object.- Parameters:
value- the timestamp in milliseconds- Returns:
- Date object representing the timestamp, or null if value is null
-
parseDate
Parses a date string using the default date format.- Parameters:
value- the date string to parse- Returns:
- parsed Date object, or null if parsing fails
-
parseDate
Parses a date string using the specified format.- Parameters:
value- the date string to parseformat- the date format pattern or "pdf_date" for PDF date format- Returns:
- parsed Date object, or null if parsing fails
-
formatDate
Formats a Date object to ISO datetime string format in UTC timezone.- Parameters:
date- the date to format- Returns:
- formatted date string, or empty string if date is null
-
formatDate
Formats a LocalDateTime object to ISO datetime string format.- Parameters:
date- the LocalDateTime to format- Returns:
- formatted date string, or empty string if date is null
-
formatDate
Formats a ZonedDateTime object using the specified format pattern.- Parameters:
date- the ZonedDateTime to formatformat- the date format pattern- Returns:
- formatted date string, or empty string if date is null
-
formatDuration
Formats a duration in milliseconds to a human-readable string.- Parameters:
durationMillis- the duration in milliseconds- Returns:
- formatted duration string (e.g., "2 days 14:30:25.123" or "14:30:25.123")
-
formatNumber
Formats a number using the specified pattern and user's locale.- Parameters:
value- the number to formatpattern- the number format pattern- Returns:
- formatted number string
-
formatFileSize
Formats a file size in bytes to a human-readable string with appropriate units.- Parameters:
value- the file size in bytes- Returns:
- formatted file size string (e.g., "1.5M", "2.3G", "512K")
-
pagingQuery
Generates URL query parameters for pagination, excluding the specified query parameter.- Parameters:
query- the query parameter to exclude from paging- Returns:
- URL-encoded query string for pagination
-
facetQuery
Generates URL query parameters for facet filtering.- Returns:
- URL-encoded query string containing facet parameters
-
geoQuery
Generates URL query parameters for geographic filtering.- Returns:
- URL-encoded query string containing geographic parameters
-
facetForm
Generates hidden HTML form fields for facet filtering.- Returns:
- HTML string containing hidden input fields for facet parameters
-
geoForm
Generates hidden HTML form fields for geographic filtering.- Returns:
- HTML string containing hidden input fields for geographic parameters
-
facetQueryViewList
Retrieves the list of facet query view objects for display.- Returns:
- list of FacetQueryView objects
-
base64
Encodes a string to URL-safe Base64 format.- Parameters:
value- the string to encode- Returns:
- Base64 encoded string, or empty string if value is null
-
fileExists
Checks if a file exists at the specified path within the servlet context.- Parameters:
path- the file path relative to the servlet context- Returns:
- true if the file exists, false otherwise
-
url
Generates a complete URL with context path and cache-busting timestamp.- Parameters:
input- the relative URL path starting with '/'- Returns:
- complete URL with context path and optional timestamp parameter
- Throws:
IllegalArgumentException- if input is null or doesn't start with '/'
-
sdh
Encodes a string for similar document hash processing.- Parameters:
input- the string to encode- Returns:
- encoded string, or the original input if blank
-
join
Joins array or list elements into a single space-separated string.- Parameters:
input- the input object (String[], List, or String)- Returns:
- joined string with elements separated by spaces, or empty string if invalid input
-
escapeJs
Escapes a string so it can be safely embedded inside a JavaScript string literal. Single quotes, double quotes, backslashes, and control characters are escaped.- Parameters:
input- the input string to escape- Returns:
- JavaScript-safe escaped string, or empty string if input is null
-
replace
Replaces all occurrences of a regular expression pattern in the input string.- Parameters:
input- the input object to processregex- the regular expression pattern to matchreplacement- the replacement string- Returns:
- string with all matches replaced, or empty string if input is null
-
formatCode
Formats code content with syntax highlighting and line numbers.- Parameters:
prefix- the line number prefix patternstyle- the CSS class name for stylingmimetype- the MIME type of the content (currently unused)input- the code content to format- Returns:
- HTML formatted code with line numbers and styling
-
getMessage
Retrieves a localized message for the given key.- Parameters:
key- the message keydefaultValue- the default value to return if message not found- Returns:
- localized message or default value
-
hasActionRole
Checks if the current user has the specified action role or administrative privileges.- Parameters:
role- the role to check (supports both view and edit variants)- Returns:
- true if the user has the role or admin privileges, false otherwise
-
maskEmail
Masks email addresses in the input string for privacy protection.- Parameters:
value- the string that may contain email addresses- Returns:
- string with email addresses replaced by masked pattern
-