当前位置: 首页>>代码示例>>Java>>正文


Java Parser.addTypeRemapping方法代码示例

本文整理汇总了Java中nl.basjes.parse.core.Parser.addTypeRemapping方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.addTypeRemapping方法的具体用法?Java Parser.addTypeRemapping怎么用?Java Parser.addTypeRemapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nl.basjes.parse.core.Parser的用法示例。


在下文中一共展示了Parser.addTypeRemapping方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:nielsbasjes,项目名称:logparser,代码行数:21,代码来源:TestCase.java

示例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;
}
 
开发者ID:nielsbasjes,项目名称:logparser,代码行数:21,代码来源:TestCase.java

示例3: 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"));

}
 
开发者ID:nielsbasjes,项目名称:logparser,代码行数:65,代码来源:ApacheHttpdLogParserTest.java

示例4: 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();
}
 
开发者ID:nielsbasjes,项目名称:logparser,代码行数:53,代码来源:ReferenceTest.java

示例5: createAdditionalDissectors

import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
@Override
public <RECORD> void createAdditionalDissectors(Parser<RECORD> parser) {
    parser.addDissector(new BarDissector());
    parser.addTypeRemapping("foostring", "BARINPUT");
}
 
开发者ID:nielsbasjes,项目名称:logparser,代码行数:6,代码来源:FooSpecialDissector.java

示例6: addTypeRemapping

import nl.basjes.parse.core.Parser; //导入方法依赖的package包/类
/**
 * In order to define a type remapping the format of the field configuration will look like: <br/>
 * HTTP.URI:request.firstline.uri.query.[parameter name] <br/>
 *
 * @param parser Add type remapping to this parser instance.
 * @param fieldName request.firstline.uri.query.[parameter_name]
 * @param fieldType HTTP.URI, etc..
 */
private void addTypeRemapping(final Parser<HttpdLogRecord> parser, final String fieldName, final String fieldType) {
  LOG.debug("Adding type remapping - fieldName: {}, fieldType: {}", fieldName, fieldType);
  parser.addTypeRemapping(fieldName, fieldType);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:13,代码来源:HttpdParser.java


注:本文中的nl.basjes.parse.core.Parser.addTypeRemapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。