當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。