Package org.openrefine.util
Class ParsingUtilities
- java.lang.Object
-
- org.openrefine.util.ParsingUtilities
-
public class ParsingUtilities extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static com.fasterxml.jackson.databind.ser.FilterProvider
defaultFilters
static com.fasterxml.jackson.databind.ObjectWriter
defaultWriter
static DateTimeFormatter
ISO8601
static com.fasterxml.jackson.core.JsonFactory
jsonFactory
static com.fasterxml.jackson.databind.ObjectMapper
mapper
static com.fasterxml.jackson.databind.ser.FilterProvider
saveFilters
static com.fasterxml.jackson.databind.ObjectWriter
saveWriter
-
Constructor Summary
Constructors Constructor Description ParsingUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OffsetDateTime
calendarToOffsetDateTime(Calendar calendar)
static String
dateToString(OffsetDateTime d)
Convert a date/time to an ISO_LOCAL_DATE_TIME stringstatic String
decode(String s)
Decode a string from UTF-8 encoding.static String
encode(String s)
Encode a string as UTF-8.static com.fasterxml.jackson.databind.node.ArrayNode
evaluateJsonStringToArrayNode(String parameter)
static com.fasterxml.jackson.databind.node.ObjectNode
evaluateJsonStringToObjectNode(String optionsString)
static String
inputStreamToString(InputStream is)
static String
inputStreamToString(InputStream is, String encoding)
static boolean
isDate(Object o)
static String
localDateToString(LocalDateTime d)
static Calendar
offsetDateTimeToCalendar(OffsetDateTime offsetDateTime)
static Properties
parseParameters(String str)
static Properties
parseParameters(Properties p, String str)
static Properties
parseUrlParameters(javax.servlet.http.HttpServletRequest request)
static OffsetDateTime
stringToDate(String s)
Parse an ISO_LOCAL_DATE_TIME formatted string into a Java Date.static LocalDateTime
stringToLocalDate(String s)
static OffsetDateTime
toDate(Calendar date)
Converts an old-style Java Calendar to an OffsetDateTime, assuming the date is represented in the current default system zone (which is what you get if the date was parsed using `Calendar.getDefault()`).static OffsetDateTime
toDate(Date date)
Converts an old-style Java Date to an OffsetDateTime, assuming the date is represented in the current default system zone (which is what you get if the date was parsed using `Calendar.getDefault()`).
-
-
-
Field Detail
-
jsonFactory
public static com.fasterxml.jackson.core.JsonFactory jsonFactory
-
mapper
public static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
defaultFilters
public static final com.fasterxml.jackson.databind.ser.FilterProvider defaultFilters
-
saveFilters
public static final com.fasterxml.jackson.databind.ser.FilterProvider saveFilters
-
saveWriter
public static final com.fasterxml.jackson.databind.ObjectWriter saveWriter
-
defaultWriter
public static final com.fasterxml.jackson.databind.ObjectWriter defaultWriter
-
ISO8601
public static final DateTimeFormatter ISO8601
-
-
Method Detail
-
parseUrlParameters
public static Properties parseUrlParameters(javax.servlet.http.HttpServletRequest request)
-
parseParameters
public static Properties parseParameters(Properties p, String str)
-
parseParameters
public static Properties parseParameters(String str)
-
inputStreamToString
public static String inputStreamToString(InputStream is) throws IOException
- Throws:
IOException
-
inputStreamToString
public static String inputStreamToString(InputStream is, String encoding) throws IOException
- Throws:
IOException
-
dateToString
public static String dateToString(OffsetDateTime d)
Convert a date/time to an ISO_LOCAL_DATE_TIME string- Parameters:
d
- the date to be written- Returns:
- string with ISO_LOCAL_DATE_TIME formatted date and time
-
localDateToString
public static String localDateToString(LocalDateTime d)
-
stringToDate
public static OffsetDateTime stringToDate(String s)
Parse an ISO_LOCAL_DATE_TIME formatted string into a Java Date. For backward compatibility, to support the version <= 2.8, cannot use the DateTimeFormatter.ISO_OFFSET_DATE_TIME. Instead, use the ISO8601 below format: yyyy-MM-dd'T'HH:mm:ss'Z'- Parameters:
s
- the string to be parsed- Returns:
- LocalDateTime or null if the parse failed
-
stringToLocalDate
public static LocalDateTime stringToLocalDate(String s)
-
calendarToOffsetDateTime
public static OffsetDateTime calendarToOffsetDateTime(Calendar calendar)
-
offsetDateTimeToCalendar
public static Calendar offsetDateTimeToCalendar(OffsetDateTime offsetDateTime)
-
isDate
public static boolean isDate(Object o)
-
toDate
public static OffsetDateTime toDate(Date date)
Converts an old-style Java Date to an OffsetDateTime, assuming the date is represented in the current default system zone (which is what you get if the date was parsed using `Calendar.getDefault()`).
-
toDate
public static OffsetDateTime toDate(Calendar date)
Converts an old-style Java Calendar to an OffsetDateTime, assuming the date is represented in the current default system zone (which is what you get if the date was parsed using `Calendar.getDefault()`).
-
evaluateJsonStringToObjectNode
public static com.fasterxml.jackson.databind.node.ObjectNode evaluateJsonStringToObjectNode(String optionsString)
-
evaluateJsonStringToArrayNode
public static com.fasterxml.jackson.databind.node.ArrayNode evaluateJsonStringToArrayNode(String parameter) throws IOException
- Throws:
IOException
-
-