1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.rolling.helper;
15
16 import ch.qos.logback.core.pattern.DynamicConverter;
17
18
19
20
21
22
23
24 public class IntegerTokenConverter extends DynamicConverter implements MonoTypedConverter {
25
26 public final static String CONVERTER_KEY = "i";
27
28 public IntegerTokenConverter() {
29 }
30
31 public String convert(int i) {
32 return Integer.toString(i);
33 }
34
35 public String convert(Object o) {
36 if(o == null) {
37 throw new IllegalArgumentException("Null argument forbidden");
38 }
39 if(o instanceof Integer) {
40 Integer i = (Integer) o;
41 return convert(i.intValue());
42 }
43 throw new IllegalArgumentException("Cannot convert "+o+" of type"+o.getClass().getName());
44 }
45
46 public boolean isApplicable(Object o) {
47 return (o instanceof Integer);
48 }
49 }