Package org.codelibs.fess.util
Class DocumentUtil
java.lang.Object
org.codelibs.fess.util.DocumentUtil
Utility class for document data manipulation and type conversion.
This class provides static methods for extracting typed values from document maps,
URL encoding, and other document-related operations. It's designed as a final
utility class with only static methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncodes a URL by encoding non-URL-safe characters.static <T> TGets a typed value from a document map.static <T> TGets a typed value from a document map with a default value.
-
Method Details
-
getValue
Gets a typed value from a document map with a default value.- Type Parameters:
T- the type to convert the value to- Parameters:
doc- the document map to extract the value fromkey- the key to look up in the document mapclazz- the class type to convert the value todefaultValue- the default value to return if the key is not found or conversion fails- Returns:
- the converted value or the default value if not found
-
getValue
Gets a typed value from a document map. Supports conversion to String, Date, Long, Integer, Double, Float, Boolean, List, and String array types. Handles both single values and arrays/lists.- Type Parameters:
T- the type to convert the value to- Parameters:
doc- the document map to extract the value fromkey- the key to look up in the document mapclazz- the class type to convert the value to- Returns:
- the converted value or null if not found or conversion fails
-
encodeUrl
Encodes a URL by encoding non-URL-safe characters. Uses the request's character encoding if available, otherwise defaults to UTF-8. Only encodes characters that are not considered URL-safe according to CharUtil.- Parameters:
url- the URL to encode- Returns:
- the encoded URL with non-URL-safe characters properly encoded
-