本文整理汇总了Java中nl.basjes.parse.core.Parser.addDissector方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.addDissector方法的具体用法?Java Parser.addDissector怎么用?Java Parser.addDissector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.basjes.parse.core.Parser
的用法示例。
在下文中一共展示了Parser.addDissector方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestParser
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
public static Parser<TestRecord> createTestParser() throws NoSuchMethodException {
Parser<TestRecord> parser = new HttpdLoglineParser<>(TestRecord.class, getLogFormat());
parser.addDissector(new nl.basjes.parse.httpdlog.dissectors.ScreenResolutionDissector());
parser.addTypeRemapping("request.firstline.uri.query.g", "HTTP.URI");
parser.addTypeRemapping("request.firstline.uri.query.r", "HTTP.URI");
parser.addTypeRemapping("request.firstline.uri.query.s", "SCREENRESOLUTION");
parser.addParseTarget("setConnectionClientHost", "IP:connection.client.host");
parser.addParseTarget("setRequestReceiveTime", "TIME.STAMP:request.receive.time");
parser.addParseTarget("setReferrer", "STRING:request.firstline.uri.query.g.query.promo");
parser.addParseTarget("setScreenResolution", "STRING:request.firstline.uri.query.s");
parser.addParseTarget("setScreenWidth", "SCREENWIDTH:request.firstline.uri.query.s.width");
parser.addParseTarget("setScreenHeight", "SCREENHEIGHT:request.firstline.uri.query.s.height");
parser.addParseTarget("setGoogleQuery", "STRING:request.firstline.uri.query.r.query.blabla");
parser.addParseTarget("setBui", "HTTP.COOKIE:request.cookies.bui");
parser.addParseTarget("setUseragent", "HTTP.USERAGENT:request.user-agent");
return parser;
}
示例2: createTestParser
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
public static Parser<TestRecord> createTestParser() throws NoSuchMethodException {
Parser<TestRecord> parser = new HttpdLoglineParser<>(TestRecord.class, getLogFormat());
parser.addDissector(new ScreenResolutionDissector());
parser.addTypeRemapping("request.firstline.uri.query.g", "HTTP.URI");
parser.addTypeRemapping("request.firstline.uri.query.r", "HTTP.URI");
parser.addTypeRemapping("request.firstline.uri.query.s", "SCREENRESOLUTION");
parser.addParseTarget("setConnectionClientHost", "IP:connection.client.host");
parser.addParseTarget("setRequestReceiveTime", "TIME.STAMP:request.receive.time");
parser.addParseTarget("setReferrer", "STRING:request.firstline.uri.query.g.query.promo");
parser.addParseTarget("setScreenResolution", "STRING:request.firstline.uri.query.s");
parser.addParseTarget("setScreenWidth", "SCREENWIDTH:request.firstline.uri.query.s.width");
parser.addParseTarget("setScreenHeight", "SCREENHEIGHT:request.firstline.uri.query.s.height");
parser.addParseTarget("setGoogleQuery", "STRING:request.firstline.uri.query.r.query.blabla");
parser.addParseTarget("setBui", "HTTP.COOKIE:request.cookies.bui");
parser.addParseTarget("setUseragent", "HTTP.USERAGENT:request.user-agent");
return parser;
}
示例3: createAdditionalDissectors
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
@Override
public <RECORD> void createAdditionalDissectors(Parser<RECORD> parser) {
super.createAdditionalDissectors(parser);
parser.addDissector(new BinaryIPDissector());
parser.addDissector(new ConvertSecondsWithMillisStringDissector("SECOND_MILLIS", "MILLISECONDS"));
parser.addDissector(new ConvertSecondsWithMillisStringDissector("TIME.EPOCH_SECOND_MILLIS", "TIME.EPOCH"));
parser.addDissector(new ConvertMillisecondsIntoMicroseconds("MILLISECONDS", "MICROSECONDS"));
}
示例4: createAdditionalDissectors
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
@Override
public <RECORD> void createAdditionalDissectors(Parser<RECORD> parser) {
for (Token token: logFormatTokens) {
parser.addDissector(token.getCustomDissector());
}
}
示例5: createAdditionalDissectors
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
@Override
public <RECORD> void createAdditionalDissectors(Parser<RECORD> parser) {
parser.addDissector(new LocalizedTimeDissector(inputType));
}
示例6: fullTest1
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
/**
* Test of initialize method, of class ApacheHttpdLogParser.
*/
@Test
public void fullTest1() throws Exception {
String line = "%127.0.0.1 127.0.0.1 127.0.0.1 - - [31/Dec/2012:23:49:40 +0100] "
+ "\"GET /icons/powered_by_rh.png?aap=noot&res=1024x768 HTTP/1.1\" 200 1213 "
+ "80 \"\" \"http://localhost/index.php?mies=wim\" 351 "
+ "\"Mozilla/5.0 (X11; Linux i686 on x86_64; rv:11.0) Gecko/20100101 Firefox/11.0\" "
+ "\"jquery-ui-theme=Eggplant\" \"Apache=127.0.0.1.1344635380111339; path=/; domain=.basjes.nl\" \"-\" "
+ "\"\\\"3780ff-4bd-4c1ce3df91380\\\"\"";
Parser<TestRecord> parser = new HttpdLoglineParser<>(TestRecord.class, LOG_FORMAT);
// Manually add an extra dissector
parser.addDissector(new ScreenResolutionDissector());
parser.addTypeRemapping("request.firstline.uri.query.res", "SCREENRESOLUTION");
List<String> extraFields = new ArrayList<>();
extraFields.add("SCREENWIDTH:request.firstline.uri.query.res.width");
extraFields.add("SCREENHEIGHT:request.firstline.uri.query.res.height");
parser.addParseTarget(TestRecord.class.getMethod("setValue", String.class, String.class), extraFields);
TestRecord record = new TestRecord();
parser.parse(record, line);
Map<String, String> results = record.getResults();
System.out.println(results.toString());
assertEquals("noot", results.get("STRING:request.firstline.uri.query.aap"));
assertEquals(null, results.get("STRING:request.firstline.uri.query.foo"));
assertEquals(null, results.get("STRING:request.querystring.aap"));
assertEquals("1024", results.get("SCREENWIDTH:request.firstline.uri.query.res.width"));
assertEquals("768", results.get("SCREENHEIGHT:request.firstline.uri.query.res.height"));
assertEquals("127.0.0.1", results.get("IP:connection.client.ip"));
assertEquals(null, results.get("NUMBER:connection.client.logname"));
assertEquals(null, results.get("STRING:connection.client.user"));
assertEquals("31/Dec/2012:23:49:40 +0100", results.get("TIME.STAMP:request.receive.time"));
assertEquals("1356994180000", results.get("TIME.EPOCH:request.receive.time.epoch"));
assertEquals("1", results.get("TIME.WEEK:request.receive.time.weekofweekyear"));
assertEquals("2013", results.get("TIME.YEAR:request.receive.time.weekyear"));
assertEquals("2012", results.get("TIME.YEAR:request.receive.time.year"));
assertEquals("40", results.get("TIME.SECOND:request.receive.time.second"));
assertEquals("/icons/powered_by_rh.png?aap=noot&res=1024x768", results.get("HTTP.URI:request.firstline.uri"));
assertEquals("200", results.get("STRING:request.status.last"));
assertEquals("1213", results.get("BYTESCLF:response.body.bytes"));
assertEquals("http://localhost/index.php?mies=wim", results.get("HTTP.URI:request.referer"));
assertEquals("wim", results.get("STRING:request.referer.query.mies"));
assertEquals("Mozilla/5.0 (X11; Linux i686 on x86_64; rv:11.0) Gecko/20100101 Firefox/11.0",
results.get("HTTP.USERAGENT:request.user-agent"));
assertEquals("31", results.get("TIME.DAY:request.receive.time.day"));
assertEquals("23", results.get("TIME.HOUR:request.receive.time.hour"));
assertEquals("December", results.get("TIME.MONTHNAME:request.receive.time.monthname"));
assertEquals("351", results.get("MICROSECONDS:response.server.processing.time"));
assertEquals("Apache=127.0.0.1.1344635380111339; path=/; domain=.basjes.nl",
results.get("HTTP.SETCOOKIES:response.cookies"));
assertEquals("jquery-ui-theme=Eggplant", results.get("HTTP.COOKIES:request.cookies"));
assertEquals("\\\"3780ff-4bd-4c1ce3df91380\\\"", results.get("HTTP.HEADER:response.header.etag"));
assertEquals("Eggplant", results.get("HTTP.COOKIE:request.cookies.jquery-ui-theme"));
assertEquals("Apache=127.0.0.1.1344635380111339; path=/; domain=.basjes.nl", results.get("HTTP.SETCOOKIE:response.cookies.apache"));
assertEquals(".basjes.nl", results.get("STRING:response.cookies.apache.domain"));
}
示例7: runManuallyCombined
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
@Test
public void runManuallyCombined(){
Parser<TestRecord> parser = new Parser<>(TestRecord.class);
parser.addDissector(new FooDissector());
parser.addDissector(new BarDissector());
parser.addTypeRemapping("foostring", "BARINPUT");
parser.setRootType(new FooDissector().getInputType());
DissectorTester.create()
.withParser(parser)
.withInput("BlaBlaBla")
.expect("ANY:fooany", "42")
.expect("ANY:fooany", 42L)
.expect("ANY:fooany", 42D)
.expect("STRING:foostring", "42")
.expectAbsentLong("STRING:foostring")
.expectAbsentDouble("STRING:foostring")
.expect("INT:fooint", "42")
.expect("INT:fooint", 42L)
.expectAbsentDouble("INT:fooint")
.expect("LONG:foolong", "42")
.expect("LONG:foolong", 42L)
.expectAbsentDouble("LONG:foolong")
.expect("FLOAT:foofloat", "42.0")
.expectAbsentLong("FLOAT:foofloat")
.expect("FLOAT:foofloat", 42D)
.expect("DOUBLE:foodouble", "42.0")
.expectAbsentLong("DOUBLE:foodouble")
.expect("DOUBLE:foodouble", 42D)
.expect("ANY:foostring.barany", "42")
.expect("ANY:foostring.barany", 42L)
.expect("ANY:foostring.barany", 42D)
.expect("STRING:foostring.barstring", "42")
.expectAbsentLong("STRING:foostring.barstring")
.expectAbsentDouble("STRING:foostring.barstring")
.expect("INT:foostring.barint", "42")
.expect("INT:foostring.barint", 42L)
.expectAbsentDouble("INT:foostring.barint")
.expect("LONG:foostring.barlong", "42")
.expect("LONG:foostring.barlong", 42L)
.expectAbsentDouble("LONG:foostring.barlong")
.expect("FLOAT:foostring.barfloat", "42.0")
.expectAbsentLong("FLOAT:foostring.barfloat")
.expect("FLOAT:foostring.barfloat", 42D)
.expect("DOUBLE:foostring.bardouble", "42.0")
.expectAbsentLong("DOUBLE:foostring.bardouble")
.expect("DOUBLE:foostring.bardouble", 42D)
.checkExpectations();
}
示例8: createAdditionalDissectors
import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
@Override
public <RECORD> void createAdditionalDissectors(Parser<RECORD> parser) {
parser.addDissector(new BarDissector());
parser.addTypeRemapping("foostring", "BARINPUT");
}