1
1
/*
2
- * Copyright 2014 Anthony Corbacho, and contributors.
3
- *
4
2
* Licensed under the Apache License, Version 2.0 (the "License");
5
3
* you may not use this file except in compliance with the License.
6
4
* You may obtain a copy of the License at
24
22
import java .io .InputStreamReader ;
25
23
import java .io .Reader ;
26
24
import java .io .Serializable ;
25
+ import java .nio .charset .Charset ;
27
26
import java .nio .file .Files ;
28
27
import java .util .ArrayList ;
29
28
import java .util .HashMap ;
51
50
* @since 0.0.1
52
51
* @author anthonycorbacho
53
52
*/
53
+ // Note: this code is forked from oi.thekraken.grok.api
54
+ // Copyright 2014 Anthony Corbacho, and contributors.
54
55
public class Grok
55
56
implements Serializable
56
57
{
@@ -244,7 +245,7 @@ public static Grok create(String grokPatternPath, String grokDatatypePath, Strin
244
245
static Reader getFileFromResouces (String filePath )
245
246
throws GrokException
246
247
{
247
- Reader reader = new InputStreamReader (Grok .class .getClassLoader ().getResourceAsStream (filePath ));
248
+ Reader reader = new InputStreamReader (Grok .class .getClassLoader ().getResourceAsStream (filePath ), Charset . defaultCharset () );
248
249
if (reader == null ) {
249
250
throw new GrokException ("File <" + filePath + "> not found." );
250
251
}
@@ -481,7 +482,7 @@ public void addDateFormatFromReader(Reader r)
481
482
482
483
// match log with regex and capture results
483
484
/**
484
- * Match the given <tt >log</tt > with the named regex.
485
+ * Match the given <var >log</var > with the named regex.
485
486
* And return the json representation of the matched element
486
487
*
487
488
* @param log : log to match
@@ -496,7 +497,7 @@ public String capture(String log)
496
497
}
497
498
498
499
/**
499
- * Match the given list of <tt >log</tt > with the named regex
500
+ * Match the given list of <var >log</var > with the named regex
500
501
* and return the list of json representation of the matched elements.
501
502
*
502
503
* @param logs : list of log
@@ -521,7 +522,7 @@ public List<String> captures(List<String> logs)
521
522
}
522
523
523
524
/**
524
- * Match the given <tt >text</tt > with the named regex
525
+ * Match the given <var >text</var > with the named regex
525
526
* {@code Grok} will extract data from the string and get an extence of {@link Match}.
526
527
*
527
528
* @param text : Single line of log
@@ -593,7 +594,7 @@ public void compile(String pattern, boolean namedOnly)
593
594
// Match %{Foo=regex} -> add new regex definition
594
595
if (m .find ()) {
595
596
continueIteration = true ;
596
- Map <String , String > group = GrokUtils .namedGroups (m , m .group ()); // AMZN - probably don't need this tag since it's going into OSS Trino
597
+ Map <String , String > group = GrokUtils .namedGroups (m , m .group ());
597
598
if (group .get ("definition" ) != null ) {
598
599
try {
599
600
addPattern (group .get ("pattern" ), group .get ("definition" ));
@@ -692,9 +693,9 @@ public String getSaved_pattern()
692
693
return savedPattern ;
693
694
}
694
695
695
- public void setSaved_pattern (String savedpattern )
696
+ public void setSaved_pattern (String savedPattern )
696
697
{
697
- this .savedPattern = savedpattern ;
698
+ this .savedPattern = savedPattern ;
698
699
}
699
700
700
701
public boolean getStrictMode ()
0 commit comments