Package ca.uqac.lif.cep.apache
Class ParseCommonLog
- java.lang.Object
-
- ca.uqac.lif.cep.functions.Function
-
- ca.uqac.lif.cep.functions.UnaryFunction<java.lang.String,HttpRequest>
-
- ca.uqac.lif.cep.apache.ParseCommonLog
-
- All Implemented Interfaces:
ca.uqac.lif.azrael.Printable
,ca.uqac.lif.azrael.Readable
,ca.uqac.lif.cep.Duplicable
,ca.uqac.lif.cep.functions.DuplicableFunction
public class ParseCommonLog extends ca.uqac.lif.cep.functions.UnaryFunction<java.lang.String,HttpRequest>
Parses a line of an Apache log in the common log format and creates anHttpRequest
object with it.- Author:
- Sylvain Hallé
-
-
Field Summary
Fields Modifier and Type Field Description static ParseCommonLog
instance
protected java.util.Calendar
m_calendar
An instance of calendar to convert dates into timestampsprotected static java.util.regex.Pattern
s_linePattern
The pattern to parse a line of the logprotected static java.util.regex.Pattern
s_urlPattern
The pattern to parse a URL
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpRequest
getValue(java.lang.String log_line)
static java.lang.String
methodToString(HttpRequest.Method m)
Creates a string out of a methodstatic java.util.Map<java.lang.String,java.lang.String>
parseParameters(java.lang.String param_string)
static long
parseTime(java.util.Calendar calendar, java.lang.String time_string)
static java.util.Map<java.lang.String,java.lang.String>
queryToMap(java.lang.String query, HttpRequest.Method m)
Convenience method to transform a GET query into a map of attribute-value pairs.static HttpRequest.Method
stringToMethod(java.lang.String s)
static int
stringToMonth(java.lang.String m)
-
Methods inherited from class ca.uqac.lif.cep.functions.UnaryFunction
duplicate, evaluate, getInputArity, getInputTypesFor, getOutputArity, getOutputTypeFor, reset
-
-
-
-
Field Detail
-
instance
public static final ParseCommonLog instance
-
m_calendar
protected final java.util.Calendar m_calendar
An instance of calendar to convert dates into timestamps
-
s_linePattern
protected static final transient java.util.regex.Pattern s_linePattern
The pattern to parse a line of the log
-
s_urlPattern
protected static final transient java.util.regex.Pattern s_urlPattern
The pattern to parse a URL
-
-
Method Detail
-
getValue
public HttpRequest getValue(java.lang.String log_line)
- Specified by:
getValue
in classca.uqac.lif.cep.functions.UnaryFunction<java.lang.String,HttpRequest>
-
parseTime
public static long parseTime(java.util.Calendar calendar, java.lang.String time_string)
-
stringToMonth
public static int stringToMonth(java.lang.String m)
-
queryToMap
public static java.util.Map<java.lang.String,java.lang.String> queryToMap(java.lang.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 processm
- The method (GET, POST, etc.) of the request- Returns:
- A map of attribute-value pairs
-
methodToString
public static final java.lang.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(java.lang.String s)
-
parseParameters
public static java.util.Map<java.lang.String,java.lang.String> parseParameters(java.lang.String param_string)
-
-