Class ParseCommonLog

java.lang.Object
ca.uqac.lif.cep.functions.Function
ca.uqac.lif.cep.functions.UnaryFunction<String,HttpRequest>
ca.uqac.lif.cep.apache.ParseCommonLog
All Implemented Interfaces:
ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.functions.DuplicableFunction

public class ParseCommonLog extends ca.uqac.lif.cep.functions.UnaryFunction<String,HttpRequest>
Parses a line of an Apache log in the common log format and creates an HttpRequest object with it.
Author:
Sylvain Hallé
  • Field Details

    • instance

      public static final ParseCommonLog instance
    • m_calendar

      protected final Calendar m_calendar
      An instance of calendar to convert dates into timestamps
    • s_linePattern

      protected static final transient Pattern s_linePattern
      The pattern to parse a line of the log
    • s_urlPattern

      protected static final transient Pattern s_urlPattern
      The pattern to parse a URL
  • Method Details

    • getValue

      public HttpRequest getValue(String log_line)
      Specified by:
      getValue in class ca.uqac.lif.cep.functions.UnaryFunction<String,HttpRequest>
    • parseTime

      public static long parseTime(Calendar calendar, String time_string)
    • stringToMonth

      public static int stringToMonth(String m)
    • queryToMap

      public static Map<String,String> queryToMap(String query, HttpRequest.Method m)
      Convenience method to transform a GET query into a map of attribute-value pairs. For example, given an URI object representing the URL "http://abc.com/xyz?a=1&b=2", the method will return an object mapping "a" to "1" and "b" to "2".
      Parameters:
      query - The URI to process
      m - The method (GET, POST, etc.) of the request
      Returns:
      A map of attribute-value pairs
    • methodToString

      public static final String methodToString(HttpRequest.Method m)
      Creates a string out of a method
      Parameters:
      m - The method
      Returns:
      The method in string
    • stringToMethod

      public static HttpRequest.Method stringToMethod(String s)
    • parseParameters

      public static Map<String,String> parseParameters(String param_string)