Class AttributeUtility
- java.lang.Object
-
- org.gcube.informationsystem.utils.AttributeUtility
-
public class AttributeUtility extends Object
A utility class for handling attribute-related operations.- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.LoggerloggerThe logger for this class.
-
Constructor Summary
Constructors Constructor Description AttributeUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LocalDateTimecheckDateTimeString(String dateTimeString)Checks if a string is a valid date-time string according to the standard pattern.static voidcheckRegex(String regex, String text)Checks if a given text matches a regular expression.static StringevaluateNullForDefaultValue(String defaultValueAsString)Evaluates a default value string, returningnullif the string is "null".static ObjectevaluateValueStringAccordingBaseType(PropertyTypeName.BaseType baseType, String valueAsString)Converts a string value to an object of the specified base type.
-
-
-
Method Detail
-
checkRegex
public static void checkRegex(String regex, String text)
Checks if a given text matches a regular expression.- Parameters:
regex- The regular expression.text- The text to check.- Throws:
RuntimeException- if the text does not match the regex or if the regex is invalid.
-
evaluateNullForDefaultValue
public static String evaluateNullForDefaultValue(String defaultValueAsString)
Evaluates a default value string, returningnullif the string is "null".- Parameters:
defaultValueAsString- The default value as a string.- Returns:
- The evaluated default value.
-
evaluateValueStringAccordingBaseType
public static Object evaluateValueStringAccordingBaseType(PropertyTypeName.BaseType baseType, String valueAsString)
Converts a string value to an object of the specified base type.- Parameters:
baseType- The target base type.valueAsString- The string value to convert.- Returns:
- The converted object.
-
checkDateTimeString
public static LocalDateTime checkDateTimeString(String dateTimeString) throws DateTimeParseException
Checks if a string is a valid date-time string according to the standard pattern.- Parameters:
dateTimeString- The date-time string to check.- Returns:
- The parsed
LocalDateTime. - Throws:
DateTimeParseException- if the string is not a valid date-time.
-
-