/** * Set the <em>time zone</em> that will be used to represent dates. */ public AccessLogBuilder timeZone(TimeZone timeZone) { if (timeZone == null) throw new NullPointerException("Null time zone"); if (format instanceof ApacheLogFormat) { final ApacheLogFormat apacheFormat = (ApacheLogFormat) format; format = new ApacheLogFormat(timeZone, apacheFormat.getFormat()); return this; } throw new IllegalStateException("TimeZone can not be set for " + format.getClass().getName()); }
private void parse(String format) { for (int x = 0; x < format.length(); x ++) { switch (format.charAt(x)) { case '\\': x = parseEscape(format, x); break; case '%': x = parseFormat(format, null, x); break; default: addLiteral(format.charAt(x)); } } }
/** * Create a new {@link ApacheLogFormat} instance by parsing the format * from the specified {@link String}. */ public ApacheLogFormat(TimeZone timeZone, String format) { if (timeZone == null) throw new NullPointerException("Null time zone"); fields = new ArrayList<Field>(); this.timeZone = timeZone; parse(format); }
case '{': return parseParameter(format, position); case '%': addLiteral('%'); break; // The percent sign case 'a': fields.add(new RemoteAddressField()); break; // Remote IP-address case 'A': fields.add(new LocalAddressField()); break; // Local IP-address case 'D': fields.add(new ResponseTimeField("micro", format, position)); break; // The time taken to serve the request, in microseconds. /* */ case 'h': // Remote (or local if parameterized) host fields.add(parseLocal(parameter, false, field, format, position) ? new LocalHostField() : new RemoteHostField()); /* */ case 'o': fields.add(new ResponseHeaderField(parameter)); break; // A response header /* */ case 'p': // Local (or remote if parameterized) port fields.add(parseLocal(parameter, true, field, format, position) ? new LocalPortField() : new RemotePortField()); case 'r': // First line of request, alias to "%m %U%q %H" fields.add(new RequestMethodField()); addLiteral(' '); fields.add(new RequestURIField()); fields.add(new RequestQueryField()); addLiteral(' '); fields.add(new RequestProtocolField()); break;
/** * Set the <em>format</em> as a {@link String} compatible with the default * {@linkplain ApacheLogFormat Apache access log format} that will be used * by the access logs configured by this instance. */ public AccessLogBuilder format(String format) { if (format == null) throw new NullPointerException("Null format"); return this.format(new ApacheLogFormat(format)); }
private int parseParameter(String format, int position) { if (++position < format.length()) { final int end = format.indexOf('}', position); if (end == position) { return parseFormat(format, null, end); } else if (end > position) { return parseFormat(format, format.substring(position, end), end); } } throw new IllegalArgumentException("Unterminated format parameter in [" + format + "] at character " + position); }
private int parseEscape(String format, int position) { if (++position < format.length()) { final char escaped = format.charAt(position); switch (escaped) { case 't': addLiteral('\t'); break; case 'b': addLiteral('\b'); break; case 'n': addLiteral('\n'); break; case 'r': addLiteral('\r'); break; case 'f': addLiteral('\f'); break; default: addLiteral(escaped); } return position; } throw new IllegalArgumentException("Unterminated escape sequence in [" + format + "] at character " + position); }
case '{': return parseParameter(format, position); case '%': addLiteral('%'); break; // The percent sign case 'a': fields.add(new RemoteAddressField()); break; // Remote IP-address case 'A': fields.add(new LocalAddressField()); break; // Local IP-address case 'D': fields.add(new ResponseTimeField("micro", format, position)); break; // The time taken to serve the request, in microseconds. /* */ case 'h': // Remote (or local if parameterized) host fields.add(parseLocal(parameter, false, field, format, position) ? new LocalHostField() : new RemoteHostField()); /* */ case 'o': fields.add(new ResponseHeaderField(parameter)); break; // A response header /* */ case 'p': // Local (or remote if parameterized) port fields.add(parseLocal(parameter, true, field, format, position) ? new LocalPortField() : new RemotePortField()); case 'r': // First line of request, alias to "%m %U%q %H" fields.add(new RequestMethodField()); addLiteral(' '); fields.add(new RequestURIField()); fields.add(new RequestQueryField()); addLiteral(' '); fields.add(new RequestProtocolField()); break;
/** * Set the <em>format</em> as a {@link String} compatible with the default * {@linkplain ApacheLogFormat Apache access log format} that will be used * by the access logs configured by this instance. */ public AccessLogBuilder format(String format) { if (format == null) throw new NullPointerException("Null format"); return this.format(new ApacheLogFormat(format)); }
private int parseParameter(String format, int position) { if (++position < format.length()) { final int end = format.indexOf('}', position); if (end == position) { return parseFormat(format, null, end); } else if (end > position) { return parseFormat(format, format.substring(position, end), end); } } throw new IllegalArgumentException("Unterminated format parameter in [" + format + "] at character " + position); }
private int parseEscape(String format, int position) { if (++position < format.length()) { final char escaped = format.charAt(position); switch (escaped) { case 't': addLiteral('\t'); break; case 'b': addLiteral('\b'); break; case 'n': addLiteral('\n'); break; case 'r': addLiteral('\r'); break; case 'f': addLiteral('\f'); break; default: addLiteral(escaped); } return position; } throw new IllegalArgumentException("Unterminated escape sequence in [" + format + "] at character " + position); }
private void parse(String format) { for (int x = 0; x < format.length(); x ++) { switch (format.charAt(x)) { case '\\': x = parseEscape(format, x); break; case '%': x = parseFormat(format, null, x); break; default: addLiteral(format.charAt(x)); } } }
case '{': return parseParameter(format, position); case '%': addLiteral('%'); break; // The percent sign case 'a': fields.add(new RemoteAddressField()); break; // Remote IP-address case 'A': fields.add(new LocalAddressField()); break; // Local IP-address case 'D': fields.add(new ResponseTimeField("micro", format, position)); break; // The time taken to serve the request, in microseconds. /* */ case 'h': // Remote (or local if parameterized) host fields.add(parseLocal(parameter, false, field, format, position) ? new LocalHostField() : new RemoteHostField()); /* */ case 'o': fields.add(new ResponseHeaderField(parameter)); break; // A response header /* */ case 'p': // Local (or remote if parameterized) port fields.add(parseLocal(parameter, true, field, format, position) ? new LocalPortField() : new RemotePortField()); case 'r': // First line of request, alias to "%m %U%q %H" fields.add(new RequestMethodField()); addLiteral(' '); fields.add(new RequestURIField()); fields.add(new RequestQueryField()); addLiteral(' '); fields.add(new RequestProtocolField()); break;
/** * Set the <em>time zone</em> that will be used to represent dates. */ public AccessLogBuilder timeZone(TimeZone timeZone) { if (timeZone == null) throw new NullPointerException("Null time zone"); if (format instanceof ApacheLogFormat) { final ApacheLogFormat apacheFormat = (ApacheLogFormat) format; format = new ApacheLogFormat(timeZone, apacheFormat.getFormat()); return this; } throw new IllegalStateException("TimeZone can not be set for " + format.getClass().getName()); }
/** * Set the <em>format</em> as a {@link String} compatible with the default * {@linkplain ApacheLogFormat Apache access log format} that will be used * by the access logs configured by this instance. */ public AccessLogBuilder format(String format) { if (format == null) throw new NullPointerException("Null format"); return this.format(new ApacheLogFormat(format)); }
private int parseParameter(String format, int position) { if (++position < format.length()) { final int end = format.indexOf('}', position); if (end == position) { return parseFormat(format, null, end); } else if (end > position) { return parseFormat(format, format.substring(position, end), end); } } throw new IllegalArgumentException("Unterminated format parameter in [" + format + "] at character " + position); }
/** * Create a new {@link ApacheLogFormat} instance by parsing the format * from the specified {@link String}. */ public ApacheLogFormat(TimeZone timeZone, String format) { if (timeZone == null) throw new NullPointerException("Null time zone"); fields = new ArrayList<Field>(); this.timeZone = timeZone; parse(format); }
private int parseEscape(String format, int position) { if (++position < format.length()) { final char escaped = format.charAt(position); switch (escaped) { case 't': addLiteral('\t'); break; case 'b': addLiteral('\b'); break; case 'n': addLiteral('\n'); break; case 'r': addLiteral('\r'); break; case 'f': addLiteral('\f'); break; default: addLiteral(escaped); } return position; } throw new IllegalArgumentException("Unterminated escape sequence in [" + format + "] at character " + position); }
private void parse(String format) { for (int x = 0; x < format.length(); x ++) { switch (format.charAt(x)) { case '\\': x = parseEscape(format, x); break; case '%': x = parseFormat(format, null, x); break; default: addLiteral(format.charAt(x)); } } }
case '{': return parseParameter(format, position); case '%': addLiteral('%'); break; // The percent sign case 'a': fields.add(new RemoteAddressField()); break; // Remote IP-address case 'A': fields.add(new LocalAddressField()); break; // Local IP-address case 'D': fields.add(new ResponseTimeField("micro", format, position)); break; // The time taken to serve the request, in microseconds. /* */ case 'h': // Remote (or local if parameterized) host fields.add(parseLocal(parameter, false, field, format, position) ? new LocalHostField() : new RemoteHostField()); /* */ case 'o': fields.add(new ResponseHeaderField(parameter)); break; // A response header /* */ case 'p': // Local (or remote if parameterized) port fields.add(parseLocal(parameter, true, field, format, position) ? new LocalPortField() : new RemotePortField()); case 'r': // First line of request, alias to "%m %U%q %H" fields.add(new RequestMethodField()); addLiteral(' '); fields.add(new RequestURIField()); fields.add(new RequestQueryField()); addLiteral(' '); fields.add(new RequestProtocolField()); break;