Skip to content

Commit 387d2d0

Browse files
committed
improve logging, javadoc, style
1 parent cd07f50 commit 387d2d0

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/AnalyzerGuru.java

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2021, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis;
@@ -125,9 +125,9 @@
125125
* Manages and provides Analyzers as needed. Please see
126126
* <a href="https://github.com/oracle/opengrok/wiki/Internals">
127127
* this</a> page for a great description of the purpose of the AnalyzerGuru.
128-
*
128+
* <p>
129129
* Created on September 22, 2005
130-
*
130+
* </p>
131131
* @author Chandan
132132
*/
133133
public class AnalyzerGuru {
@@ -550,9 +550,8 @@ public static AbstractAnalyzer getAnalyzer(InputStream in, String file) throws I
550550
if (factory == null) {
551551
AbstractAnalyzer defaultAnalyzer = getAnalyzer();
552552
if (LOGGER.isLoggable(Level.FINEST)) {
553-
LOGGER.log(Level.FINEST, "{0}: fallback {1}",
554-
new Object[]{file,
555-
defaultAnalyzer.getClass().getSimpleName() });
553+
LOGGER.log(Level.FINEST, "''{0}'': fallback {1}",
554+
new Object[]{file, defaultAnalyzer.getClass().getSimpleName()});
556555
}
557556
return defaultAnalyzer;
558557
}
@@ -849,8 +848,7 @@ public static Class<?> getFactoryClass(String simpleName) {
849848
* @param factoryClass the factory class
850849
* @return a file analyzer factory
851850
*
852-
* @throws ClassCastException if the class is not a subclass of {@code
853-
* FileAnalyzerFactory}
851+
* @throws ClassCastException if the class is not a subclass of {@code FileAnalyzerFactory}
854852
* @throws IllegalAccessException if the constructor cannot be accessed
855853
* @throws InstantiationException if the class cannot be instantiated
856854
* @throws NoSuchMethodException if no-argument constructor could not be found
@@ -871,7 +869,7 @@ private static AnalyzerFactory findFactory(Class<?> factoryClass)
871869
/**
872870
* Finds a suitable analyzer class for file name. If the analyzer cannot be
873871
* determined by the file extension, try to look at the data in the
874-
* InputStream to find a suitable analyzer.
872+
* {@link InputStream} to find a suitable analyzer.
875873
* <p>
876874
* Use if you just want to find file type.
877875
* </p>
@@ -914,9 +912,8 @@ public static AnalyzerFactory find(String file) {
914912
factory = pre.get(path.substring(0, dotpos).toUpperCase(Locale.ROOT));
915913
if (factory != null) {
916914
if (LOGGER.isLoggable(Level.FINEST)) {
917-
LOGGER.log(Level.FINEST, "{0}: chosen by prefix: {1}",
918-
new Object[]{file,
919-
factory.getClass().getSimpleName() });
915+
LOGGER.log(Level.FINEST, "''{0}'': chosen by prefix: {1}",
916+
new Object[]{file, factory.getClass().getSimpleName()});
920917
}
921918
return factory;
922919
}
@@ -928,9 +925,8 @@ public static AnalyzerFactory find(String file) {
928925
factory = ext.get(path.substring(dotpos + 1).toUpperCase(Locale.ROOT));
929926
if (factory != null) {
930927
if (LOGGER.isLoggable(Level.FINEST)) {
931-
LOGGER.log(Level.FINEST, "{0}: chosen by suffix: {1}",
932-
new Object[]{file,
933-
factory.getClass().getSimpleName() });
928+
LOGGER.log(Level.FINEST, "''{0}'': chosen by suffix: {1}",
929+
new Object[]{file, factory.getClass().getSimpleName()});
934930
}
935931
return factory;
936932
}
@@ -959,8 +955,7 @@ public static AnalyzerFactory find(InputStream in) throws IOException {
959955
* @param in The stream containing the data to analyze
960956
* @param file The file name to get the analyzer for
961957
* @return the analyzer factory to use
962-
* @throws java.io.IOException if an error occurs while reading data from
963-
* the stream
958+
* @throws java.io.IOException if an error occurs while reading data from the stream
964959
*/
965960
private static AnalyzerFactory findForStream(InputStream in,
966961
String file) throws IOException {
@@ -989,8 +984,8 @@ private static AnalyzerFactory findForStream(InputStream in,
989984
if (fac != null) {
990985
if (LOGGER.isLoggable(Level.FINEST)) {
991986
LOGGER.log(Level.FINEST,
992-
"{0}: chosen by precise magic: {1}", new Object[]{
993-
file, fac.getClass().getSimpleName() });
987+
"{0}: chosen by precise magic: {1}",
988+
new Object[]{file, fac.getClass().getSimpleName()});
994989
}
995990
return fac;
996991
}
@@ -1011,9 +1006,8 @@ private static AnalyzerFactory findForStream(InputStream in,
10111006
if (fac != null) {
10121007
if (LOGGER.isLoggable(Level.FINEST)) {
10131008
LOGGER.log(Level.FINEST,
1014-
"{0}: chosen by imprecise magic: {1}",
1015-
new Object[]{file,
1016-
fac.getClass().getSimpleName() });
1009+
"''{0}'': chosen by imprecise magic: {1}",
1010+
new Object[]{file, fac.getClass().getSimpleName()});
10171011
}
10181012
return fac;
10191013
}
@@ -1030,9 +1024,8 @@ private static AnalyzerFactory findMagicString(String opening, String file) {
10301024
AnalyzerFactory fac = magics.get(fragment);
10311025
if (fac != null) {
10321026
if (LOGGER.isLoggable(Level.FINEST)) {
1033-
LOGGER.log(Level.FINEST, "{0}: chosen by magic {2}: {1}",
1034-
new Object[]{file, fac.getClass().getSimpleName(),
1035-
fragment});
1027+
LOGGER.log(Level.FINEST, "''{0}'': chosen by magic {2}: {1}",
1028+
new Object[]{file, fac.getClass().getSimpleName(), fragment});
10361029
}
10371030
return fac;
10381031
}
@@ -1042,9 +1035,8 @@ private static AnalyzerFactory findMagicString(String opening, String file) {
10421035
fac = magics.get(fragment);
10431036
if (fac != null) {
10441037
if (LOGGER.isLoggable(Level.FINEST)) {
1045-
LOGGER.log(Level.FINEST, "{0}: chosen by magic {2}: {1}",
1046-
new Object[]{file, fac.getClass().getSimpleName(),
1047-
fragment});
1038+
LOGGER.log(Level.FINEST, "''{0}'': chosen by magic {2}: {1}",
1039+
new Object[]{file, fac.getClass().getSimpleName(), fragment});
10481040
}
10491041
return fac;
10501042
}
@@ -1057,8 +1049,8 @@ private static AnalyzerFactory findMagicString(String opening, String file) {
10571049
fac = entry.getValue();
10581050
if (LOGGER.isLoggable(Level.FINEST)) {
10591051
LOGGER.log(Level.FINEST,
1060-
"{0}: chosen by magic(substr) {2}: {1}", new Object[]{
1061-
file, fac.getClass().getSimpleName(), magic});
1052+
"''{0}'': chosen by magic(substr) {2}: {1}",
1053+
new Object[]{file, fac.getClass().getSimpleName(), magic});
10621054
}
10631055
return fac;
10641056
}

0 commit comments

Comments
 (0)