Package org.apache.camel.support
Class LanguageHelper
java.lang.Object
org.apache.camel.support.LanguageHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
For the given offsets to a given Date instance and, optionally, convert it to a pattern.captureOffsets
(String commandWithOffsets, Pattern offsetPattern) static Date
dateFromExchangeCreated
(org.apache.camel.Exchange exchange) Extracts the creation date from an exchangestatic Date
dateFromExchangeProperty
(org.apache.camel.Exchange exchange, String command, BiFunction<org.apache.camel.Exchange, Object, Date> orElseFunction) static Date
dateFromFileLastModified
(org.apache.camel.Exchange exchange, String command) static Date
dateFromHeader
(org.apache.camel.Exchange exchange, String command, BiFunction<org.apache.camel.Exchange, Object, Date> orElseFunction) static boolean
Tests if the exchange ends with a given valuestatic String
escapeQuotes
(String text) static Exception
exception
(org.apache.camel.Exchange exchange) Extracts the exception from an Exchangestatic String
exceptionMessage
(org.apache.camel.Exchange exchange) Extracts the exception message from an exchangestatic String
exceptionStacktrace
(org.apache.camel.Exchange exchange) Gets the exception stack trace from an exchangestatic org.apache.camel.spi.ExchangeFormatter
getOrCreateExchangeFormatter
(org.apache.camel.CamelContext camelContext, org.apache.camel.spi.ExchangeFormatter exchangeFormatter) Gets the exchange formatter or creates one if unsetstatic boolean
startsWith
(org.apache.camel.Exchange exchange, Object leftValue, Object rightValue) Tests if the exchange starts with a given valuestatic String
Gets an environment variable from the system (parsing and adjusting the name according to the OS)
-
Method Details
-
exception
Extracts the exception from an Exchange- Parameters:
exchange
- the exchange to extract the exception- Returns:
- the exception or null if not present
-
exceptionMessage
Extracts the exception message from an exchange- Parameters:
exchange
- the exchange to extract the exception- Returns:
- the message or null if not found
-
exceptionStacktrace
Gets the exception stack trace from an exchange- Parameters:
exchange
- exchange the exchange to extract the stack trace- Returns:
- the stack trace or null if no exception is present on the exchange
-
endsWith
public static boolean endsWith(org.apache.camel.Exchange exchange, Object leftValue, Object rightValue) Tests if the exchange ends with a given value- Parameters:
exchange
- the exchange to testleftValue
- the value being testedrightValue
- the suffix to test- Returns:
- true if it ends with or false otherwise
-
startsWith
public static boolean startsWith(org.apache.camel.Exchange exchange, Object leftValue, Object rightValue) Tests if the exchange starts with a given value- Parameters:
exchange
- the exchange to testleftValue
- the value being testedrightValue
- the prefix to test- Returns:
- true if it starts with or false otherwise
-
getOrCreateExchangeFormatter
public static org.apache.camel.spi.ExchangeFormatter getOrCreateExchangeFormatter(org.apache.camel.CamelContext camelContext, org.apache.camel.spi.ExchangeFormatter exchangeFormatter) Gets the exchange formatter or creates one if unset- Parameters:
camelContext
- the Camel contextexchangeFormatter
- the exchange formatter- Returns:
- the exchange formatter or the newly created one if previously unset
-
sysenv
Gets an environment variable from the system (parsing and adjusting the name according to the OS)- Parameters:
name
- the environment variable name- Returns:
- the environment variable value
-
escapeQuotes
-
dateFromFileLastModified
-
dateFromExchangeProperty
public static Date dateFromExchangeProperty(org.apache.camel.Exchange exchange, String command, BiFunction<org.apache.camel.Exchange, Object, Date> orElseFunction) -
dateFromHeader
public static Date dateFromHeader(org.apache.camel.Exchange exchange, String command, BiFunction<org.apache.camel.Exchange, Object, Date> orElseFunction) -
dateFromExchangeCreated
Extracts the creation date from an exchange- Parameters:
exchange
- the exchange to extract the create date- Returns:
- A Date instance
-
applyDateOffsets
public static Object applyDateOffsets(Date date, List<Long> offsets, String pattern, String timezone) For the given offsets to a given Date instance and, optionally, convert it to a pattern. NOTE: this is for internal use of Camel- Parameters:
date
- the date to apply the offsetoffsets
- the numeric offset as a milliseconds from epochpattern
- the (optional) date pattern to convert the given date totimezone
- the timezone for the pattern- Returns:
- A new Date instance with the offsets applied to it *or* a String-based if a pattern is provided
-
captureOffsets
-