@@ -70,7 +73,7 @@ public class Property {
*/
public static final int DEFAULT_CODEPAGE = CodePageUtil.CP_WINDOWS_1252;
- private static final POILogger LOG = POILogFactory.getLogger(Property.class);
+ private static final Logger LOG = LogManager.getLogger(Property.class);
/** The property's ID. */
private long id;
@@ -293,7 +296,7 @@ public class Property {
* section's dictionary. Another special case are strings: Two properties
* may have the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;
*
- * @see Object#equals(java.lang.Object)
+ * @see Object#equals(Object)
*/
@Override
public boolean equals(final Object o) {
@@ -412,7 +415,7 @@ public class Property {
try {
write(bos, codepage);
} catch (Exception e) {
- LOG.log(POILogger.WARN, "can't serialize string", e);
+ LOG.atWarn().withThrowable(e).log("can't serialize string");
}
// skip length field
@@ -427,8 +430,8 @@ public class Property {
String hex = HexDump.dump(bytes, 0L, 0);
b.append(hex);
}
- } else if (value instanceof java.util.Date) {
- java.util.Date d = (java.util.Date)value;
+ } else if (value instanceof Date) {
+ Date d = (Date)value;
long filetime = Filetime.dateToFileTime(d);
if (Filetime.isUndefined(d)) {
b.append("
@@ -58,7 +58,7 @@ public class VariantSupport extends Variant {
Variant.VT_CF, Variant.VT_BOOL };
- private static final POILogger LOG = POILogFactory.getLogger(VariantSupport.class);
+ private static final Logger LOG = LogManager.getLogger(VariantSupport.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
@@ -114,7 +114,7 @@ public class VariantSupport extends Variant {
Long vt = Long.valueOf(ex.getVariantType());
if (!unsupportedMessage.contains(vt))
{
- LOG.log( POILogger.ERROR, ex.getMessage());
+ LOG.atError().withThrowable(ex).log("Unsupported type");
unsupportedMessage.add(vt);
}
}
diff --git a/src/java/org/apache/poi/hssf/dev/BiffViewer.java b/src/java/org/apache/poi/hssf/dev/BiffViewer.java
index 998df2fa7b..4adbedad61 100644
--- a/src/java/org/apache/poi/hssf/dev/BiffViewer.java
+++ b/src/java/org/apache/poi/hssf/dev/BiffViewer.java
@@ -31,6 +31,8 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.RecordInputStream.LeftoverDataException;
import org.apache.poi.hssf.record.chart.*;
@@ -46,18 +48,19 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.poi.util.RecordFormatException;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.SuppressForbidden;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Utility for reading in BIFF8 records and displaying data from them.
* @see #main
*/
public final class BiffViewer {
private static final char[] NEW_LINE_CHARS = System.getProperty("line.separator").toCharArray();
- private static final POILogger LOG = POILogFactory.getLogger(BiffViewer.class);
+ private static final Logger LOG = LogManager.getLogger(BiffViewer.class);
private BiffViewer() {
// no instances of this class
@@ -71,17 +74,17 @@ public final class BiffViewer {
* @param recListener the record listener to notify about read records
* @param dumpInterpretedRecords if {@code true}, the read records will be written to the PrintWriter
*
- * @exception org.apache.poi.util.RecordFormatException on error processing the InputStream
+ * @exception RecordFormatException on error processing the InputStream
*/
private static void createRecords(InputStream is, PrintWriter ps, BiffRecordListener recListener, boolean dumpInterpretedRecords)
- throws org.apache.poi.util.RecordFormatException {
+ throws RecordFormatException {
RecordInputStream recStream = new RecordInputStream(is);
while (true) {
boolean hasNext;
try {
hasNext = recStream.hasNextRecord();
} catch (LeftoverDataException e) {
- LOG.log(POILogger.ERROR, "Discarding ", recStream.remaining(), " bytes and continuing", e);
+ LOG.atError().withThrowable(e).log("Discarding {} bytes and continuing", box(recStream.remaining()));
recStream.readRemainder();
hasNext = recStream.hasNextRecord();
}
@@ -92,7 +95,7 @@ public final class BiffViewer {
if (recStream.getSid() == 0) {
continue;
}
- org.apache.poi.hssf.record.Record record;
+ Record record;
if (dumpInterpretedRecords) {
record = createRecord (recStream);
if (record.getSid() == ContinueRecord.sid) {
@@ -116,7 +119,7 @@ public final class BiffViewer {
* up non-debug operations.
*
*/
- private static org.apache.poi.hssf.record.Record createRecord(RecordInputStream in) {
+ private static Record createRecord(RecordInputStream in) {
switch (in.getSid()) {
case AreaFormatRecord.sid: return new AreaFormatRecord(in);
case AreaRecord.sid: return new AreaRecord(in);
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java b/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
index 16c7bdfb1a..fcd4cdd2a3 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
@@ -23,16 +23,19 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.FormatRecord;
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.NumberRecord;
+import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* A proxy HSSFListener that keeps track of the document formatting records, and
@@ -40,7 +43,7 @@ import org.apache.poi.util.POILogger;
* ids.
*/
public class FormatTrackingHSSFListener implements HSSFListener {
- private static final POILogger LOG = POILogFactory.getLogger(FormatTrackingHSSFListener.class);
+ private static final Logger LOG = LogManager.getLogger(FormatTrackingHSSFListener.class);
private final HSSFListener _childListener;
private final HSSFDataFormatter _formatter;
private final NumberFormat _defaultFormat;
@@ -83,7 +86,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
* Process this record ourselves, and then pass it on to our child listener
*/
@Override
- public void processRecord(org.apache.poi.hssf.record.Record record) {
+ public void processRecord(Record record) {
// Handle it ourselves
processRecordInternally(record);
@@ -97,7 +100,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
*
* @param record the record to be processed
*/
- public void processRecordInternally(org.apache.poi.hssf.record.Record record) {
+ public void processRecordInternally(Record record) {
if (record instanceof FormatRecord) {
FormatRecord fr = (FormatRecord) record;
_customFormatRecords.put(Integer.valueOf(fr.getIndexCode()), fr);
@@ -154,8 +157,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
FormatRecord tfr = _customFormatRecords.get(Integer.valueOf(formatIndex));
if (tfr == null) {
- LOG.log( POILogger.ERROR, "Requested format at index ", formatIndex,
- ", but it wasn't found");
+ LOG.atError().log("Requested format at index {}, but it wasn't found", box(formatIndex));
} else {
format = tfr.getFormatString();
}
@@ -191,8 +193,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
public int getFormatIndex(CellValueRecordInterface cell) {
ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());
if (xfr == null) {
- LOG.log( POILogger.ERROR, "Cell ", cell.getRow(), ",", cell.getColumn(),
- " uses XF with index ", cell.getXFIndex(), ", but we don't have that");
+ LOG.atError().log("Cell {},{} uses XF with index {}, but we don't have that", box(cell.getRow()),box(cell.getColumn()),box(cell.getXFIndex()));
return -1;
}
return xfr.getFormatIndex();
diff --git a/src/java/org/apache/poi/hssf/model/InternalSheet.java b/src/java/org/apache/poi/hssf/model/InternalSheet.java
index c28dbee408..efba5e75c5 100644
--- a/src/java/org/apache/poi/hssf/model/InternalSheet.java
+++ b/src/java/org/apache/poi/hssf/model/InternalSheet.java
@@ -21,6 +21,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.ChartSubstreamRecordAggregate;
import org.apache.poi.hssf.record.aggregates.ColumnInfoRecordsAggregate;
@@ -34,14 +37,15 @@ import org.apache.poi.hssf.record.aggregates.RecordAggregate.PositionTrackingVis
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.formula.FormulaShifter;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.PaneInformation;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.RecordFormatException;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Low level model implementation of a Sheet (one workbook contains many sheets)
* This file contains the low level binary records starting at the sheets BOF and
@@ -53,8 +57,8 @@ import org.apache.poi.util.RecordFormatException;
* Kit (Microsoft Press) and the documentation at http://sc.openoffice.org/excelfileformat.pdf
* before even attempting to use this.
*
- * @see org.apache.poi.hssf.model.InternalWorkbook
- * @see org.apache.poi.hssf.usermodel.HSSFSheet
+ * @see InternalWorkbook
+ * @see HSSFSheet
*/
@Internal
public final class InternalSheet {
@@ -63,7 +67,7 @@ public final class InternalSheet {
public static final short TopMargin = 2;
public static final short BottomMargin = 3;
- private static POILogger log = POILogFactory.getLogger(InternalSheet.class);
+ private static final Logger LOGGER = LogManager.getLogger(InternalSheet.class);
private List
* A sub-record within the OBJ record which stores a reference to an object
* stored in a separate entry within the OLE2 compound file.
*/
public final class EmbeddedObjectRefSubRecord extends SubRecord {
- private static final POILogger LOG = POILogFactory.getLogger(EmbeddedObjectRefSubRecord.class);
+ private static final Logger LOG = LogManager.getLogger(EmbeddedObjectRefSubRecord.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
@@ -157,7 +159,7 @@ public final class EmbeddedObjectRefSubRecord extends SubRecord {
int nUnexpectedPadding = remaining - dataLenAfterFormula;
if (nUnexpectedPadding > 0) {
- LOG.log( POILogger.ERROR, "Discarding ", nUnexpectedPadding, " unexpected padding bytes");
+ LOG.atError().log("Discarding {} unexpected padding bytes", box(nUnexpectedPadding));
readRawData(in, nUnexpectedPadding);
remaining-=nUnexpectedPadding;
}
diff --git a/src/java/org/apache/poi/hssf/record/FeatRecord.java b/src/java/org/apache/poi/hssf/record/FeatRecord.java
index 22a3e8988d..f5850bfefa 100644
--- a/src/java/org/apache/poi/hssf/record/FeatRecord.java
+++ b/src/java/org/apache/poi/hssf/record/FeatRecord.java
@@ -21,6 +21,8 @@ import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Stream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.record.common.FeatFormulaErr2;
import org.apache.poi.hssf.record.common.FeatProtection;
import org.apache.poi.hssf.record.common.FeatSmartTag;
@@ -29,8 +31,8 @@ import org.apache.poi.hssf.record.common.SharedFeature;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndianOutput;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* Title: Feat (Feature) Record
@@ -39,8 +41,8 @@ import org.apache.poi.util.POILogger;
* up with a {@link FeatHdrRecord}.
*/
public final class FeatRecord extends StandardRecord {
- private static final POILogger LOG = POILogFactory.getLogger(FeatRecord.class);
- public static final short sid = 0x0868;
+ private static final Logger LOG = LogManager.getLogger(FeatRecord.class);
+ public static final short sid = 0x0868;
// SIDs from newer versions
public static final short v11_sid = 0x0872;
public static final short v12_sid = 0x0878;
@@ -108,7 +110,7 @@ public final class FeatRecord extends StandardRecord {
sharedFeature = new FeatSmartTag(in);
break;
default:
- LOG.log( POILogger.ERROR, "Unknown Shared Feature ", isf_sharedFeatureType, " found!");
+ LOG.atError().log("Unknown Shared Feature {} found!", box(isf_sharedFeatureType));
}
}
diff --git a/src/java/org/apache/poi/hssf/record/FormatRecord.java b/src/java/org/apache/poi/hssf/record/FormatRecord.java
index 24063ff93d..7b2714bc77 100644
--- a/src/java/org/apache/poi/hssf/record/FormatRecord.java
+++ b/src/java/org/apache/poi/hssf/record/FormatRecord.java
@@ -21,19 +21,22 @@ import java.util.Arrays;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianOutput;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Describes a number format -- those goofy strings like $(#,###)
*/
public final class FormatRecord extends StandardRecord {
- private static final POILogger LOG = POILogFactory.getLogger(FormatRecord.class);
+ private static final Logger LOG = LogManager.getLogger(FormatRecord.class);
public static final short sid = 0x041E;
@@ -70,7 +73,7 @@ public final class FormatRecord extends StandardRecord {
* get the format index code (for built in formats)
*
* @return the format index code
- * @see org.apache.poi.hssf.model.InternalWorkbook
+ * @see InternalWorkbook
*/
public int getIndexCode() {
return field_1_index_code;
@@ -149,7 +152,7 @@ public final class FormatRecord extends StandardRecord {
}
if (ris.available() > 0) {
- LOG.log(POILogger.INFO, "FormatRecord has ", ris.available(), " unexplained bytes. Silently skipping");
+ LOG.atInfo().log("FormatRecord has {} unexplained bytes. Silently skipping", box(ris.available()));
//swallow what's left
while (ris.available() > 0) {
ris.readByte();
diff --git a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
index 1c24d0023a..78bda25262 100644
--- a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
+++ b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
@@ -17,24 +17,26 @@
package org.apache.poi.hssf.record;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.apache.poi.hpsf.ClassIDPredefined.FILE_MONIKER;
import static org.apache.poi.hpsf.ClassIDPredefined.STD_MONIKER;
import static org.apache.poi.hpsf.ClassIDPredefined.URL_MONIKER;
import static org.apache.poi.util.GenericRecordUtil.getBitsAsString;
+import static org.apache.poi.util.HexDump.toHex;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hpsf.ClassID;
+import org.apache.poi.hpsf.ClassIDPredefined;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.GenericRecordUtil;
-import org.apache.poi.util.HexDump;
import org.apache.poi.util.HexRead;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.RecordFormatException;
import org.apache.poi.util.StringUtil;
@@ -45,7 +47,7 @@ import org.apache.poi.util.StringUtil;
*/
public final class HyperlinkRecord extends StandardRecord {
public static final short sid = 0x01B8;
- private static final POILogger LOG = POILogFactory.getLogger(HyperlinkRecord.class);
+ private static final Logger LOG = LogManager.getLogger(HyperlinkRecord.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
@@ -184,7 +186,7 @@ public final class HyperlinkRecord extends StandardRecord {
}
/**
- * @return 16-byte guid identifier Seems to always equal {@link org.apache.poi.hpsf.ClassIDPredefined#STD_MONIKER}
+ * @return 16-byte guid identifier Seems to always equal {@link ClassIDPredefined#STD_MONIKER}
*/
ClassID getGuid() {
return _guid;
@@ -403,10 +405,7 @@ public final class HyperlinkRecord extends StandardRecord {
}
if (in.remaining() > 0) {
- LOG.log(POILogger.WARN,
- "Hyperlink data remains: " + in.remaining() +
- " : " +HexDump.toHex(in.readRemainder())
- );
+ LOG.atWarn().log("Hyperlink data remains: {} : {}", box(in.remaining()), toHex(in.readRemainder()));
}
}
diff --git a/src/java/org/apache/poi/hssf/record/LabelRecord.java b/src/java/org/apache/poi/hssf/record/LabelRecord.java
index f3ac972d09..b21286085e 100644
--- a/src/java/org/apache/poi/hssf/record/LabelRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LabelRecord.java
@@ -20,20 +20,22 @@ package org.apache.poi.hssf.record;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.GenericRecordUtil;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.RecordFormatException;
+import static org.apache.logging.log4j.util.Unbox.box;
+import static org.apache.poi.util.HexDump.toHex;
+
/**
* Label Record (0x0204) - read only support for strings stored directly in the cell...
* Don't use this (except to read), use LabelSST instead
*
- * @see org.apache.poi.hssf.record.LabelSSTRecord
+ * @see LabelSSTRecord
*/
public final class LabelRecord extends Record implements CellValueRecordInterface {
- private static final POILogger LOG = POILogFactory.getLogger(LabelRecord.class);
+ private static final Logger LOG = LogManager.getLogger(LabelRecord.class);
public static final short sid = 0x0204;
@@ -77,10 +79,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
}
if (in.remaining() > 0) {
- LOG.log(POILogger.INFO,
- "LabelRecord data remains: ", in.remaining(),
- " : ", HexDump.toHex(in.readRemainder())
- );
+ LOG.atInfo().log("LabelRecord data remains: {} : {}", box(in.remaining()), toHex(in.readRemainder()));
}
}
diff --git a/src/java/org/apache/poi/hssf/record/OldLabelRecord.java b/src/java/org/apache/poi/hssf/record/OldLabelRecord.java
index dd59ca258f..e393c8e3d8 100644
--- a/src/java/org/apache/poi/hssf/record/OldLabelRecord.java
+++ b/src/java/org/apache/poi/hssf/record/OldLabelRecord.java
@@ -20,20 +20,22 @@ package org.apache.poi.hssf.record;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.GenericRecordUtil;
-import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.RecordFormatException;
+import static org.apache.logging.log4j.util.Unbox.box;
+import static org.apache.poi.util.HexDump.toHex;
+
/**
* Biff2 - Biff 4 Label Record (0x0004 / 0x0204) - read only support for
* strings stored directly in the cell, from the older file formats that
* didn't use {@link LabelSSTRecord}
*/
public final class OldLabelRecord extends OldCellRecord {
- private static final POILogger LOG = POILogFactory.getLogger(OldLabelRecord.class);
+ private static final Logger LOG = LogManager.getLogger(OldLabelRecord.class);
//arbitrarily set, may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
@@ -62,10 +64,7 @@ public final class OldLabelRecord extends OldCellRecord {
in.read(field_5_bytes, 0, field_4_string_len);
if (in.remaining() > 0) {
- LOG.log(POILogger.INFO,
- "LabelRecord data remains: ", in.remaining(),
- " : ", HexDump.toHex(in.readRemainder())
- );
+ LOG.atInfo().log("LabelRecord data remains: {} : {}", box(in.remaining()), toHex(in.readRemainder()));
}
}
diff --git a/src/java/org/apache/poi/hssf/record/SSTDeserializer.java b/src/java/org/apache/poi/hssf/record/SSTDeserializer.java
index bcd6452c25..6b3bce351d 100644
--- a/src/java/org/apache/poi/hssf/record/SSTDeserializer.java
+++ b/src/java/org/apache/poi/hssf/record/SSTDeserializer.java
@@ -19,10 +19,12 @@
package org.apache.poi.hssf.record;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.record.common.UnicodeString;
import org.apache.poi.util.IntMapper;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* Handles the task of deserializing a SST string. The two main entry points are
@@ -32,7 +34,7 @@ import org.apache.poi.util.POILogger;
*/
class SSTDeserializer
{
- private static final POILogger LOG = POILogFactory.getLogger(SSTDeserializer.class);
+ private static final Logger LOG = LogManager.getLogger(SSTDeserializer.class);
private IntMapper CFRecordsAggregate - aggregates Conditional Formatting records CFHeaderRecord
* and number of up CFRuleRecord records together to simplify access to them.
*/
public class UnicodeString implements Comparable
*
- * Calculating the formula values with {@link org.apache.poi.ss.usermodel.FormulaEvaluator} is the
+ * Calculating the formula values with {@link FormulaEvaluator} is the
* recommended solution, but this may be used for certain cases where
* evaluation in POI is not possible.
*
* It is recommended to force recalcuation of formulas on workbook level using
- * {@link org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)}
+ * {@link Workbook#setForceFormulaRecalculation(boolean)}
* to ensure that all cross-worksheet formuals and external dependencies are updated.
*
* @param value true if the application will perform a full recalculation of
* this worksheet values when the workbook is opened
- * @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
+ * @see Workbook#setForceFormulaRecalculation(boolean)
*/
@Override
public void setForceFormulaRecalculation(boolean value) {
@@ -1773,7 +1770,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
// add logic for hyperlinks etc, like in shiftRows()
}
- protected void insertChartRecords(List
- * If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive
+ * If {@code stream} is a {@link FileOutputStream} on a networked drive
* or has a high cost/latency associated with each written byte,
- * consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream}
+ * consider wrapping the OutputStream in a {@link BufferedOutputStream}
* to improve write performance.
*
* @param stream - the java OutputStream you wish to write the XLS to
* @throws IOException if anything can't be written.
- * @see org.apache.poi.poifs.filesystem.POIFSFileSystem
+ * @see POIFSFileSystem
*/
@Override
public void write(OutputStream stream) throws IOException {
@@ -1405,7 +1408,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
*/
private static final class SheetRecordCollector implements RecordVisitor {
- private List This is the main class of the POIFS system; it manages the entire
@@ -63,7 +63,7 @@ public class POIFSFileSystem extends BlockStore
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
- private static final POILogger LOG = POILogFactory.getLogger(POIFSFileSystem.class);
+ private static final Logger LOG = LogManager.getLogger(POIFSFileSystem.class);
/**
* Maximum number size (in blocks) of the allocation table as supported by
@@ -327,7 +327,7 @@ public class POIFSFileSystem extends BlockStore
}
// else not success? Try block did not complete normally
// just print stack trace and leave original ex to be thrown
- LOG.log(POILogger.ERROR, "can't close input stream", e);
+ LOG.atError().withThrowable(e).log("can't close input stream");
}
}
diff --git a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
index 624a5fd360..2f28c6397e 100644
--- a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
+++ b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
@@ -17,6 +17,7 @@
package org.apache.poi.poifs.macros;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.apache.poi.util.StringUtil.endsWithIgnoreCase;
import static org.apache.poi.util.StringUtil.startsWithIgnoreCase;
@@ -37,6 +38,8 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.DocumentNode;
@@ -49,8 +52,6 @@ import org.apache.poi.util.CodePageUtil;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.RLEDecompressingInputStream;
import org.apache.poi.util.StringUtil;
@@ -68,7 +69,7 @@ import org.apache.poi.util.StringUtil;
* @since 3.15-beta2
*/
public class VBAMacroReader implements Closeable {
- private static final POILogger LOGGER = POILogFactory.getLogger(VBAMacroReader.class);
+ private static final Logger LOGGER = LogManager.getLogger(VBAMacroReader.class);
//arbitrary limit on size of strings to read, etc.
private static final int MAX_STRING_LENGTH = 20000;
@@ -663,9 +664,7 @@ public class VBAMacroReader implements Closeable {
}
}
- if (records >= maxNameRecords) {
- LOGGER.log(POILogger.WARN, "Hit max name records to read ("+maxNameRecords+"). Stopped early.");
- }
+ LOGGER.atWarn().log("Hit max name records to read (" + maxNameRecords + "). Stopped early.");
}
private static String readUnicode(InputStream is, int maxLength) throws IOException {
@@ -684,7 +683,7 @@ public class VBAMacroReader implements Closeable {
read += 2;
}
if (read >= maxLength) {
- LOGGER.log(POILogger.WARN, "stopped reading unicode name after "+read+" bytes");
+ LOGGER.atWarn().log("stopped reading unicode name after {} bytes", box(read));
}
return new String (bos.toByteArray(), StandardCharsets.UTF_16LE);
}
@@ -747,21 +746,21 @@ public class VBAMacroReader implements Closeable {
if (module != null) {
module.moduleType = ModuleType.Document;
} else {
- LOGGER.log(POILogger.WARN, "couldn't find module with name: "+mn);
+ LOGGER.atWarn().log("couldn't find module with name: {}", mn);
}
} else if ("Module".equals(tokens[0]) && tokens.length > 1) {
ModuleImpl module = getModule(tokens[1], moduleNameMap, modules);
if (module != null) {
module.moduleType = ModuleType.Module;
} else {
- LOGGER.log(POILogger.WARN, "couldn't find module with name: "+tokens[1]);
+ LOGGER.atWarn().log("couldn't find module with name: {}", tokens[1]);
}
} else if ("Class".equals(tokens[0]) && tokens.length > 1) {
ModuleImpl module = getModule(tokens[1], moduleNameMap, modules);
if (module != null) {
module.moduleType = ModuleType.Class;
} else {
- LOGGER.log(POILogger.WARN, "couldn't find module with name: "+tokens[1]);
+ LOGGER.atWarn().log("couldn't find module with name: {}", tokens[1]);
}
}
}
diff --git a/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java b/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java
index d74eb9d2b8..e3001f238f 100644
--- a/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java
+++ b/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java
@@ -29,15 +29,15 @@ import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;
import java.util.IdentityHashMap;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* A POIFS {@link DataSource} backed by a File
*/
public class FileBackedDataSource extends DataSource implements Closeable {
- private static final POILogger LOG = POILogFactory.getLogger(FileBackedDataSource.class);
+ private static final Logger LOG = LogManager.getLogger(FileBackedDataSource.class);
private final FileChannel channel;
private Long channelSize;
@@ -195,10 +195,10 @@ public class FileBackedDataSource extends DataSource implements Closeable {
try {
CleanerUtil.getCleaner().freeBuffer(buffer);
} catch (IOException e) {
- LOG.log(POILogger.WARN, "Failed to unmap the buffer", e);
+ LOG.atWarn().withThrowable(e).log("Failed to unmap the buffer");
}
} else {
- LOG.log(POILogger.DEBUG, CleanerUtil.UNMAP_NOT_SUPPORTED_REASON);
+ LOG.atDebug().log(CleanerUtil.UNMAP_NOT_SUPPORTED_REASON);
}
}
}
diff --git a/src/java/org/apache/poi/poifs/property/PropertyTable.java b/src/java/org/apache/poi/poifs/property/PropertyTable.java
index e1f663cea6..596bea5070 100644
--- a/src/java/org/apache/poi/poifs/property/PropertyTable.java
+++ b/src/java/org/apache/poi/poifs/property/PropertyTable.java
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.poifs.common.POIFSBigBlockSize;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.poifs.filesystem.BATManaged;
@@ -31,8 +33,8 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSStream;
import org.apache.poi.poifs.storage.HeaderBlock;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* This class embodies the Property Table for a {@link POIFSFileSystem};
@@ -41,7 +43,7 @@ import org.apache.poi.util.POILogger;
* chain of blocks.
*/
public final class PropertyTable implements BATManaged {
- private static final POILogger LOG = POILogFactory.getLogger(PropertyTable.class);
+ private static final Logger LOG = LogManager.getLogger(PropertyTable.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
@@ -96,8 +98,7 @@ public final class PropertyTable implements BATManaged {
// Looks to be a truncated block
// This isn't allowed, but some third party created files
// sometimes do this, and we can normally read anyway
- LOG.log(POILogger.WARN, "Short Property Block, ", bb.remaining(),
- " bytes instead of the expected " + _bigBigBlockSize.getBigBlockSize());
+ LOG.atWarn().log("Short Property Block, {} bytes instead of the expected {}", box(bb.remaining()),box(_bigBigBlockSize.getBigBlockSize()));
toRead = bb.remaining();
}
@@ -247,8 +248,7 @@ public final class PropertyTable implements BATManaged {
if (! Property.isValidIndex(index))
return false;
if (index < 0 || index >= _properties.size()) {
- LOG.log(POILogger.WARN, "Property index " + index +
- "outside the valid range 0.."+_properties.size());
+ LOG.atWarn().log("Property index {} outside the valid range 0..{}", box(index),box(_properties.size()));
return false;
}
return true;
diff --git a/src/java/org/apache/poi/sl/draw/BitmapImageRenderer.java b/src/java/org/apache/poi/sl/draw/BitmapImageRenderer.java
index 21139719d9..96e63a6448 100644
--- a/src/java/org/apache/poi/sl/draw/BitmapImageRenderer.java
+++ b/src/java/org/apache/poi/sl/draw/BitmapImageRenderer.java
@@ -40,16 +40,16 @@ import javax.imageio.ImageTypeSpecifier;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* For now this class renders only images supported by the javax.imageio.ImageIO framework.
**/
public class BitmapImageRenderer implements ImageRenderer {
- private static final POILogger LOG = POILogFactory.getLogger(BitmapImageRenderer.class);
+ private static final Logger LOG = LogManager.getLogger(BitmapImageRenderer.class);
protected BufferedImage img;
@@ -200,7 +200,7 @@ public class BitmapImageRenderer implements ImageRenderer {
// multiple locations above ...
throw lastException;
}
- LOG.log(POILogger.WARN, "Content-type: "+contentType+" is not support. Image ignored.");
+ LOG.atWarn().log("Content-type: {} is not support. Image ignored.", contentType);
return null;
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawPaint.java b/src/java/org/apache/poi/sl/draw/DrawPaint.java
index 157c4103e9..e78dd2ee14 100644
--- a/src/java/org/apache/poi/sl/draw/DrawPaint.java
+++ b/src/java/org/apache/poi/sl/draw/DrawPaint.java
@@ -46,6 +46,8 @@ import java.util.TreeMap;
import java.util.function.BiFunction;
import java.util.stream.Stream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.sl.usermodel.AbstractColorStyle;
import org.apache.poi.sl.usermodel.ColorStyle;
import org.apache.poi.sl.usermodel.Insets2D;
@@ -57,8 +59,6 @@ import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
import org.apache.poi.sl.usermodel.PlaceableShape;
import org.apache.poi.util.Dimension2DDouble;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
@@ -69,7 +69,9 @@ import org.apache.poi.util.POILogger;
public class DrawPaint {
// HSL code is public domain - see https://tips4java.wordpress.com/contact-us/
- private static final POILogger LOG = POILogFactory.getLogger(DrawPaint.class);
+ // HSL code is public domain - see https://tips4java.wordpress.com/contact-us/
+
+ private static final Logger LOG = LogManager.getLogger(DrawPaint.class);
private static final Color TRANSPARENT = new Color(1f,1f,1f,0f);
@@ -286,7 +288,7 @@ public class DrawPaint {
BufferedImage image = renderer.getImage(imgDim);
if(image == null) {
- LOG.log(POILogger.ERROR, "Can't load image data");
+ LOG.atError().log("Can't load image data");
return TRANSPARENT;
}
@@ -336,7 +338,7 @@ public class DrawPaint {
// TODO: check why original bitmaps scale/behave differently to vector based images
return new DrawTexturePaint(image, s, fill, flipX, flipY, renderer instanceof BitmapImageRenderer);
} catch (IOException e) {
- LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e);
+ LOG.atError().withThrowable(e).log("Can't load image data - using transparent color");
return TRANSPARENT;
}
}
@@ -796,10 +798,10 @@ public class DrawPaint {
try {
graphics.fill(shape);
} catch (ArrayIndexOutOfBoundsException e) {
- LOG.log(POILogger.WARN, "IBM JDK failed with TexturePaintContext AIOOBE - try adding the following to the VM parameter:\n" +
+ LOG.atWarn().withThrowable(e).log("IBM JDK failed with TexturePaintContext AIOOBE - try adding the following to the VM parameter:\n" +
"-Xjit:exclude={sun/java2d/pipe/AlphaPaintPipe.renderPathTile(Ljava/lang/Object;[BIIIIII)V} and " +
"search for 'JIT Problem Determination for IBM SDK using -Xjit' (http://www-01.ibm.com/support/docview.wss?uid=swg21294023) " +
- "for how to add/determine further excludes", e);
+ "for how to add/determine further excludes");
}
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java
index 933211658a..71cb1bdd23 100644
--- a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java
@@ -27,17 +27,17 @@ import java.util.ServiceLoader;
import java.util.function.Supplier;
import java.util.stream.StreamSupport;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.PictureType;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.sl.usermodel.PictureShape;
import org.apache.poi.sl.usermodel.RectAlign;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
public class DrawPictureShape extends DrawSimpleShape {
- private static final POILogger LOG = POILogFactory.getLogger(DrawPictureShape.class);
+ private static final Logger LOG = LogManager.getLogger(DrawPictureShape.class);
public DrawPictureShape(PictureShape,?> shape) {
super(shape);
@@ -69,7 +69,7 @@ public class DrawPictureShape extends DrawSimpleShape {
return;
}
} catch (IOException e) {
- LOG.log(POILogger.ERROR, "image can't be loaded/rendered.", e);
+ LOG.atError().withThrowable(e).log("image can't be loaded/rendered.");
}
}
}
@@ -93,8 +93,8 @@ public class DrawPictureShape extends DrawSimpleShape {
// the fallback is the BitmapImageRenderer, at least it gracefully handles invalid images
final Supplier
*
@@ -27,8 +30,8 @@ import org.apache.poi.util.POILogger;
* ErrorEval.
*/
public final class ErrorConstant {
- private static final POILogger LOG = POILogFactory.getLogger(ErrorConstant.class);
- private static final ErrorConstant NULL = new ErrorConstant(FormulaError.NULL.getCode());
+ private static final Logger LOG = LogManager.getLogger(ErrorConstant.class);
+ private static final ErrorConstant NULL = new ErrorConstant(FormulaError.NULL.getCode());
private static final ErrorConstant DIV_0 = new ErrorConstant(FormulaError.DIV0.getCode());
private static final ErrorConstant VALUE = new ErrorConstant(FormulaError.VALUE.getCode());
private static final ErrorConstant REF = new ErrorConstant(FormulaError.REF.getCode());
@@ -66,7 +69,7 @@ public final class ErrorConstant {
default: break;
}
}
- LOG.log( POILogger.WARN, "Warning - unexpected error code (", errorCode, ")");
+ LOG.atWarn().log("Warning - unexpected error code ({})", box(errorCode));
return new ErrorConstant(errorCode);
}
diff --git a/src/java/org/apache/poi/ss/formula/functions/Rate.java b/src/java/org/apache/poi/ss/formula/functions/Rate.java
index 3b9de86dce..d0a840f6b7 100644
--- a/src/java/org/apache/poi/ss/formula/functions/Rate.java
+++ b/src/java/org/apache/poi/ss/formula/functions/Rate.java
@@ -17,20 +17,20 @@
package org.apache.poi.ss.formula.functions;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Implements the Excel Rate function
*/
public class Rate implements Function {
- private static final POILogger LOG = POILogFactory.getLogger(Rate.class);
-
+ private static final Logger LOG = LogManager.getLogger(Rate.class);
+
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
if (args.length < 3) { //First 3 parameters are mandatory
return ErrorEval.VALUE_INVALID;
@@ -65,7 +65,7 @@ public class Rate implements Function {
checkValue(rate);
} catch (EvaluationException e) {
- LOG.log(POILogger.ERROR, "Can't evaluate rate function", e);
+ LOG.atError().withThrowable(e).log("Can't evaluate rate function");
return e.getErrorEval();
}
diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
index a4c7e32637..78bbd79b55 100644
--- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
+++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
@@ -40,14 +40,14 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.format.CellFormat;
import org.apache.poi.ss.format.CellFormatResult;
import org.apache.poi.ss.formula.ConditionalFormattingEvaluator;
import org.apache.poi.ss.util.DateFormatConverter;
import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
@@ -58,7 +58,7 @@ import org.apache.poi.util.POILogger;
* codes, etc.
*
* Internally, formats will be implemented using subclasses of {@link Format}
- * such as {@link DecimalFormat} and {@link java.text.SimpleDateFormat}. Therefore the
+ * such as {@link DecimalFormat} and {@link SimpleDateFormat}. Therefore the
* formats used by this class must obey the same pattern rules as these Format
* subclasses. This means that only legal number pattern characters ("0", "#",
* ".", "," etc.) may appear in number formats. Other characters can be
@@ -216,7 +216,7 @@ public class DataFormatter {
private final PropertyChangeSupport pcs;
/** For logging any problems we find */
- private static final POILogger LOG = POILogFactory.getLogger(DataFormatter.class);
+ private static final Logger LOG = LogManager.getLogger(DataFormatter.class);
/**
* Creates a formatter using the {@link Locale#getDefault() default locale}.
@@ -337,7 +337,7 @@ public class DataFormatter {
// Wrap and return (non-cacheable - CellFormat does that)
return new CellFormatResultWrapper( cfmt.apply(cellValueO) );
} catch (Exception e) {
- LOG.log(POILogger.WARN, "Formatting failed for format " + formatStr + ", falling back", e);
+ LOG.atWarn().withThrowable(e).log("Formatting failed for format {}, falling back", formatStr);
}
}
@@ -598,7 +598,7 @@ public class DataFormatter {
try {
return new ExcelStyleDateFormatter(formatStr, dateSymbols);
} catch(IllegalArgumentException iae) {
- LOG.log(POILogger.DEBUG, "Formatting failed for format ", formatStr, ", falling back", iae);
+ LOG.atDebug().withThrowable(iae).log("Formatting failed for format {}, falling back", formatStr);
// the pattern could not be parsed correctly,
// so fall back to the default number format
return getDefaultFormat(cellValue);
@@ -758,7 +758,7 @@ public class DataFormatter {
try {
return new InternalDecimalFormatWithScale(format, symbols);
} catch(IllegalArgumentException iae) {
- LOG.log(POILogger.DEBUG, "Formatting failed for format ", formatStr, ", falling back", iae);
+ LOG.atDebug().withThrowable(iae).log("Formatting failed for format {}, falling back", formatStr);
// the pattern could not be parsed correctly,
// so fall back to the default number format
return getDefaultFormat(cellValue);
@@ -1044,7 +1044,7 @@ public class DataFormatter {
* Format class that handles Excel style fractions, such as "# #/#" and "#/###" This is necessary because Excel has an upper limit on the number of styles that it supports. This function is more efficient than multiple calls to
- * {@link #setCellStyleProperty(org.apache.poi.ss.usermodel.Cell, String, Object)}
+ * {@link #setCellStyleProperty(Cell, String, Object)}
* if adding multiple cell styles. For performance reasons, if this is the only cell in a workbook that uses a cell style,
@@ -313,7 +313,7 @@ public final class CellUtil {
* same style. If setting more than one cell style property on a cell, use
- * {@link #setCellStyleProperties(org.apache.poi.ss.usermodel.Cell, Map)},
+ * {@link #setCellStyleProperties(Cell, Map)},
* which is faster and does not add unnecessary intermediate CellStyles to the workbook.
- * Each POIXMLDocumentPart keeps a reference to the underlying a {@link org.apache.poi.openxml4j.opc.PackagePart}.
+ * Each POIXMLDocumentPart keeps a reference to the underlying a {@link PackagePart}.
*
* This method only exists to allow access to protected {@link POIXMLDocumentPart#onDocumentRead()}
- * from {@link org.apache.poi.xwpf.usermodel.XWPFDocument} without reflection. It should be removed.
+ * from {@link XWPFDocument} without reflection. It should be removed.
*
* @param part the part which is to be read
* @throws IOException if the part can't be read
diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLFactory.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLFactory.java
index b839e0fd17..0e91da3be9 100644
--- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLFactory.java
+++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLFactory.java
@@ -18,20 +18,20 @@ package org.apache.poi.ooxml;
import java.io.IOException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ooxml.POIXMLRelation.PackagePartConstructor;
import org.apache.poi.ooxml.POIXMLRelation.ParentPartConstructor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.xmlbeans.XmlException;
/**
* Defines a factory API that enables sub-classes to create instances of
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
index b65996b53d..67e7c44567 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
@@ -33,6 +33,9 @@ import java.util.stream.Collectors;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.poi.UnsupportedFileFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
@@ -52,8 +55,6 @@ import org.apache.poi.openxml4j.util.ZipEntrySource;
import org.apache.poi.openxml4j.util.ZipFileZipEntrySource;
import org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.TempFile;
/**
@@ -63,7 +64,7 @@ public final class ZipPackage extends OPCPackage {
private static final String MIMETYPE = "mimetype";
private static final String SETTINGS_XML = "settings.xml";
- private static final POILogger LOG = POILogFactory.getLogger(ZipPackage.class);
+ private static final Logger LOG = LogManager.getLogger(ZipPackage.class);
/**
* Zip archive, as either a file on disk,
@@ -81,7 +82,7 @@ public final class ZipPackage extends OPCPackage {
try {
this.contentTypeManager = new ZipContentTypeManager(null, this);
} catch (InvalidFormatException e) {
- LOG.log(POILogger.WARN,"Could not parse ZipPackage", e);
+ LOG.atWarn().withThrowable(e).log("Could not parse ZipPackage");
}
}
@@ -145,7 +146,7 @@ public final class ZipPackage extends OPCPackage {
throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e);
}
- LOG.log(POILogger.ERROR, "Error in zip file ", file, " - falling back to stream processing (i.e. ignoring zip central directory)");
+ LOG.atError().log("Error in zip file {} - falling back to stream processing (i.e. ignoring zip central directory)", file);
ze = openZipEntrySourceStream(file);
}
this.zipArchive = ze;
@@ -311,7 +312,7 @@ public final class ZipPackage extends OPCPackage {
: PackagingURIHelper.createPartName(ZipHelper.getOPCNameFromZipItemName(entryName));
} catch (Exception e) {
// We assume we can continue, even in degraded mode ...
- LOG.log(POILogger.WARN,"Entry ", entryName, " is not valid, so this part won't be add to the package.", e);
+ LOG.atWarn().withThrowable(e).log("Entry {} is not valid, so this part won't be add to the package.", entryName);
}
this.partName = ppn;
@@ -370,7 +371,7 @@ public final class ZipPackage extends OPCPackage {
try {
return new MemoryPackagePart(this, partName, contentType, loadRelationships);
} catch (InvalidFormatException e) {
- LOG.log(POILogger.WARN, e);
+ LOG.atWarn().withThrowable(e).log("Failed to create part {}", partName);
return null;
}
}
@@ -437,9 +438,7 @@ public final class ZipPackage extends OPCPackage {
} finally {
// Either the save operation succeed or not, we delete the temporary file
if (!tempFile.delete()) {
- LOG.log(POILogger.WARN, "The temporary file: '",
- targetFile.getAbsolutePath(),
- "' cannot be deleted ! Make sure that no other application use it.");
+ LOG.atWarn().log("The temporary file: '{}' cannot be deleted ! Make sure that no other application use it.", targetFile.getAbsolutePath());
}
}
}
@@ -496,7 +495,7 @@ public final class ZipPackage extends OPCPackage {
// we save it as well
if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0 ) {
- LOG.log(POILogger.DEBUG,"Save core properties part");
+ LOG.atDebug().log("Save core properties part");
// Ensure that core properties are added if missing
getPackageProperties();
@@ -516,11 +515,11 @@ public final class ZipPackage extends OPCPackage {
}
// Save content type part.
- LOG.log(POILogger.DEBUG,"Save content types part");
+ LOG.atDebug().log("Save content types part");
this.contentTypeManager.save(zos);
// Save package relationships part.
- LOG.log(POILogger.DEBUG,"Save package relationships");
+ LOG.atDebug().log("Save package relationships");
ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
zos);
@@ -534,13 +533,13 @@ public final class ZipPackage extends OPCPackage {
}
final PackagePartName ppn = part.getPartName();
- LOG.log(POILogger.DEBUG,"Save part '", ZipHelper.getZipItemNameFromOPCName(ppn.getName()), "'");
+ LOG.atDebug().log(() -> new SimpleMessage("Save part '" + ZipHelper.getZipItemNameFromOPCName(ppn.getName()) + "'"));
final PartMarshaller marshaller = partMarshallers.get(part._contentType);
final PartMarshaller pm = (marshaller != null) ? marshaller : defaultPartMarshaller;
if (!pm.marshall(part, zos)) {
String errMsg = "The part " + ppn.getURI() + " failed to be saved in the stream with marshaller " + pm +
- ". Enable logging via POILogger for more details.";
+ ". Enable logging via Log4j 2 for more details.";
throw new OpenXML4JException(errMsg);
}
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java
index 3040262ba3..597335efc4 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java
@@ -23,11 +23,11 @@ import java.io.OutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.StreamHelper;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.w3c.dom.Document;
/**
@@ -38,7 +38,7 @@ import org.w3c.dom.Document;
* @see ContentTypeManager
*/
public class ZipContentTypeManager extends ContentTypeManager {
- private static final POILogger LOG = POILogFactory.getLogger(ZipContentTypeManager.class);
+ private static final Logger LOG = LogManager.getLogger(ZipContentTypeManager.class);
/**
* Delegate constructor to the super constructor.
@@ -71,8 +71,7 @@ public class ZipContentTypeManager extends ContentTypeManager {
zos.closeArchiveEntry();
}
} catch (IOException ioe) {
- LOG.log(POILogger.ERROR, "Cannot write: ", CONTENT_TYPES_PART_NAME,
- " in Zip !", ioe);
+ LOG.atError().withThrowable(ioe).log("Cannot write: " + CONTENT_TYPES_PART_NAME + " in Zip !");
return false;
}
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java
index 16a5917ad3..970768cb30 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java
@@ -38,7 +38,7 @@ public final class DefaultMarshaller implements PartMarshaller {
* @param part The {@link PackagePart} to store.
* @param out Output stream to save this part.
* @return true if the content has been successfully stored, false otherwise.
- * More information about errors may be logged via {@link org.apache.poi.util.POILogger}
+ * More information about errors may be logged via Log4j 2.
* @throws OpenXML4JException
* If any error occur.
*/
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
index c1e058ea6d..384ad7687e 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
@@ -24,6 +24,8 @@ import java.net.URI;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackageNamespaces;
import org.apache.poi.openxml4j.opc.PackagePart;
@@ -37,8 +39,6 @@ import org.apache.poi.openxml4j.opc.internal.PartMarshaller;
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
import org.apache.poi.ooxml.util.DocumentHelper;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.usermodel.XSSFRelation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -47,7 +47,7 @@ import org.w3c.dom.Element;
* Zip part marshaller. This marshaller is use to save any part in a zip stream.
*/
public final class ZipPartMarshaller implements PartMarshaller {
- private static final POILogger LOG = POILogFactory.getLogger(ZipPartMarshaller.class);
+ private static final Logger LOG = LogManager.getLogger(ZipPartMarshaller.class);
/**
* Save the specified part to the given stream.
@@ -56,7 +56,7 @@ public final class ZipPartMarshaller implements PartMarshaller {
* @param os The stream to write the data to
* @return true if saving was successful or there was nothing to save,
* false if an error occurred.
- * In case of errors, logging via the {@link POILogger} is used to provide more information.
+ * In case of errors, logging via Log4j 2 is used to provide more information.
* @throws OpenXML4JException
* Throws if the stream cannot be written to or an internal exception is thrown.
*/
@@ -64,7 +64,7 @@ public final class ZipPartMarshaller implements PartMarshaller {
public boolean marshall(PackagePart part, OutputStream os)
throws OpenXML4JException {
if (!(os instanceof ZipArchiveOutputStream)) {
- LOG.log(POILogger.ERROR,"Unexpected class ", os.getClass().getName());
+ LOG.atError().log("Unexpected class {}", os.getClass().getName());
throw new OpenXML4JException("ZipOutputStream expected !");
// Normally should happen only in development phase, so just throw
// exception
@@ -91,8 +91,7 @@ public final class ZipPartMarshaller implements PartMarshaller {
zos.closeArchiveEntry();
}
} catch (IOException ioe) {
- LOG.log(POILogger.ERROR,"Cannot write: ", part.getPartName(), ": in ZIP",
- ioe);
+ LOG.atError().withThrowable(ioe).log("Cannot write: {}: in ZIP", part.getPartName());
return false;
}
@@ -120,7 +119,7 @@ public final class ZipPartMarshaller implements PartMarshaller {
* relationships serialization.
* @return true if saving was successful,
* false if an error occurred.
- * In case of errors, logging via the {@link POILogger} is used to provide more information.
+ * In case of errors, logging via Log4j 2 is used to provide more information.
*/
public static boolean marshallRelationshipPart(
PackageRelationshipCollection rels, PackagePartName relPartName,
@@ -186,7 +185,7 @@ public final class ZipPartMarshaller implements PartMarshaller {
zos.closeArchiveEntry();
}
} catch (IOException e) {
- LOG.log(POILogger.ERROR,"Cannot create zip entry ", relPartName, e);
+ LOG.atError().withThrowable(e).log("Cannot create zip entry {}", relPartName);
return false;
}
}
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java
index 04ac6fd57a..e7a4eba080 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java
@@ -38,8 +38,8 @@ import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.X509Data;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
/**
* JSR105 key selector implementation using the ds:KeyInfo data of the signature
@@ -47,14 +47,14 @@ import org.apache.poi.util.POILogger;
*/
public class KeyInfoKeySelector extends KeySelector implements KeySelectorResult {
- private static final POILogger LOG = POILogFactory.getLogger(KeyInfoKeySelector.class);
+ private static final Logger LOG = LogManager.getLogger(KeyInfoKeySelector.class);
private final List
- * Calculating the formula values with {@link org.apache.poi.ss.usermodel.FormulaEvaluator} is the
+ * Calculating the formula values with {@link FormulaEvaluator} is the
* recommended solution, but this may be used for certain cases where
* evaluation in POI is not possible.
*
* It is recommended to force recalcuation of formulas on workbook level using
- * {@link org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)}
+ * {@link Workbook#setForceFormulaRecalculation(boolean)}
* to ensure that all cross-worksheet formuals and external dependencies are updated.
*
- * See {@link org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)}
+ * See {@link WorkbookUtil#createSafeSheetName(String nameProposal)}
* for a safe way to create valid names
* Note - should not be used standalone, always use via the other
* two classes
@@ -57,7 +57,7 @@ import org.apache.poi.util.POILogger;
* See {@link ShapeTypes}
*/
public class HSLFAutoShape extends HSLFTextShape implements AutoShape
*/
public abstract class HSLFShape implements Shape
@@ -68,7 +70,7 @@ public abstract class PropertiesChunk extends Chunk {
public static final int PROPERTIES_FLAG_WRITEABLE = 4;
/** For logging problems we spot with the file */
- private static final POILogger LOG = POILogFactory.getLogger(PropertiesChunk.class);
+ private static final Logger LOG = LogManager.getLogger(PropertiesChunk.class);
/**
* Holds properties, indexed by type. If a property is multi-valued, or
@@ -176,7 +178,7 @@ public abstract class PropertiesChunk extends Chunk {
if (chunk != null) {
cVal.setValue(chunk);
} else {
- LOG.log(POILogger.WARN, "No chunk found matching Property " + cVal);
+ LOG.atWarn().log("No chunk found matching Property {}", cVal);
}
}
}
@@ -200,9 +202,7 @@ public abstract class PropertiesChunk extends Chunk {
prop = MAPIProperty.createCustom(id, type, "Unknown " + id);
}
if (type == null) {
- LOG.log(POILogger.WARN, "Invalid type found, expected ",
- prop.usualType, " but got ", typeID,
- " for property ", prop);
+ LOG.atWarn().log("Invalid type found, expected {} but got {} for property {}", prop.usualType, box(typeID),prop);
going = false;
break;
}
@@ -220,12 +220,10 @@ public abstract class PropertiesChunk extends Chunk {
// We don't know what this property normally is, but it
// has come
// through with a valid type, so use that
- LOG.log(POILogger.INFO, "Property definition for ", prop,
- " is missing a type definition, found a value with type ", type);
+ LOG.atInfo().log("Property definition for {} is missing a type definition, found a value with type {}", prop, type);
} else {
// Oh dear, something has gone wrong...
- LOG.log(POILogger.WARN, "Type mismatch, expected ",
- prop.usualType, " but got ", type, " for property ", prop);
+ LOG.atWarn().log("Type mismatch, expected {} but got {} for property {}", prop.usualType, type, prop);
going = false;
break;
}
@@ -285,8 +283,7 @@ public abstract class PropertiesChunk extends Chunk {
}
if (properties.get(prop) != null) {
- LOG.log(POILogger.WARN,
- "Duplicate values found for " + prop);
+ LOG.atWarn().log("Duplicate values found for {}", prop);
}
properties.put(prop, propVal);
} catch (BufferUnderrunException e) {
@@ -310,7 +307,7 @@ public abstract class PropertiesChunk extends Chunk {
baos.close();
// write the header data with the properties declaration
- directory.createDocument(org.apache.poi.hsmf.datatypes.PropertiesChunk.NAME,
+ directory.createDocument(PropertiesChunk.NAME,
new ByteArrayInputStream(baos.toByteArray()));
// write the property values
@@ -319,7 +316,7 @@ public abstract class PropertiesChunk extends Chunk {
/**
* Write the nodes for variable-length data. Those properties are returned by
- * {@link #writeProperties(java.io.OutputStream)}.
+ * {@link #writeProperties(OutputStream)}.
*
* @param directory
* The directory.
diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
index efcd051eb9..8b37806fdc 100644
--- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
+++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
@@ -24,8 +24,8 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
/**
* Collection of convenience chunks for the Recip(ient) part of an outlook file.
@@ -33,7 +33,7 @@ import org.apache.poi.util.POILogger;
* If a message has multiple recipients, there will be several of these.
*/
public final class RecipientChunks implements ChunkGroupWithProperties {
- private static final POILogger LOG = POILogFactory.getLogger(RecipientChunks.class);
+ private static final Logger LOG = LogManager.getLogger(RecipientChunks.class);
public static final String PREFIX = "__recip_version1.0_#";
@@ -88,7 +88,7 @@ public final class RecipientChunks implements ChunkGroupWithProperties {
try {
recipientNumber = Integer.parseInt(number, 16);
} catch (NumberFormatException e) {
- LOG.log(POILogger.ERROR, "Invalid recipient number in name ", name);
+ LOG.atError().log("Invalid recipient number in name {}", name);
}
}
}
@@ -238,7 +238,7 @@ public final class RecipientChunks implements ChunkGroupWithProperties {
if (recipientProperties != null) {
recipientProperties.matchVariableSizedPropertiesToChunks();
} else {
- LOG.log(POILogger.WARN, "Recipeints Chunk didn't contain a list of properties!");
+ LOG.atWarn().log("Recipients Chunk didn't contain a list of properties!");
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java b/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java
index 5db7ade98a..086a653086 100644
--- a/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java
+++ b/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java
@@ -24,6 +24,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hsmf.datatypes.AttachmentChunks;
import org.apache.poi.hsmf.datatypes.ByteChunk;
import org.apache.poi.hsmf.datatypes.ByteChunkDeferred;
@@ -46,8 +48,6 @@ import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.DocumentNode;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Processes a POIFS of a .msg file into groups of Chunks, such as
@@ -55,7 +55,7 @@ import org.apache.poi.util.POILogger;
* data and so on.
*/
public final class POIFSChunkParser {
- private static final POILogger LOG = POILogFactory.getLogger(POIFSChunkParser.class);
+ private static final Logger LOG = LogManager.getLogger(POIFSChunkParser.class);
private POIFSChunkParser() {}
@@ -149,7 +149,7 @@ public final class POIFSChunkParser {
try (DocumentInputStream inp = new DocumentInputStream((DocumentNode) entry)) {
chunk.readValue(inp);
} catch (IOException e) {
- LOG.log(POILogger.ERROR, "Error reading from part ", entry.getName(), e);
+ LOG.atError().withThrowable(e).log("Error reading from part {}", entry.getName());
}
}
@@ -234,7 +234,7 @@ public final class POIFSChunkParser {
return new StringChunk(namePrefix, chunkId, type);
}
// Type of an unsupported type! Skipping...
- LOG.log(POILogger.WARN, "UNSUPPORTED PROP TYPE ", entryName);
+ LOG.atWarn().log("UNSUPPORTED PROP TYPE {}", entryName);
return null;
}
}
@@ -249,7 +249,7 @@ public final class POIFSChunkParser {
try {
multiValueIdx = Long.parseLong(mvidxstr) & 0xFFFFFFFFL;
} catch (NumberFormatException ignore) {
- LOG.log(POILogger.WARN, "Can't read multi value idx from entry ", entry.getName());
+ LOG.atWarn().log("Can't read multi value idx from entry {}", entry.getName());
}
}
@@ -270,7 +270,7 @@ public final class POIFSChunkParser {
chunk = new StringChunk(namePrefix, chunkId, type);
} else {
// Type of an unsupported multivalued type! Skipping...
- LOG.log(POILogger.WARN, "Unsupported multivalued prop type for entry ", entry.getName());
+ LOG.atWarn().log("Unsupported multivalued prop type for entry {}", entry.getName());
return null;
}
mc.addChunk((int) multiValueIdx, chunk);
diff --git a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
index 08b5c4ec22..50cf5427b2 100644
--- a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
@@ -24,6 +24,8 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@@ -41,8 +43,6 @@ import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.XMLHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -60,7 +60,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
private static final float DPI = 72;
- private static final POILogger LOG = POILogFactory.getLogger( ExcelToFoConverter.class );
+ private static final Logger LOG = LogManager.getLogger(ExcelToFoConverter.class);
private static final float PAPER_A4_HEIGHT_INCHES = 29.4f / CM_PER_INCH;
@@ -232,10 +232,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
- LOG.log(
- POILogger.WARN,
- "Unexpected cell cachedFormulaResultType ("
- + cell.getCachedFormulaResultType() + ")" );
+ LOG.atWarn().log("Unexpected cell cachedFormulaResultType ({})", cell.getCachedFormulaResultType());
value = AbstractExcelUtils.EMPTY;
break;
}
@@ -253,8 +250,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
- LOG.log( POILogger.WARN,
- "Unexpected cell type (" + cell.getCellType() + ")" );
+ LOG.atWarn().log("Unexpected cell type ({})", cell.getCellType());
return true;
}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
index ea6bf7665d..0110c71ec9 100644
--- a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
@@ -30,6 +30,8 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@@ -44,8 +46,6 @@ import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.XMLHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -58,7 +58,7 @@ import org.w3c.dom.Text;
*/
@Beta
public class ExcelToHtmlConverter extends AbstractExcelConverter {
- private static final POILogger LOG = POILogFactory.getLogger( ExcelToHtmlConverter.class );
+ private static final Logger LOG = LogManager.getLogger(ExcelToHtmlConverter.class);
/**
* Java main() interface to interact with {@link ExcelToHtmlConverter}
@@ -322,10 +322,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
- LOG.log(
- POILogger.WARN,
- "Unexpected cell cachedFormulaResultType ("
- + cell.getCachedFormulaResultType() + ")" );
+ LOG.atWarn().log("Unexpected cell cachedFormulaResultType ({})", cell.getCachedFormulaResultType());
value = AbstractExcelUtils.EMPTY;
break;
}
@@ -343,8 +340,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter {
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
- LOG.log( POILogger.WARN,
- "Unexpected cell type (" + cell.getCellType() + ")" );
+ LOG.atWarn().log("Unexpected cell type ({})", cell.getCellType());
return true;
}
diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java
index 7af8322f01..91597803e1 100644
--- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java
+++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java
@@ -36,6 +36,8 @@ import java.util.function.Supplier;
import javax.imageio.ImageIO;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hwmf.usermodel.HwmfPicture;
import org.apache.poi.util.GenericRecordJsonWriter;
@@ -43,8 +45,6 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.RecordFormatException;
/**
@@ -52,7 +52,7 @@ import org.apache.poi.util.RecordFormatException;
*/
public class HwmfBitmapDib implements GenericRecord {
- private static final POILogger LOG = POILogFactory.getLogger(HwmfBitmapDib.class);
+ private static final Logger LOG = LogManager.getLogger(HwmfBitmapDib.class);
private static final int BMP_HEADER_SIZE = 14;
private static final int MAX_RECORD_LENGTH = HwmfPicture.MAX_RECORD_LENGTH;
@@ -479,11 +479,11 @@ public class HwmfBitmapDib implements GenericRecord {
try {
bi = ImageIO.read(getBMPStream());
} catch (IOException|RuntimeException e) {
- LOG.log(POILogger.ERROR, "invalid bitmap data - returning placeholder image");
+ LOG.atError().log("invalid bitmap data - returning placeholder image");
return getPlaceholder();
}
- if (foreground != null && background != null && headerBitCount == HwmfBitmapDib.BitCount.BI_BITCOUNT_1) {
+ if (foreground != null && background != null && headerBitCount == BitCount.BI_BITCOUNT_1) {
IndexColorModel cmOld = (IndexColorModel)bi.getColorModel();
int fg = foreground.getRGB();
int bg = background.getRGB() & (hasAlpha ? 0xFFFFFF : 0xFFFFFFFF);
diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java
index c806befd00..6f72d28650 100644
--- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java
+++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java
@@ -31,6 +31,8 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hwmf.draw.HwmfDrawProperties;
import org.apache.poi.hwmf.draw.HwmfGraphics;
@@ -44,11 +46,9 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
public class HwmfText {
- private static final POILogger LOG = POILogFactory.getLogger(HwmfText.class);
+ private static final Logger LOG = LogManager.getLogger(HwmfText.class);
private static final int MAX_RECORD_LENGTH = 1_000_000;
/**
@@ -430,13 +430,13 @@ public class HwmfText {
size += rawTextBytes.length;
if (size >= remainingRecordSize) {
- LOG.log(POILogger.INFO, "META_EXTTEXTOUT doesn't contain character tracking info");
+ LOG.atInfo().log("META_EXTTEXTOUT doesn't contain character tracking info");
return size;
}
int dxLen = Math.min(stringLength, (remainingRecordSize-size)/LittleEndianConsts.SHORT_SIZE);
if (dxLen < stringLength) {
- LOG.log(POILogger.WARN, "META_EXTTEXTOUT tracking info doesn't cover all characters");
+ LOG.atWarn().log("META_EXTTEXTOUT tracking info doesn't cover all characters");
}
for (int i=0; i The File Information Block (FIB). Holds pointers
@@ -50,7 +52,7 @@ public final class FileInformationBlock {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
- private static final POILogger LOG = POILogFactory.getLogger( FileInformationBlock.class );
+ private static final Logger LOG = LogManager.getLogger(FileInformationBlock.class);
private final FibBase _fibBase;
private final int _csw;
@@ -175,7 +177,7 @@ public final class FileInformationBlock {
/* The Word spec has a much smaller list of "valid" values
* to what the large CommonCrawl corpus contains!
*/
- LOG.log(POILogger.WARN, "Invalid file format version number: ", nfib, "(", nfibHex, ")");
+ LOG.atWarn().log("Invalid file format version number: {}({})", box(nfib),nfibHex);
}
}
@@ -186,9 +188,7 @@ public final class FileInformationBlock {
if ( cbRgFcLcb == expectedCbRgFcLcb )
return;
- LOG.log( POILogger.WARN, "Since FIB.nFib == ", strNFib,
- " value of FIB.cbRgFcLcb MUST be ", strCbRgFcLcb + ", not 0x",
- Integer.toHexString( cbRgFcLcb ) );
+ LOG.atWarn().log("Since FIB.nFib == {} value of FIB.cbRgFcLcb MUST be {}, not 0x{}", strNFib, strCbRgFcLcb, Integer.toHexString(cbRgFcLcb));
}
private void assertCswNew()
@@ -211,7 +211,7 @@ public final class FileInformationBlock {
assertCswNew( "0x0112", 0x0005, "0x0005", _cswNew );
break;
default:
- LOG.log(POILogger.WARN, "Invalid file format version number: ", getNFib());
+ LOG.atWarn().log("Invalid file format version number: {}", box(getNFib()));
}
}
@@ -222,9 +222,7 @@ public final class FileInformationBlock {
if ( cswNew == expectedCswNew )
return;
- LOG.log( POILogger.WARN, "Since FIB.nFib == ", strNFib,
- " value of FIB.cswNew MUST be ",
- strExpectedCswNew + ", not 0x", Integer.toHexString( cswNew ) );
+ LOG.atWarn().log("Since FIB.nFib == {} value of FIB.cswNew MUST be {}, not 0x{}", strNFib, strExpectedCswNew, Integer.toHexString(cswNew));
}
public void fillVariableFields( byte[] mainDocument, byte[] tableStream )
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
index b5d28d1f45..8fba06f82b 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
@@ -20,12 +20,12 @@ package org.apache.poi.hwpf.model;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* FontTable or in MS terminology sttbfffn is a common data structure written in all
@@ -38,7 +38,7 @@ import org.apache.poi.util.POILogger;
@Internal
public final class FontTable
{
- private static final POILogger LOG = POILogFactory.getLogger(FontTable.class);
+ private static final Logger LOG = LogManager.getLogger(FontTable.class);
private short _stringCount;// how many strings are included in the string table
private short _extraDataSz;// size in bytes of the extra data
@@ -93,7 +93,7 @@ public final class FontTable
{
if(chpFtc >= _stringCount)
{
- LOG.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
+ LOG.atInfo().log("Mismatch in chpFtc with stringCount");
return null;
}
@@ -104,7 +104,7 @@ public final class FontTable
{
if(chpFtc >= _stringCount)
{
- LOG.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
+ LOG.atInfo().log("Mismatch in chpFtc with stringCount");
return null;
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java b/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
index 36b069d80a..f13e9a3884 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
@@ -19,11 +19,13 @@ package org.apache.poi.hwpf.model;
import java.util.Arrays;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hwpf.model.types.LVLFAbstractType;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* "The LVL structure contains formatting information about a specific level in
@@ -43,7 +45,7 @@ public final class ListLevel
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 10_485_760;
- private static final POILogger LOG = POILogFactory.getLogger( ListLevel.class );
+ private static final Logger LOG = LogManager.getLogger(ListLevel.class);
private byte[] _grpprlChpx;
private byte[] _grpprlPapx;
@@ -244,10 +246,7 @@ public final class ListLevel
{
if ( _xst.getCch() != 1 )
{
- LOG.log( POILogger.WARN, "LVL at offset ",
- Integer.valueOf( startOffset ),
- " has nfc == 0x17 (bullets), but cch != 1 (",
- Integer.valueOf( _xst.getCch() ), ")" );
+ LOG.atWarn().log("LVL at offset {} has nfc == 0x17 (bullets), but cch != 1 ({})", box(startOffset),box(_xst.getCch()));
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java b/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
index b105fc16e7..e163b2f005 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
@@ -23,17 +23,19 @@ import java.util.LinkedHashMap;
import java.util.NoSuchElementException;
import java.util.Objects;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hwpf.model.types.LSTFAbstractType;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
@Internal
public final class ListTables
{
- private static final POILogger log = POILogFactory.getLogger(ListTables.class);
+ private static final Logger LOGGER = LogManager.getLogger(ListTables.class);
/**
* Both PlfLst and the following LVLs
@@ -141,13 +143,13 @@ public final class ListTables
{
ListData lst = _listMap.get(lsid);
if (lst == null) {
- log.log(POILogger.WARN, "ListData for ", lsid, " was null.");
+ LOGGER.atWarn().log("ListData for {} was null.", box(lsid));
return null;
}
if(level < lst.numLevels()) {
return lst.getLevels()[level];
}
- log.log(POILogger.WARN, "Requested level ", level, " which was greater than the maximum defined (", lst.numLevels(), ")");
+ LOGGER.atWarn().log("Requested level {} which was greater than the maximum defined ({})", box(level),box(lst.numLevels()));
return null;
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java b/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
index 4f49fe90c7..3377c8cd9c 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
@@ -18,16 +18,18 @@ package org.apache.poi.hwpf.model;
import java.util.Arrays;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static java.lang.Integer.toHexString;
+import static org.apache.logging.log4j.util.Unbox.box;
public class NilPICFAndBinData
{
- private static final POILogger log = POILogFactory
- .getLogger( NilPICFAndBinData.class );
+ private static final Logger LOGGER = LogManager.getLogger(NilPICFAndBinData.class);
private byte[] _binData;
@@ -44,9 +46,7 @@ public class NilPICFAndBinData
if ( cbHeader != 0x44 )
{
- log.log(POILogger.WARN, "NilPICFAndBinData at offset ", offset,
- " cbHeader 0x", Integer.toHexString(cbHeader), " != 0x44"
- );
+ LOGGER.atWarn().log("NilPICFAndBinData at offset {} cbHeader 0x{} != 0x44", box(offset), toHexString(cbHeader));
}
// skip the 62 ignored bytes
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldFfn.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldFfn.java
index 27e5de7b1b..38c0d53cab 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldFfn.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldFfn.java
@@ -19,20 +19,22 @@ package org.apache.poi.hwpf.model;
import java.nio.charset.Charset;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.fonts.FontCharset;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Word 6.0 Font information
*/
@Internal
public final class OldFfn {
- private static final POILogger LOG = POILogFactory.getLogger(OldFfn.class);
+ private static final Logger LOG = LogManager.getLogger(OldFfn.class);
private final byte _chs;// character set identifier
@@ -59,7 +61,7 @@ public final class OldFfn {
short fontDescriptionLength = buf[offset];
offset += 1;
if (offset + fontDescriptionLength > fontTableEnd) {
- LOG.log(POILogger.WARN, "Asked to read beyond font table end. Skipping font");
+ LOG.atWarn().log("Asked to read beyond font table end. Skipping font");
return null;
}
@@ -69,7 +71,7 @@ public final class OldFfn {
Charset charset = null;
FontCharset wmfCharset = FontCharset.valueOf(chs & 0xff);
if (wmfCharset == null) {
- LOG.log(POILogger.WARN, "Couldn't find font for type: ", (chs & 0xff));
+ LOG.atWarn().log("Couldn't find font for type: {}", box((chs & 0xff)));
} else {
charset = wmfCharset.getCharset();
}
@@ -88,7 +90,7 @@ public final class OldFfn {
}
}
if (fontNameLength == -1) {
- LOG.log(POILogger.WARN, "Couldn't find the zero-byte delimited font name length");
+ LOG.atWarn().log("Couldn't find the zero-byte delimited font name length");
return null;
}
String fontName = new String(buf, offset, fontNameLength, charset);
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldFontTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldFontTable.java
index 0e3ec37815..d4935a1ba6 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldFontTable.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldFontTable.java
@@ -21,18 +21,18 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Font table for Word 6.0
*/
@Internal
public final class OldFontTable {
- private static final POILogger LOG = POILogFactory.getLogger(OldFontTable.class);
+ private static final Logger LOG = LogManager.getLogger(OldFontTable.class);
// added extra facilitator members
// FFN structure containing strings of font names
@@ -69,7 +69,7 @@ public final class OldFontTable {
public String getMainFont(int chpFtc) {
if (chpFtc >= _fontNames.length) {
- LOG.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
+ LOG.atInfo().log("Mismatch in chpFtc with stringCount");
return null;
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
index 25dae0de7d..675b62e8be 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
@@ -26,14 +26,17 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.hwpf.sprm.SprmIterator;
import org.apache.poi.hwpf.sprm.SprmOperation;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static java.lang.System.currentTimeMillis;
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* This class represents the bin table of Word document but it also serves as a
@@ -43,7 +46,7 @@ import org.apache.poi.util.POILogger;
@Internal
public class PAPBinTable
{
- private static final POILogger LOG = POILogFactory.getLogger( PAPBinTable.class );
+ private static final Logger LOG = LogManager.getLogger(PAPBinTable.class);
protected final ArrayListx
coordinates.
* @param yPoints array of the y
coordinates.
* @param nPoints the total number of points in the polygon.
- * @see java.awt.Graphics#drawPolygon(int[], int[], int)
+ * @see Graphics#drawPolygon(int[], int[], int)
*/
@Override
public void fillPolygon(int[] xPoints, int[] yPoints,
@@ -442,8 +440,7 @@ public class EscherGraphics extends Graphics {
public void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- if (LOG.check( POILogger.WARN ))
- LOG.log(POILogger.WARN,"fillRoundRect not supported");
+ LOG.atWarn().log("fillRoundRect not supported");
}
@Override
@@ -488,7 +485,7 @@ public class EscherGraphics extends Graphics {
@NotImplemented
public void setClip(Shape shape)
{
- LOG.log(POILogger.WARN,"setClip not supported");
+ LOG.atWarn().log("setClip not supported");
}
@Override
@@ -507,21 +504,21 @@ public class EscherGraphics extends Graphics {
@NotImplemented
public void setPaintMode()
{
- LOG.log(POILogger.WARN,"setPaintMode not supported");
+ LOG.atWarn().log("setPaintMode not supported");
}
@Override
@NotImplemented
public void setXORMode(Color color)
{
- LOG.log(POILogger.WARN,"setXORMode not supported");
+ LOG.atWarn().log("setXORMode not supported");
}
@Override
@NotImplemented
public void translate(int x, int y)
{
- LOG.log(POILogger.WARN,"translate not supported");
+ LOG.atWarn().log("translate not supported");
}
public Color getBackground()
diff --git a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
index 6d631efb1f..a5e3516ab0 100644
--- a/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
+++ b/src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
@@ -17,17 +17,19 @@
package org.apache.poi.hssf.usermodel;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
+import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
@@ -69,7 +71,7 @@ import java.util.Map;
*
*/
public final class EscherGraphics2d extends Graphics2D {
- private static final POILogger LOG = POILogFactory.getLogger(EscherGraphics2d.class);
+ private static final Logger LOG = LogManager.getLogger(EscherGraphics2d.class);
private EscherGraphics _escherGraphics;
private BufferedImage _img;
@@ -153,15 +155,14 @@ public final class EscherGraphics2d extends Graphics2D {
}
else
{
- if (LOG.check(POILogger.WARN))
- LOG.log(POILogger.WARN, "draw not fully supported");
+ LOG.atWarn().log("draw not fully supported");
}
}
public void drawArc(int x, int y, int width, int height,
int startAngle, int arcAngle)
{
- draw(new java.awt.geom.Arc2D.Float(x, y, width, height, startAngle, arcAngle, 0));
+ draw(new Arc2D.Float(x, y, width, height, startAngle, arcAngle, 0));
}
public void drawGlyphVector(GlyphVector g, float x, float y)
@@ -172,22 +173,19 @@ public final class EscherGraphics2d extends Graphics2D {
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, Color bgColor, ImageObserver imageobserver)
{
- if (LOG.check( POILogger.WARN ))
- LOG.log(POILogger.WARN,"drawImage() not supported");
+ LOG.atWarn().log("drawImage() not supported");
return true;
}
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, ImageObserver imageobserver)
{
- if (LOG.check( POILogger.WARN ))
- LOG.log(POILogger.WARN,"drawImage() not supported");
+ LOG.atWarn().log("drawImage() not supported");
return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null, imageobserver);
}
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, Color bgColor, ImageObserver imageobserver)
{
- if (LOG.check( POILogger.WARN ))
- LOG.log(POILogger.WARN,"drawImage() not supported");
+ LOG.atWarn().log("drawImage() not supported");
return true;
}
@@ -282,7 +280,7 @@ public final class EscherGraphics2d extends Graphics2D {
public void drawRoundRect(int i, int j, int k, int l, int i1, int j1)
{
- draw(new java.awt.geom.RoundRectangle2D.Float(i, j, k, l, i1, j1));
+ draw(new RoundRectangle2D.Float(i, j, k, l, i1, j1));
}
public void drawString(String string, float x, float y)
@@ -311,13 +309,12 @@ public final class EscherGraphics2d extends Graphics2D {
public void fill(Shape shape)
{
- if (LOG.check( POILogger.WARN ))
- LOG.log(POILogger.WARN,"fill(Shape) not supported");
+ LOG.atWarn().log("fill(Shape) not supported");
}
public void fillArc(int i, int j, int k, int l, int i1, int j1)
{
- fill(new java.awt.geom.Arc2D.Float(i, j, k, l, i1, j1, 2));
+ fill(new Arc2D.Float(i, j, k, l, i1, j1, 2));
}
public void fillOval(int x, int y, int width, int height)
@@ -342,7 +339,7 @@ public final class EscherGraphics2d extends Graphics2D {
* @param xPoints array of the x
coordinates.
* @param yPoints array of the y
coordinates.
* @param nPoints the total number of points in the polygon.
- * @see java.awt.Graphics#drawPolygon(int[], int[], int)
+ * @see Graphics#drawPolygon(int[], int[], int)
*/
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
{
@@ -357,7 +354,7 @@ public final class EscherGraphics2d extends Graphics2D {
public void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- fill(new java.awt.geom.RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight));
+ fill(new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight));
}
public Color getBackground()
@@ -422,7 +419,7 @@ public final class EscherGraphics2d extends Graphics2D {
return _paint;
}
- public Object getRenderingHint(java.awt.RenderingHints.Key key)
+ public Object getRenderingHint(RenderingHints.Key key)
{
return getG2D().getRenderingHint(key);
}
@@ -510,7 +507,7 @@ public final class EscherGraphics2d extends Graphics2D {
getEscherGraphics().setPaintMode();
}
- public void setRenderingHint(java.awt.RenderingHints.Key key, Object obj)
+ public void setRenderingHint(RenderingHints.Key key, Object obj)
{
getG2D().setRenderingHint(key, obj);
}
@@ -545,18 +542,6 @@ public final class EscherGraphics2d extends Graphics2D {
getTrans().concatenate(affinetransform);
}
-// Image transformImage(Image image, Rectangle rectangle, Rectangle rectangle1, ImageObserver imageobserver, Color color1)
-// {
-// logger.log(POILogger.WARN,"transformImage() not supported");
-// return null;
-// }
-//
-// Image transformImage(Image image, int ai[], Rectangle rectangle, ImageObserver imageobserver, Color color1)
-// {
-// logger.log(POILogger.WARN,"transformImage() not supported");
-// return null;
-// }
-
public void translate(double d, double d1)
{
getTrans().translate(d, d1);
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
index c0aa36f524..e5b6d668cc 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
@@ -57,7 +57,6 @@ import org.apache.poi.util.StringUtil;
* little other than act as a container for other shapes and groups.
*/
public final class HSSFPatriarch implements HSSFShapeContainer, DrawingGraphics2D
Paint
,
* which defines a color or pattern.
* @see #setPaint
- * @see java.awt.Graphics#setColor
+ * @see Graphics#setColor
*/
public Paint getPaint(){
return _paint;
@@ -193,7 +178,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* of this Graphics2D
.
* @param paint the Paint
object to be used to generate
* color during the rendering process, or null
- * @see java.awt.Graphics#setColor
+ * @see Graphics#setColor
*/
public void setPaint(Paint paint){
if(paint == null) return;
@@ -235,7 +220,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param shape the Shape
to be rendered
* @see #setStroke
* @see #setPaint
- * @see java.awt.Graphics#setColor
+ * @see Graphics#setColor
* @see #_transform
* @see #setTransform
* @see #clip
@@ -272,8 +257,8 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @throws NullPointerException if str
is
* null
* @see #setPaint
- * @see java.awt.Graphics#setColor
- * @see java.awt.Graphics#setFont
+ * @see Graphics#setColor
+ * @see Graphics#setFont
* @see #setTransform
* @see #setComposite
* @see #setClip
@@ -332,7 +317,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* Paint
, and Composite
.
* @param shape the Shape
to be filled
* @see #setPaint
- * @see java.awt.Graphics#setColor
+ * @see Graphics#setColor
* @see #_transform
* @see #setTransform
* @see #setComposite
@@ -374,7 +359,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* The user clip modified by this method is independent of the
* clipping associated with device bounds and visibility. If no clip has
* previously been set, or if the clip has been cleared using
- * {@link java.awt.Graphics#setClip(Shape) setClip} with a
+ * {@link Graphics#setClip(Shape) setClip} with a
* null
argument, the specified Shape
becomes
* the new user clip.
* @param s the Shape
to be intersected with the current
@@ -396,10 +381,10 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @return a Shape
object representing the
* current clipping area, or null
if
* no clip is set.
- * @see java.awt.Graphics#getClipBounds()
- * @see java.awt.Graphics#clipRect
- * @see java.awt.Graphics#setClip(int, int, int, int)
- * @see java.awt.Graphics#setClip(Shape)
+ * @see Graphics#getClipBounds()
+ * @see Graphics#clipRect
+ * @see Graphics#setClip(int, int, int, int)
+ * @see Graphics#setClip(Shape)
* @since JDK1.1
*/
@NotImplemented
@@ -445,7 +430,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* at the four corners.
* @param arcHeight the vertical diameter of the arc
* at the four corners.
- * @see java.awt.Graphics#fillRoundRect
+ * @see Graphics#fillRoundRect
*/
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight){
@@ -461,8 +446,8 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param str the string to be drawn.
* @param x the x coordinate.
* @param y the y coordinate.
- * @see java.awt.Graphics#drawBytes
- * @see java.awt.Graphics#drawChars
+ * @see Graphics#drawBytes
+ * @see Graphics#drawChars
*/
public void drawString(String str, int x, int y){
drawString(str, (float)x, (float)y);
@@ -477,7 +462,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* of the oval to be filled.
* @param width the width of the oval to be filled.
* @param height the height of the oval to be filled.
- * @see java.awt.Graphics#drawOval
+ * @see Graphics#drawOval
*/
public void fillOval(int x, int y, int width, int height){
Ellipse2D oval = new Ellipse2D.Double(x, y, width, height);
@@ -498,7 +483,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* of the arc at the four corners.
* @param arcHeight the vertical diameter
* of the arc at the four corners.
- * @see java.awt.Graphics#drawRoundRect
+ * @see Graphics#drawRoundRect
*/
public void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight){
@@ -541,7 +526,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param startAngle the beginning angle.
* @param arcAngle the angular extent of the arc,
* relative to the start angle.
- * @see java.awt.Graphics#drawArc
+ * @see Graphics#drawArc
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle){
Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
@@ -583,7 +568,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param startAngle the beginning angle.
* @param arcAngle the angular extent of the arc,
* relative to the start angle.
- * @see java.awt.Graphics#fillArc
+ * @see Graphics#fillArc
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
@@ -600,7 +585,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param xPoints an array of x points
* @param yPoints an array of y points
* @param nPoints the total number of points
- * @see java.awt.Graphics#drawPolygon(int[], int[], int)
+ * @see Graphics#drawPolygon(int[], int[], int)
* @since JDK1.1
*/
public void drawPolyline(int[] xPoints, int[] yPoints,
@@ -630,7 +615,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* corner of the oval to be drawn.
* @param width the width of the oval to be drawn.
* @param height the height of the oval to be drawn.
- * @see java.awt.Graphics#fillOval
+ * @see Graphics#fillOval
*/
public void drawOval(int x, int y, int width, int height){
Ellipse2D oval = new Ellipse2D.Double(x, y, width, height);
@@ -663,9 +648,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* non-opaque portions of the image.
* @param observer object to be notified as more of
* the image is converted.
- * @see java.awt.Image
- * @see java.awt.image.ImageObserver
- * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
+ * @see Image
+ * @see ImageObserver
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
*/
@NotImplemented
public boolean drawImage(Image img, int x, int y,
@@ -709,9 +694,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* non-opaque portions of the image.
* @param observer object to be notified as more of
* the image is converted.
- * @see java.awt.Image
- * @see java.awt.image.ImageObserver
- * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
+ * @see Image
+ * @see ImageObserver
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
*/
@NotImplemented
public boolean drawImage(Image img, int x, int y,
@@ -765,9 +750,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* source rectangle.
* @param observer object to be notified as more of the image is
* scaled and converted.
- * @see java.awt.Image
- * @see java.awt.image.ImageObserver
- * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
+ * @see Image
+ * @see ImageObserver
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
* @since JDK1.1
*/
@NotImplemented
@@ -827,9 +812,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* non-opaque portions of the image.
* @param observer object to be notified as more of the image is
* scaled and converted.
- * @see java.awt.Image
- * @see java.awt.image.ImageObserver
- * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
+ * @see Image
+ * @see ImageObserver
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
* @since JDK1.1
*/
@NotImplemented
@@ -870,9 +855,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* the image is converted.
* @return false
if the image pixels are still changing;
* true
otherwise.
- * @see java.awt.Image
- * @see java.awt.image.ImageObserver
- * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
+ * @see Image
+ * @see ImageObserver
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
*/
@NotImplemented
public boolean drawImage(Image img, int x, int y,
@@ -902,11 +887,11 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* call dispose
when finished using
* a Graphics
object only if it was created
* directly from a component or another Graphics
object.
- * @see java.awt.Graphics#finalize
- * @see java.awt.Component#paint
- * @see java.awt.Component#update
- * @see java.awt.Component#getGraphics
- * @see java.awt.Graphics#create
+ * @see Graphics#finalize
+ * @see Component#paint
+ * @see Component#update
+ * @see Component#getGraphics
+ * @see Graphics#create
*/
public void dispose() {
}
@@ -943,11 +928,11 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param xPoints a an array of x
coordinates.
* @param yPoints a an array of y
coordinates.
* @param nPoints a the total number of points.
- * @see java.awt.Graphics#drawPolygon(int[], int[], int)
+ * @see Graphics#drawPolygon(int[], int[], int)
*/
public void fillPolygon(int[] xPoints, int[] yPoints,
int nPoints){
- java.awt.Polygon polygon = new java.awt.Polygon(xPoints, yPoints, nPoints);
+ Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
fill(polygon);
}
@@ -967,8 +952,8 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* of the rectangle to be filled.
* @param width the width of the rectangle to be filled.
* @param height the height of the rectangle to be filled.
- * @see java.awt.Graphics#clearRect
- * @see java.awt.Graphics#drawRect
+ * @see Graphics#clearRect
+ * @see Graphics#drawRect
*/
public void fillRect(int x, int y, int width, int height){
Rectangle rect = new Rectangle(x, y, width, height);
@@ -988,8 +973,8 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* of the rectangle to be drawn.
* @param width the width of the rectangle to be drawn.
* @param height the height of the rectangle to be drawn.
- * @see java.awt.Graphics#fillRect
- * @see java.awt.Graphics#clearRect
+ * @see Graphics#fillRect
+ * @see Graphics#clearRect
*/
public void drawRect(int x, int y, int width, int height) {
Rectangle rect = new Rectangle(x, y, width, height);
@@ -1012,12 +997,12 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param xPoints a an array of x
coordinates.
* @param yPoints a an array of y
coordinates.
* @param nPoints a the total number of points.
- * @see java.awt.Graphics#fillPolygon(int[],int[],int)
- * @see java.awt.Graphics#drawPolyline
+ * @see Graphics#fillPolygon(int[],int[],int)
+ * @see Graphics#drawPolyline
*/
public void drawPolygon(int[] xPoints, int[] yPoints,
int nPoints){
- java.awt.Polygon polygon = new java.awt.Polygon(xPoints, yPoints, nPoints);
+ Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
draw(polygon);
}
@@ -1055,9 +1040,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* user clip, which is independent of the clipping associated
* with device bounds and window visibility.
* @param clip the Shape
to use to set the clip
- * @see java.awt.Graphics#getClip()
- * @see java.awt.Graphics#clipRect
- * @see java.awt.Graphics#setClip(int, int, int, int)
+ * @see Graphics#getClip()
+ * @see Graphics#clipRect
+ * @see Graphics#setClip(int, int, int, int)
* @since JDK1.1
*/
@NotImplemented
@@ -1076,10 +1061,10 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* system origin of this graphics context.
* @return the bounding rectangle of the current clipping area,
* or null
if no clip is set.
- * @see java.awt.Graphics#getClip
- * @see java.awt.Graphics#clipRect
- * @see java.awt.Graphics#setClip(int, int, int, int)
- * @see java.awt.Graphics#setClip(Shape)
+ * @see Graphics#getClip
+ * @see Graphics#clipRect
+ * @see Graphics#setClip(int, int, int, int)
+ * @see Graphics#setClip(Shape)
* @since JDK1.1
*/
public Rectangle getClipBounds(){
@@ -1096,8 +1081,8 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param iterator the iterator whose text is to be drawn
* @param x the x coordinate.
* @param y the y coordinate.
- * @see java.awt.Graphics#drawBytes
- * @see java.awt.Graphics#drawChars
+ * @see Graphics#drawBytes
+ * @see Graphics#drawChars
*/
public void drawString(AttributedCharacterIterator iterator,
int x, int y){
@@ -1117,11 +1102,11 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param y the y coordinate of the rectangle to clear.
* @param width the width of the rectangle to clear.
* @param height the height of the rectangle to clear.
- * @see java.awt.Graphics#fillRect(int, int, int, int)
- * @see java.awt.Graphics#drawRect
- * @see java.awt.Graphics#setColor(java.awt.Color)
- * @see java.awt.Graphics#setPaintMode
- * @see java.awt.Graphics#setXORMode(java.awt.Color)
+ * @see Graphics#fillRect(int, int, int, int)
+ * @see Graphics#drawRect
+ * @see Graphics#setColor(Color)
+ * @see Graphics#setPaintMode
+ * @see Graphics#setXORMode(Color)
*/
public void clearRect(int x, int y, int width, int height) {
Paint paint = getPaint();
@@ -1143,8 +1128,8 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param y the y coordinate of the new clip rectangle.
* @param width the width of the new clip rectangle.
* @param height the height of the new clip rectangle.
- * @see java.awt.Graphics#clipRect
- * @see java.awt.Graphics#setClip(Shape)
+ * @see Graphics#clipRect
+ * @see Graphics#setClip(Shape)
* @since JDK1.1
*/
public void setClip(int x, int y, int width, int height){
@@ -1232,9 +1217,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* the text rendering.
*
* @return a reference to an instance of FontRenderContext.
- * @see java.awt.font.FontRenderContext
- * @see java.awt.Font#createGlyphVector(FontRenderContext,char[])
- * @see java.awt.font.TextLayout
+ * @see FontRenderContext
+ * @see Font#createGlyphVector(FontRenderContext,char[])
+ * @see TextLayout
* @since JDK1.2
*/
public FontRenderContext getFontRenderContext() {
@@ -1311,7 +1296,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param color the background color that isused in
* subsequent calls to clearRect
* @see #getBackground
- * @see java.awt.Graphics#clearRect
+ * @see Graphics#clearRect
*/
public void setBackground(Color color) {
if(color == null)
@@ -1351,9 +1336,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* used to render to the screen and a security manager
* is set and its checkPermission
method
* does not allow the operation.
- * @see java.awt.Graphics#setXORMode
- * @see java.awt.Graphics#setPaintMode
- * @see java.awt.AlphaComposite
+ * @see Graphics#setXORMode
+ * @see Graphics#setPaintMode
+ * @see AlphaComposite
*/
@NotImplemented
public void setComposite(Composite comp){
@@ -1423,10 +1408,10 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param y the y position in user space where the glyphs should be
* rendered
*
- * @see java.awt.Font#createGlyphVector(FontRenderContext, char[])
- * @see java.awt.font.GlyphVector
+ * @see Font#createGlyphVector(FontRenderContext, char[])
+ * @see GlyphVector
* @see #setPaint
- * @see java.awt.Graphics#setColor
+ * @see Graphics#setColor
* @see #setTransform
* @see #setComposite
* @see #setClip(Shape)
@@ -1504,7 +1489,7 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* @param y the y coordinate where the iterator's text is to be
* rendered
* @see #setPaint
- * @see java.awt.Graphics#setColor
+ * @see Graphics#setColor
* @see #setTransform
* @see #setComposite
* @see #setClip
@@ -1652,9 +1637,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* the image is converted.
* @return false
if the image pixels are still changing;
* true
otherwise.
- * @see java.awt.Image
- * @see java.awt.image.ImageObserver
- * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
+ * @see Image
+ * @see ImageObserver
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
*/
@NotImplemented
public boolean drawImage(Image img, int x, int y,
@@ -1682,9 +1667,9 @@ public class SLGraphics extends Graphics2D implements Cloneable {
* Gets the font metrics for the specified font.
* @return the font metrics for the specified font.
* @param f the specified font
- * @see java.awt.Graphics#getFont
- * @see java.awt.FontMetrics
- * @see java.awt.Graphics#getFontMetrics()
+ * @see Graphics#getFont
+ * @see FontMetrics
+ * @see Graphics#getFontMetrics()
*/
@SuppressWarnings("deprecation")
@SuppressForbidden
@@ -1805,8 +1790,6 @@ public class SLGraphics extends Graphics2D implements Cloneable {
}
private void logNotImplemented() {
- if (LOG.check(POILogger.WARN)) {
- LOG.log(POILogger.WARN, "Not implemented");
- }
+ LOG.atWarn().log("Not implemented");
}
}
diff --git a/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java b/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
index 13e3992fd6..acde02c945 100644
--- a/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
+++ b/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
@@ -31,12 +31,12 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.XMLHelper;
public final class PresetGeometries {
- private static final POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
+ private static final Logger LOG = LogManager.getLogger(PresetGeometries.class);
private final Map,
P extends TextParagraph
> implements POITextExtractor {
- private static final POILogger LOG = POILogFactory.getLogger(SlideShowExtractor.class);
+ private static final Logger LOG = LogManager.getLogger(SlideShowExtractor.class);
// placeholder text for slide numbers
private static final String SLIDE_NUMBER_PH = "‹#›";
@@ -178,7 +178,7 @@ public class SlideShowExtractor<
if (ts.isPlaceholder()) {
// don't bother about boiler plate text on master sheets
- LOG.log(POILogger.INFO, "Ignoring boiler plate (placeholder) text on slide master:", text);
+ LOG.atInfo().log("Ignoring boiler plate (placeholder) text on slide master: {}", text);
continue;
}
diff --git a/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java b/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java
index c6283b6759..b7d0a3c4ec 100644
--- a/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java
+++ b/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java
@@ -24,15 +24,15 @@ import java.io.IOException;
import javax.imageio.ImageIO;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
@Internal
public class ImageHeaderBitmap {
- private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderBitmap.class);
-
+ private static final Logger LOG = LogManager.getLogger(ImageHeaderBitmap.class);
+
private final Dimension size;
public ImageHeaderBitmap(byte[] data, int offset) {
@@ -40,7 +40,7 @@ public class ImageHeaderBitmap {
try {
img = ImageIO.read(new ByteArrayInputStream(data, offset, data.length-offset));
} catch (IOException e) {
- LOG.log(POILogger.WARN, "Can't determine image dimensions", e);
+ LOG.atWarn().withThrowable(e).log("Can't determine image dimensions");
}
// set dummy size, in case of dummy dimension can't be set
size = (img == null)
diff --git a/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java b/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java
index 48bf45564b..6dd5faf440 100644
--- a/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java
+++ b/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java
@@ -20,15 +20,15 @@ package org.apache.poi.sl.image;
import java.awt.Dimension;
import java.awt.Rectangle;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
@Internal
public class ImageHeaderEMF {
- private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderEMF.class);
+ private static final Logger LOG = LogManager.getLogger(ImageHeaderEMF.class);
private static final String EMF_SIGNATURE = " EMF"; // 0x464D4520 (LE)
@@ -40,7 +40,7 @@ public class ImageHeaderEMF {
int offset = off;
int type = (int)LittleEndian.getUInt(data, offset); offset += 4;
if (type != 1) {
- LOG.log(POILogger.WARN, "Invalid EMF picture - invalid type");
+ LOG.atWarn().log("Invalid EMF picture - invalid type");
deviceBounds = new Rectangle(0,0,200,200);
return;
}
@@ -55,7 +55,7 @@ public class ImageHeaderEMF {
offset += 16;
String signature = new String(data, offset, EMF_SIGNATURE.length(), LocaleUtil.CHARSET_1252);
if (!EMF_SIGNATURE.equals(signature)) {
- LOG.log(POILogger.WARN, "Invalid EMF picture - invalid signature");
+ LOG.atWarn().log("Invalid EMF picture - invalid signature");
}
}
diff --git a/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java b/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java
index d210bc5429..cf2f75867f 100644
--- a/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java
+++ b/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java
@@ -22,11 +22,11 @@ import java.awt.Rectangle;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
/**
@@ -47,7 +47,7 @@ import org.apache.poi.util.Units;
public class ImageHeaderWMF {
public static final int APMHEADER_KEY = 0x9AC6CDD7;
- private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderWMF.class);
+ private static final Logger LOG = LogManager.getLogger(ImageHeaderWMF.class);
@SuppressWarnings("unused")
private final int handle;
@@ -80,7 +80,7 @@ public class ImageHeaderWMF {
int offset = off;
int key = LittleEndian.getInt(data, offset); offset += LittleEndianConsts.INT_SIZE; //header key
if (key != APMHEADER_KEY) {
- LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing");
+ LOG.atWarn().log("WMF file doesn't contain a placeable header - ignore parsing");
handle = 0;
left = 0;
top = 0;
@@ -102,7 +102,7 @@ public class ImageHeaderWMF {
checksum = LittleEndian.getShort(data, offset); offset += LittleEndianConsts.SHORT_SIZE;
if (checksum != getChecksum()){
- LOG.log(POILogger.WARN, "WMF checksum does not match the header data");
+ LOG.atWarn().log("WMF checksum does not match the header data");
}
}
diff --git a/src/java/org/apache/poi/sl/usermodel/ObjectData.java b/src/java/org/apache/poi/sl/usermodel/ObjectData.java
index db30a9b245..11a94281ed 100644
--- a/src/java/org/apache/poi/sl/usermodel/ObjectData.java
+++ b/src/java/org/apache/poi/sl/usermodel/ObjectData.java
@@ -21,12 +21,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Common interface for OLE shapes, i.e. shapes linked to embedded documents
@@ -68,8 +68,8 @@ public interface ObjectData {
FileMagic fm = FileMagic.valueOf(is);
return fm == FileMagic.OLE2;
} catch (IOException e) {
- POILogger LOG = POILogFactory.getLogger(ObjectData.class);
- LOG.log(POILogger.WARN, "Can't determine filemagic of ole stream", e);
+ Logger LOG = LogManager.getLogger(ObjectData.class);
+ LOG.atWarn().withThrowable(e).log("Can't determine filemagic of ole stream");
return false;
}
}
diff --git a/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java b/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
index 153733f5a1..dbce0249ea 100644
--- a/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
+++ b/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
@@ -28,6 +28,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hpsf.ClassID;
import org.apache.poi.hpsf.ClassIDPredefined;
import org.apache.poi.poifs.filesystem.DirectoryNode;
@@ -47,8 +49,6 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* This extractor class tries to identify various embedded documents within Excel files
@@ -56,7 +56,7 @@ import org.apache.poi.util.POILogger;
*/
@Beta
public class EmbeddedExtractor implements Iterable
- * -Dorg.apache.poi.util.POILogger=org.apache.poi.util.SystemOutLogger
- *
- *
- * The following Logger-implementations are provided:
- *
- *
- *
- */
-@Internal
-public interface POILogger {
-
- int DEBUG = 1;
- int INFO = 3;
- int WARN = 5;
- int ERROR = 7;
- int FATAL = 9;
-
- /**
- * Initialize the Logger - belongs to the SPI, called from the POILogFactory
- * @param cat the String that defines the log
- */
- void initialize(String cat);
-
- /**
- * Log a message - belongs to the SPI, usually not called from user code
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 The object to log. This is converted to a string.
- */
- @Internal
- void _log(int level, Object obj1);
-
- /**
- * Log a message - belongs to the SPI, usually not called from user code
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 The object to log. This is converted to a string.
- * @param exception An exception to be logged
- */
- @Internal
- void _log(int level, Object obj1, final Throwable exception);
-
-
- /**
- * Check if a logger is enabled to log at the specified level
- * This allows code to avoid building strings or evaluating functions in
- * the arguments to log.
- *
- * An example:
- *
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- */
- boolean check(int level);
-
- /**
- * Log a message. Lazily appends Object parameters together.
- * If the last parameter is a {@link Throwable} it is logged specially.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param objs the objects to place in the message
- */
- default void log(int level, Object... objs) {
- if (!check(level)) return;
- Throwable lastEx = null;
- String msg;
- if (objs.length == 0) {
- msg = "";
- } else if (objs.length == 1) {
- if (objs[0] instanceof Throwable) {
- lastEx = (Throwable)objs[0];
- }
- msg = objs[0].toString();
- } else {
- StringBuilder sb = new StringBuilder(32);
- for (int i=0; i
- * if (logger.check(POILogger.INFO)) {
- * logger.log(POILogger.INFO, "Avoid concatenating ", " strings and evaluating ", functions());
- * }
- *
POIXMLDocumentPart
*/
public abstract class POIXMLFactory {
- private static final POILogger LOGGER = POILogFactory.getLogger(POIXMLFactory.class);
+ private static final Logger LOGGER = LogManager.getLogger(POIXMLFactory.class);
/**
* Create a POIXMLDocumentPart from existing package part and relation. This method is called
@@ -62,7 +62,7 @@ public abstract class POIXMLFactory {
}
}
- LOGGER.log(POILogger.DEBUG, "using default POIXMLDocumentPart for ", rel.getRelationshipType());
+ LOGGER.atDebug().log("using default POIXMLDocumentPart for {}", rel.getRelationshipType());
return new POIXMLDocumentPart(parent, part);
} catch (IOException | XmlException e) {
throw new POIXMLException(e.getMessage(), e);
diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java
index ca08b55427..5bf576d4e0 100644
--- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java
+++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java
@@ -20,6 +20,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
@@ -27,8 +29,6 @@ import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.xmlbeans.XmlException;
/**
@@ -51,7 +51,7 @@ public abstract class POIXMLRelation {
POIXMLDocumentPart init(POIXMLDocumentPart parent, PackagePart part) throws IOException, XmlException;
}
- private static final POILogger log = POILogFactory.getLogger(POIXMLRelation.class);
+ private static final Logger LOGGER = LogManager.getLogger(POIXMLRelation.class);
/**
* Describes the content stored in a part.
@@ -207,7 +207,7 @@ public abstract class POIXMLRelation {
PackagePart part = corePart.getPackage().getPart(relName);
return part.getInputStream();
}
- log.log(POILogger.WARN, "No part " + getDefaultFileName() + " found");
+ LOGGER.atWarn().log("No part {} found", getDefaultFileName());
return null;
}
}
diff --git a/src/ooxml/java/org/apache/poi/ooxml/util/XPathHelper.java b/src/ooxml/java/org/apache/poi/ooxml/util/XPathHelper.java
index cd4b25da2b..6677f01fb9 100644
--- a/src/ooxml/java/org/apache/poi/ooxml/util/XPathHelper.java
+++ b/src/ooxml/java/org/apache/poi/ooxml/util/XPathHelper.java
@@ -24,9 +24,9 @@ import javax.xml.namespace.QName;
import javax.xml.xpath.XPathFactory;
import com.microsoft.schemas.compatibility.AlternateContentDocument;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.xslf.usermodel.XSLFShape;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
@@ -34,7 +34,7 @@ import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
public final class XPathHelper {
- private static final POILogger LOG = POILogFactory.getLogger(XPathHelper.class);
+ private static final Logger LOG = LogManager.getLogger(XPathHelper.class);
private static final String OSGI_ERROR =
"Schemas (*.xsb) for
*
*/
public class SignatureInfo {
- private static final POILogger LOG = POILogFactory.getLogger(SignatureInfo.class);
+ private static final Logger LOG = LogManager.getLogger(SignatureInfo.class);
private SignatureConfig signatureConfig;
private OPCPackage opcPackage;
@@ -313,11 +314,11 @@ public class SignatureInfo {
return false;
}
sigPart = opcPackage.getPart(sigOrigRels.next());
- LOG.log(POILogger.DEBUG, "Digital Signature Origin part", sigPart);
+ LOG.atDebug().log("Digital Signature Origin part: {}", sigPart);
try {
sigRels = sigPart.getRelationshipsByType(PackageRelationshipTypes.DIGITAL_SIGNATURE).iterator();
} catch (InvalidFormatException e) {
- LOG.log(POILogger.WARN, "Reference to signature is invalid.", e);
+ LOG.atWarn().withThrowable(e).log("Reference to signature is invalid.");
}
}
return true;
@@ -332,9 +333,9 @@ public class SignatureInfo {
throw new NoSuchElementException();
}
sigRelPart = sigPart.getRelatedPart(sigRels.next());
- LOG.log(POILogger.DEBUG, "XML Signature part", sigRelPart);
+ LOG.atDebug().log("XML Signature part: {}", sigRelPart);
} catch (InvalidFormatException e) {
- LOG.log(POILogger.WARN, "Reference to signature is invalid.", e);
+ LOG.atWarn().withThrowable(e).log("Reference to signature is invalid.");
}
} while (sigRelPart == null);
return new SignaturePart(sigRelPart, SignatureInfo.this);
@@ -378,7 +379,7 @@ public class SignatureInfo {
*/
List> _paragraphs = new ArrayList<>();
@@ -57,7 +57,7 @@ public final class HSLFNotes extends HSLFSheet implements Notes
Picture
@@ -120,14 +122,14 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShapeShape
object depending on its type
*/
public final class HSLFShapeFactory {
// For logging
- private static final POILogger LOG = POILogFactory.getLogger(HSLFShapeFactory.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFShapeFactory.class);
/**
* Create a new shape from the data provided.
@@ -112,7 +112,7 @@ public final class HSLFShapeFactory {
if (parent instanceof HSLFTable) {
EscherTextboxRecord etr = spContainer.getChildById(EscherTextboxRecord.RECORD_ID);
if (etr == null) {
- LOG.log(POILogger.WARN, "invalid ppt - add EscherTextboxRecord to cell");
+ LOG.atWarn().log("invalid ppt - add EscherTextboxRecord to cell");
etr = new EscherTextboxRecord();
etr.setRecordId(EscherTextboxRecord.RECORD_ID);
etr.setOptions((short)15);
@@ -153,14 +153,14 @@ public final class HSLFShapeFactory {
return new HSLFFreeformShape(spContainer, parent);
}
- LOG.log(POILogger.INFO, "Creating AutoShape for a NotPrimitive shape");
+ LOG.atInfo().log("Creating AutoShape for a NotPrimitive shape");
return new HSLFAutoShape(spContainer, parent);
}
@SuppressWarnings("unchecked")
protected static > findTextParagraphs(Record[] records) {
List
> paragraphCollection = new ArrayList<>();
int[] recordIdx = { 0 };
@@ -1453,7 +1455,7 @@ public final class HSLFTextParagraph implements TextParagraph