| 1 | package pro.verron.officestamper; | |
| 2 | ||
| 3 | import pro.verron.officestamper.api.OfficeStamperException; | |
| 4 | ||
| 5 | import java.io.InputStream; | |
| 6 | import java.util.Locale; | |
| 7 | import java.util.logging.Level; | |
| 8 | import java.util.logging.Logger; | |
| 9 | ||
| 10 | import static java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE; | |
| 11 | ||
| 12 | /// Utility class for the CLI. | |
| 13 | public class Utils { | |
| 14 | ||
| 15 | /// Logging format property key. | |
| 16 | public static final String LOGGING_FORMAT_KEY = "java.util.logging.SimpleFormatter.format"; | |
| 17 | /// Logging format property value. | |
| 18 | public static final String LOGGING_FORMAT_VAL = "[%1$tl:%1$tM:%1$tS] %2$s %4$-7s: %5$s %6$s %n"; | |
| 19 | ||
| 20 | static { | |
| 21 | Locale.setDefault(Locale.ROOT); | |
| 22 | System.setProperty(LOGGING_FORMAT_KEY, LOGGING_FORMAT_VAL); | |
| 23 | Logger.getLogger("org.docx4j") | |
| 24 | .setLevel(Level.SEVERE); | |
| 25 | } | |
| 26 | ||
| 27 | private Utils() { | |
| 28 | throw new OfficeStamperException("Utility class"); | |
| 29 | } | |
| 30 | ||
| 31 | /// Returns a logger for the caller class. | |
| 32 | /// | |
| 33 | /// @return a logger | |
| 34 | public static Logger getLogger() { | |
| 35 | var callerName = StackWalker | |
| 36 | .getInstance(RETAIN_CLASS_REFERENCE) | |
| 37 | .getCallerClass() | |
| 38 | .getTypeName(); | |
| 39 | return Logger.getLogger(callerName); | |
| 40 | } | |
| 41 | ||
| 42 | static InputStream streamResource(String name) { | |
| 43 |
1
1. streamResource : replaced return value with null for pro/verron/officestamper/Utils::streamResource → NO_COVERAGE |
return StackWalker |
| 44 | .getInstance(RETAIN_CLASS_REFERENCE) | |
| 45 | .getCallerClass() | |
| 46 | .getResourceAsStream(name); | |
| 47 | } | |
| 48 | ||
| 49 | } | |
Mutations | ||
| 43 |
1.1 |