本文整理汇总了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("==================================");
}
示例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"));
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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());
}
}