Class LanguageHelper

java.lang.Object
org.apache.camel.support.LanguageHelper

public final class LanguageHelper extends Object
  • Method Details

    • exception

      public static Exception exception(org.apache.camel.Exchange exchange)
      Extracts the exception from an Exchange
      Parameters:
      exchange - the exchange to extract the exception
      Returns:
      the exception or null if not present
    • exceptionMessage

      public static String exceptionMessage(org.apache.camel.Exchange exchange)
      Extracts the exception message from an exchange
      Parameters:
      exchange - the exchange to extract the exception
      Returns:
      the message or null if not found
    • exceptionStacktrace

      public static String exceptionStacktrace(org.apache.camel.Exchange exchange)
      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 test
      leftValue - the value being tested
      rightValue - 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 test
      leftValue - the value being tested
      rightValue - 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 context
      exchangeFormatter - the exchange formatter
      Returns:
      the exchange formatter or the newly created one if previously unset
    • sysenv

      public static String sysenv(String name)
      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

      public static String escapeQuotes(String text)
    • dateFromFileLastModified

      public static Date dateFromFileLastModified(org.apache.camel.Exchange exchange, String command)
    • 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)
    • dateFromVariable

      public static Date dateFromVariable(org.apache.camel.Exchange exchange, String command, BiFunction<org.apache.camel.Exchange,Object,Date> orElseFunction)
    • dateFromExchangeCreated

      public static Date dateFromExchangeCreated(org.apache.camel.Exchange exchange)
      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 offset
      offsets - the numeric offset as a milliseconds from epoch
      pattern - the (optional) date pattern to convert the given date to
      timezone - 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

      public static List<Long> captureOffsets(String commandWithOffsets, Pattern offsetPattern)