当前位置: 首页>>代码示例>>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;未经允许,请勿转载。