當前位置: 首頁>>代碼示例>>Java>>正文


Java Parser.getPossiblePaths方法代碼示例

本文整理匯總了Java中nl.basjes.parse.core.Parser.getPossiblePaths方法的典型用法代碼示例。如果您正苦於以下問題:Java Parser.getPossiblePaths方法的具體用法?Java Parser.getPossiblePaths怎麽用?Java Parser.getPossiblePaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nl.basjes.parse.core.Parser的用法示例。


在下文中一共展示了Parser.getPossiblePaths方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printAllPossibles

import nl.basjes.parse.core.Parser; //導入方法依賴的package包/類
private void printAllPossibles(String logformat) throws NoSuchMethodException, MissingDissectorsException, InvalidDissectorException {
    // To figure out what values we CAN get from this line we instantiate the parser with a dummy class
    // that does not have ANY @Field annotations.
    Parser<Object> dummyParser= new HttpdLoglineParser<>(Object.class, logformat);

    List<String> possiblePaths;
    possiblePaths = dummyParser.getPossiblePaths();

    // If you want to call 'getCasts' then the actual parser needs to be constructed.
    // Simply calling getPossiblePaths does not build the actual parser.
    // Because we want this for all possibilities yet we are never actually going to use this instance of the parser
    // We simply give it a random method with the right signature and tell it we want all possible paths
    dummyParser.addParseTarget(String.class.getMethod("indexOf", String.class), possiblePaths);

    LOG.info("==================================");
    LOG.info("Possible output:");
    for (String path : possiblePaths) {
        LOG.info("{}     {}", path, dummyParser.getCasts(path));
    }
    LOG.info("==================================");
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:22,代碼來源:Main.java

示例2: testGetPossiblePaths

import nl.basjes.parse.core.Parser; //導入方法依賴的package包/類
@Test
public void testGetPossiblePaths() {
    Parser<TestRecord> parser = new HttpdLoglineParser<>(TestRecord.class, LOG_FORMAT);

    List<String> paths = parser.getPossiblePaths(5);
    assertEquals(true, paths.contains("TIME.SECOND:request.receive.time.second"));
    assertEquals(true, paths.contains("STRING:request.firstline.uri.query.*"));
    assertEquals(true, paths.contains("STRING:response.cookies.*.expires"));
    assertEquals(true, paths.contains("HTTP.HEADER:response.header.etag"));

    assertEquals(false, paths.contains("FIXED_STRING:fixed_string"));
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:13,代碼來源:ApacheHttpdLogParserTest.java

示例3: testEmptyRecordPossibles

import nl.basjes.parse.core.Parser; //導入方法依賴的package包/類
@Test
public void testEmptyRecordPossibles() {
    Parser<EmptyTestRecord> parser = new HttpdLoglineParser<>(EmptyTestRecord.class, LOG_FORMAT);

    List<String> possibles = parser.getPossiblePaths();
    for (String possible : possibles) {
        System.out.println(possible);
    }
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:10,代碼來源:CookiesTest.java

示例4: testRecordPossibles

import nl.basjes.parse.core.Parser; //導入方法依賴的package包/類
@Test
public void testRecordPossibles() {
    Parser<TestRecord> parser = new HttpdLoglineParser<>(TestRecord.class, LOG_FORMAT);

    List<String> possibles = parser.getPossiblePaths();
    for (String possible : possibles) {
        System.out.println(possible);
    }
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:10,代碼來源:CookiesTest.java

示例5: testBasicParsing

import nl.basjes.parse.core.Parser; //導入方法依賴的package包/類
@Test
public void testBasicParsing() {
    Parser<TestRecord> parser = new HttpdLoglineParser<>(TestRecord.class, LOGFORMAT);

    DissectorTester tester = DissectorTester.create()
        .withParser(parser)
        .verbose();

    for (String logline: LOGLINES){
        tester.withInput(logline);
    }

    tester.expectValuePresent("TIME.LOCALIZEDSTRING:request.receive.time")
          .expectValuePresent("STRING:connection.server.name")
          .expectValuePresent("NUMBER:connection.client.logname")
          .expectValuePresent("STRING:connection.client.user")
          .expectValuePresent("HTTP.HEADER:request.header.x-forwarded-for")
          .expectValuePresent("HTTP.URI:request.referer")
          .expectValuePresent("HTTP.USERAGENT:request.user-agent")
          .expectValuePresent("HTTP.HEADER:request.header.host")
          .expectValuePresent("HTTP.FIRSTLINE:request.firstline")
          .expectValuePresent("HTTP.METHOD:request.firstline.method")
          .expectValuePresent("HTTP.URI:request.firstline.uri")
          .expectValuePresent("HTTP.PROTOCOL:request.firstline.protocol")
          .expectValuePresent("HTTP.PROTOCOL.VERSION:request.firstline.protocol.version")
          .expectValuePresent("STRING:request.status.last")
          .expectValuePresent("BYTES:response.body.bytes")
          .expectValuePresent("MICROSECONDS:response.server.processing.time")
          .expectValuePresent("HTTP.QUERYSTRING:request.firstline.uri.query")
          .expectValuePresent("HTTP.PATH:request.firstline.uri.path")
          .expectValuePresent("HTTP.REF:request.firstline.uri.ref");

    for (String path: parser.getPossiblePaths()){
        tester.expectPossible(path);
    }

    tester.checkExpectations();
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:39,代碼來源:JsonLogFormatTest.java

示例6: testBasicParsing

import nl.basjes.parse.core.Parser; //導入方法依賴的package包/類
@Test
public void testBasicParsing() throws Exception {
    Parser<MyRecord> parser = new HttpdLoglineParser<>(MyRecord.class, LOG_FORMAT);
    MyRecord         record = new MyRecord();

    List<String> paths = parser.getPossiblePaths();

    parser.addParseTarget(record.getClass().getMethod("setValue", String.class, String.class), paths);

    for (String logline : LOG_LINES) {
        record.clear();
        parser.parse(record, logline);
        System.out.println(record.toString());
    }
}
 
開發者ID:nielsbasjes,項目名稱:logparser,代碼行數:16,代碼來源:BasicOverallTest.java


注:本文中的nl.basjes.parse.core.Parser.getPossiblePaths方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。