You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ma...@apache.org on 2021/02/21 20:57:27 UTC
svn commit: r1886770 [4/10] - in /poi/trunk: ./ legal/ maven/ osgi/ sonar/
sonar/excelant/ sonar/integration-test/ sonar/main/ sonar/ooxml/
sonar/scratchpad/ src/examples/src/org/apache/poi/examples/hssf/usermodel/
src/integrationtest/ src/integrationt...
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java Sun Feb 21 20:57:25 2021
@@ -18,22 +18,7 @@
package org.apache.poi.sl.draw;
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Composite;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.Image;
-import java.awt.Paint;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.Shape;
-import java.awt.Stroke;
-import java.awt.Toolkit;
+import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.TextLayout;
@@ -52,6 +37,8 @@ import java.awt.image.renderable.Rendera
import java.text.AttributedCharacterIterator;
import java.util.Map;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.sl.usermodel.FreeformShape;
import org.apache.poi.sl.usermodel.GroupShape;
import org.apache.poi.sl.usermodel.Insets2D;
@@ -61,8 +48,6 @@ import org.apache.poi.sl.usermodel.TextB
import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.NotImplemented;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.SuppressForbidden;
/**
@@ -70,7 +55,7 @@ import org.apache.poi.util.SuppressForbi
*/
public class SLGraphics extends Graphics2D implements Cloneable {
- private static final POILogger LOG = POILogFactory.getLogger(SLGraphics.class);
+ private static final Logger LOG = LogManager.getLogger(SLGraphics.class);
//The ppt object to write into.
private GroupShape<?,?> _group;
@@ -110,8 +95,8 @@ public class SLGraphics extends Graphics
/**
* Gets the current font.
* @return this graphics context's current font.
- * @see java.awt.Font
- * @see java.awt.Graphics#setFont(Font)
+ * @see Font
+ * @see Graphics#setFont(Font)
*/
public Font getFont(){
return _font;
@@ -122,10 +107,10 @@ public class SLGraphics extends Graphics
* All subsequent text operations using this graphics context
* use this font.
* @param font the font.
- * @see java.awt.Graphics#getFont
- * @see java.awt.Graphics#drawString(java.lang.String, int, int)
- * @see java.awt.Graphics#drawBytes(byte[], int, int, int, int)
- * @see java.awt.Graphics#drawChars(char[], int, int, int, int)
+ * @see Graphics#getFont
+ * @see Graphics#drawString(String, int, int)
+ * @see Graphics#drawBytes(byte[], int, int, int, int)
+ * @see Graphics#drawChars(char[], int, int, int, int)
*/
public void setFont(Font font){
this._font = font;
@@ -134,8 +119,8 @@ public class SLGraphics extends Graphics
/**
* Gets this graphics context's current color.
* @return this graphics context's current color.
- * @see java.awt.Color
- * @see java.awt.Graphics#setColor
+ * @see Color
+ * @see Graphics#setColor
*/
public Color getColor(){
return _foreground;
@@ -146,8 +131,8 @@ public class SLGraphics extends Graphics
* color. All subsequent graphics operations using this graphics
* context use this specified color.
* @param c the new rendering color.
- * @see java.awt.Color
- * @see java.awt.Graphics#getColor
+ * @see Color
+ * @see Graphics#getColor
*/
public void setColor(Color c) {
setPaint(c);
@@ -179,7 +164,7 @@ public class SLGraphics extends Graphics
* @return the current <code>Graphics2D</code> <code>Paint</code>,
* 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 Graphics
* of this <code>Graphics2D</code>.
* @param paint the <code>Paint</code> object to be used to generate
* color during the rendering process, or <code>null</code>
- * @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 Graphics
* @param shape the <code>Shape</code> 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 Graphics
* @throws NullPointerException if <code>str</code> is
* <code>null</code>
* @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 Graphics
* <code>Paint</code>, and <code>Composite</code>.
* @param shape the <code>Shape</code> 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 Graphics
* The <i>user clip</i> 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
* <code>null</code> argument, the specified <code>Shape</code> becomes
* the new user clip.
* @param s the <code>Shape</code> to be intersected with the current
@@ -396,10 +381,10 @@ public class SLGraphics extends Graphics
* @return a <code>Shape</code> object representing the
* current clipping area, or <code>null</code> 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 Graphics
* 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 Graphics
* @param str the string to be drawn.
* @param x the <i>x</i> coordinate.
* @param y the <i>y</i> 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 Graphics
* 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 Graphics
* 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 Graphics
* @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 Graphics
* @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 Graphics
* @param xPoints an array of <i>x</i> points
* @param yPoints an array of <i>y</i> 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 Graphics
* 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 Graphics
* 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 Graphics
* 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 Graphics
* 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 Graphics
* 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 Graphics
* the image is converted.
* @return <code>false</code> if the image pixels are still changing;
* <code>true</code> 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 Graphics
* call <code>dispose</code> when finished using
* a <code>Graphics</code> object only if it was created
* directly from a component or another <code>Graphics</code> 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 Graphics
* @param xPoints a an array of <code>x</code> coordinates.
* @param yPoints a an array of <code>y</code> 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 Graphics
* 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 Graphics
* 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 Graphics
* @param xPoints a an array of <code>x</code> coordinates.
* @param yPoints a an array of <code>y</code> 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 Graphics
* user clip, which is independent of the clipping associated
* with device bounds and window visibility.
* @param clip the <code>Shape</code> 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 Graphics
* system origin of this graphics context.
* @return the bounding rectangle of the current clipping area,
* or <code>null</code> 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 Graphics
* @param iterator the iterator whose text is to be drawn
* @param x the <i>x</i> coordinate.
* @param y the <i>y</i> 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 Graphics
* @param y the <i>y</i> 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 Graphics
* @param y the <i>y</i> 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 Graphics
* 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 Graphics
* @param color the background color that isused in
* subsequent calls to <code>clearRect</code>
* @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 Graphics
* used to render to the screen and a security manager
* is set and its <code>checkPermission</code> 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 Graphics
* @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 Graphics
* @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 Graphics
* the image is converted.
* @return <code>false</code> if the image pixels are still changing;
* <code>true</code> 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 Graphics
* 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 Graphics
}
private void logNotImplemented() {
- if (LOG.check(POILogger.WARN)) {
- LOG.log(POILogger.WARN, "Not implemented");
- }
+ LOG.atWarn().log("Not implemented");
}
}
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java Sun Feb 21 20:57:25 2021
@@ -31,12 +31,12 @@ import javax.xml.stream.XMLStreamExcepti
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<String, CustomGeometry> map = new TreeMap<>();
@@ -76,7 +76,7 @@ public final class PresetGeometries {
p.parse(staxReader);
return p.getGeom().values().stream().findFirst().orElse(null);
} catch (XMLStreamException e) {
- LOG.log(POILogger.ERROR, "Unable to parse single custom geometry", e);
+ LOG.atError().withThrowable(e).log("Unable to parse single custom geometry");
return null;
}
}
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java Sun Feb 21 20:57:25 2021
@@ -27,10 +27,10 @@ import javax.xml.stream.XMLStreamConstan
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.sl.usermodel.PaintStyle.PaintModifier;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
@Internal
class PresetParser {
@@ -55,7 +55,7 @@ class PresetParser {
}
}
- private static final POILogger LOG = POILogFactory.getLogger(PresetParser.class);
+ private static final Logger LOG = LogManager.getLogger(PresetParser.class);
private Mode mode;
@@ -104,7 +104,7 @@ class PresetParser {
final String name = sr.getLocalName();
customGeometry = new CustomGeometry();
if (geom.containsKey(name)) {
- LOG.log(POILogger.WARN, "Duplicate definition of " + name);
+ LOG.atWarn().log("Duplicate definition of {}", name);
}
geom.put(name, customGeometry);
mode = Mode.SHAPE;
Modified: poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java Sun Feb 21 20:57:25 2021
@@ -26,6 +26,8 @@ import java.util.function.Function;
import java.util.function.Predicate;
import com.zaxxer.sparsebits.SparseBitSet;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.extractor.POITextExtractor;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.Notes;
@@ -43,8 +45,6 @@ import org.apache.poi.sl.usermodel.TextP
import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.sl.usermodel.TextShape;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Common SlideShow extractor
@@ -55,7 +55,7 @@ public class SlideShowExtractor<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> 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;
}
Modified: poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java Sun Feb 21 20:57:25 2021
@@ -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)
Modified: poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderEMF.java Sun Feb 21 20:57:25 2021
@@ -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");
}
}
Modified: poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/image/ImageHeaderWMF.java Sun Feb 21 20:57:25 2021
@@ -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");
}
}
Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/ObjectData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/ObjectData.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/ObjectData.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/ObjectData.java Sun Feb 21 20:57:25 2021
@@ -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;
}
}
Modified: poi/trunk/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java Sun Feb 21 20:57:25 2021
@@ -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.Workb
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<EmbeddedExtractor> {
- private static final POILogger LOG = POILogFactory.getLogger(EmbeddedExtractor.class);
+ private static final Logger LOG = LogManager.getLogger(EmbeddedExtractor.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 1_000_000;
@@ -117,7 +117,7 @@ public class EmbeddedExtractor implement
data = new EmbeddedData(od.getFileName(), od.getObjectData(), od.getContentType());
}
} catch (Exception e) {
- LOG.log(POILogger.WARN, "Entry not found / readable - ignoring OLE embedding", e);
+ LOG.atWarn().withThrowable(e).log("Entry not found / readable - ignoring OLE embedding");
}
} else if (shape instanceof Picture) {
data = extractOne((Picture)shape);
Modified: poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java Sun Feb 21 20:57:25 2021
@@ -32,15 +32,15 @@ import java.util.Set;
import java.util.TreeSet;
import com.zaxxer.sparsebits.SparseBitSet;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* This class implements printing out a value using a number format.
*/
public class CellNumberFormatter extends CellFormatter {
- private static final POILogger LOG = POILogFactory.getLogger(CellNumberFormatter.class);
+ private static final Logger LOG = LogManager.getLogger(CellNumberFormatter.class);
private final String desc;
private final String printfFmt;
@@ -695,8 +695,8 @@ public class CellNumberFormatter extends
}
writeSingleInteger(numeratorFmt, n, output, numeratorSpecials, mods);
writeSingleInteger(denominatorFmt, d, output, denominatorSpecials, mods);
- } catch (RuntimeException ignored) {
- LOG.log(POILogger.ERROR, "error while fraction evaluation", ignored);
+ } catch (RuntimeException e) {
+ LOG.atError().withThrowable(e).log("error while fraction evaluation");
}
}
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java Sun Feb 21 20:57:25 2021
@@ -22,6 +22,10 @@ import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.constant.ErrorConstant;
import org.apache.poi.ss.formula.function.FunctionMetadata;
@@ -71,12 +75,11 @@ import org.apache.poi.ss.formula.ptg.Val
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Table;
+import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.CellReference.NameType;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* This class parses a formula string into a List of tokens in RPN order.
@@ -93,7 +96,7 @@ import org.apache.poi.util.POILogger;
*/
@Internal
public final class FormulaParser {
- private static final POILogger log = POILogFactory.getLogger(FormulaParser.class);
+ private static final Logger LOGGER = LogManager.getLogger(FormulaParser.class);
private final String _formulaString;
private final int _formulaLength;
/** points at the next character to be read (after the {@link #look} codepoint) */
@@ -132,9 +135,9 @@ public final class FormulaParser {
* parse results.
* This class is recommended only for single threaded use.
*
- * If you have a {@link org.apache.poi.hssf.usermodel.HSSFWorkbook}, and not a
- * {@link org.apache.poi.ss.usermodel.Workbook}, then use the convenience method on
- * {@link org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator}
+ * If you have a {@link HSSFWorkbook}, and not a
+ * {@link Workbook}, then use the convenience method on
+ * {@link HSSFFormulaEvaluator}
*/
private FormulaParser(String formula, FormulaParsingWorkbook book, int sheetIndex, int rowIndex) {
_formulaString = formula;
@@ -148,7 +151,7 @@ public final class FormulaParser {
/**
* Parse a formula into an array of tokens
- * Side effect: creates name ({@link org.apache.poi.ss.usermodel.Workbook#createName})
+ * Side effect: creates name ({@link Workbook#createName})
* if formula contains unrecognized names (names are likely UDFs)
*
* @param formula the formula to parse
@@ -173,7 +176,7 @@ public final class FormulaParser {
/**
* Parse a formula into an array of tokens
- * Side effect: creates name ({@link org.apache.poi.ss.usermodel.Workbook#createName})
+ * Side effect: creates name ({@link Workbook#createName})
* if formula contains unrecognized names (names are likely UDFs)
*
* @param formula the formula to parse
@@ -1012,7 +1015,7 @@ public final class FormulaParser {
/**
* Matches a zero or one letter-runs followed by zero or one digit-runs.
* Either or both runs man optionally be prefixed with a single '$'.
- * (copied+modified from {@link org.apache.poi.ss.util.CellReference#CELL_REF_PATTERN})
+ * (copied+modified from {@link CellReference#CELL_REF_PATTERN})
*/
private static final Pattern CELL_REF_PATTERN = Pattern.compile("(\\$?[A-Za-z]+)?(\\$?[0-9]+)?");
@@ -1325,10 +1328,7 @@ public final class FormulaParser {
nameToken = _book.getNameXPtg(name, null);
if (nameToken == null) {
// name is not an internal or external name
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN,
- "FormulaParser.function: Name '" + name + "' is completely unknown in the current workbook.");
- }
+ LOGGER.atWarn().log("FormulaParser.function: Name '{}' is completely unknown in the current workbook.", name);
// name is probably the name of an unregistered User-Defined Function
switch (_book.getSpreadsheetVersion()) {
case EXCEL97:
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java Sun Feb 21 20:57:25 2021
@@ -25,6 +25,9 @@ import java.util.Map;
import java.util.Stack;
import java.util.TreeSet;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.CollaboratingWorkbooksEnvironment.WorkbookNotFoundException;
import org.apache.poi.ss.formula.atp.AnalysisToolPak;
@@ -38,8 +41,9 @@ import org.apache.poi.ss.usermodel.CellT
import org.apache.poi.ss.util.CellRangeAddressBase;
import org.apache.poi.ss.util.CellReference;
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;
+
/**
* Evaluates formula cells.<p/>
*
@@ -55,7 +59,7 @@ import org.apache.poi.util.POILogger;
@Internal
public final class WorkbookEvaluator {
- private static final POILogger LOG = POILogFactory.getLogger(WorkbookEvaluator.class);
+ private static final Logger LOG = LogManager.getLogger(WorkbookEvaluator.class);
private final EvaluationWorkbook _workbook;
private EvaluationCache _cache;
@@ -77,7 +81,7 @@ public final class WorkbookEvaluator {
private boolean dbgEvaluationOutputForNextEval;
// special logger for formula evaluation output (because of possibly very large output)
- private final POILogger EVAL_LOG = POILogFactory.getLogger("POI.FormulaEval");
+ private final Logger EVAL_LOG = LogManager.getLogger("POI.FormulaEval");
// current indent level for evalution; negative value for no output
private int dbgEvaluationOutputIndent = -1;
@@ -125,22 +129,6 @@ public final class WorkbookEvaluator {
return _workbook.getName(name, sheetIndex);
}
- private static boolean isDebugLogEnabled() {
- return LOG.check(POILogger.DEBUG);
- }
- private static boolean isInfoLogEnabled() {
- return LOG.check(POILogger.INFO);
- }
- private static void logDebug(String s) {
- if (isDebugLogEnabled()) {
- LOG.log(POILogger.DEBUG, s);
- }
- }
- private static void logInfo(String s) {
- if (isInfoLogEnabled()) {
- LOG.log(POILogger.INFO, s);
- }
- }
/* package */ void attachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache, int workbookIx) {
_collaboratingWorkbookEnvironment = collaboratingWorkbooksEnvironment;
_cache = cache;
@@ -285,7 +273,7 @@ public final class WorkbookEvaluator {
throw addExceptionInfo(e, sheetIndex, rowIndex, columnIndex);
} catch (RuntimeException re) {
if (re.getCause() instanceof WorkbookNotFoundException && _ignoreMissingWorkbooks) {
- logInfo(re.getCause().getMessage() + " - Continuing with cached value!");
+ LOG.atInfo().log("{} - Continuing with cached value!", re.getCause().getMessage());
switch(srcCell.getCachedFormulaResultType()) {
case NUMERIC:
result = new NumberEval(srcCell.getNumericCellValue());
@@ -318,11 +306,12 @@ public final class WorkbookEvaluator {
}
return cce.getValue();
}
- if (isDebugLogEnabled()) {
+ final ValueEval resultForLogging = result;
+ LOG.atDebug().log(()->{
String sheetName = getSheetName(sheetIndex);
CellReference cr = new CellReference(rowIndex, columnIndex);
- logDebug("Evaluated " + sheetName + "!" + cr.formatAsString() + " to " + result);
- }
+ return new SimpleMessage("Evaluated " + sheetName + "!" + cr.formatAsString() + " to " + resultForLogging);
+ });
// Usually (result === cce.getValue())
// But sometimes: (result==ErrorEval.CIRCULAR_REF_ERROR, cce.getValue()==null)
// When circular references are detected, the cache entry is only updated for
@@ -344,7 +333,7 @@ public final class WorkbookEvaluator {
return new NotImplementedException(msg, inner);
} catch (Exception e) {
// avoid bombing out during exception handling
- LOG.log(POILogger.ERROR, "Can't add exception info", e);
+ LOG.atError().withThrowable(e).log("Can't add exception info");
return inner; // preserve original exception
}
}
@@ -387,14 +376,18 @@ public final class WorkbookEvaluator {
dbgEvaluationOutputForNextEval = false;
}
if (dbgEvaluationOutputIndent > 0) {
- // init. indent string to needed spaces (create as substring vom very long space-only string;
- // limit indendation for deep recursions)
+ // init. indent string to needed spaces (create as substring from very long space-only string;
+ // limit indentation for deep recursions)
dbgIndentStr = " ";
dbgIndentStr = dbgIndentStr.substring(0, Math.min(dbgIndentStr.length(), dbgEvaluationOutputIndent*2));
- EVAL_LOG.log(POILogger.WARN, dbgIndentStr
- + "- evaluateFormula('" + ec.getRefEvaluatorForCurrentSheet().getSheetNameRange()
- + "'/" + new CellReference(ec.getRowIndex(), ec.getColumnIndex()).formatAsString()
- + "): " + Arrays.toString(ptgs).replaceAll("\\Qorg.apache.poi.ss.formula.ptg.\\E", ""));
+ String finalDbgIndentStr = dbgIndentStr;
+ EVAL_LOG.atWarn().log(() -> {
+ String message = finalDbgIndentStr
+ + "- evaluateFormula('" + ec.getRefEvaluatorForCurrentSheet().getSheetNameRange()
+ + "'/" + new CellReference(ec.getRowIndex(), ec.getColumnIndex()).formatAsString()
+ + "): " + Arrays.toString(ptgs).replaceAll("\\Qorg.apache.poi.ss.formula.ptg.\\E", "");
+ return new SimpleMessage(message);
+ });
dbgEvaluationOutputIndent++;
}
@@ -406,7 +399,7 @@ public final class WorkbookEvaluator {
// since we don't know how to handle these yet :(
Ptg ptg = ptgs[i];
if (dbgEvaluationOutputIndent > 0) {
- EVAL_LOG.log(POILogger.INFO, dbgIndentStr, " * ptg ", i, ": ", ptg, ", stack: ", stack);
+ EVAL_LOG.atInfo().log("{} * ptg {}: {}, stack: {}", dbgIndentStr, box(i),ptg, stack);
}
if (ptg instanceof AttrPtg) {
AttrPtg attrPtg = (AttrPtg) ptg;
@@ -551,7 +544,7 @@ public final class WorkbookEvaluator {
// logDebug("push " + opResult);
stack.push(opResult);
if (dbgEvaluationOutputIndent > 0) {
- EVAL_LOG.log(POILogger.INFO, dbgIndentStr, " = ", opResult);
+ EVAL_LOG.atInfo().log("{} = {}", dbgIndentStr, opResult);
}
}
@@ -570,9 +563,7 @@ public final class WorkbookEvaluator {
}
if (dbgEvaluationOutputIndent > 0) {
- EVAL_LOG.log(POILogger.INFO, dbgIndentStr, "finished eval of ",
- new CellReference(ec.getRowIndex(), ec.getColumnIndex()).formatAsString(),
- ": ", result);
+ EVAL_LOG.atInfo().log("{}finished eval of {}: {}", dbgIndentStr, new CellReference(ec.getRowIndex(), ec.getColumnIndex()).formatAsString(), result);
dbgEvaluationOutputIndent--;
if (dbgEvaluationOutputIndent == 1) {
// this evaluation is done, reset indent to stop logging
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java Sun Feb 21 20:57:25 2021
@@ -17,9 +17,12 @@
package org.apache.poi.ss.formula.constant;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.usermodel.FormulaError;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Represents a constant error code value as encoded in a constant values array. <p>
*
@@ -27,8 +30,8 @@ import org.apache.poi.util.POILogger;
* <tt>ErrorEval</tt>.
*/
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);
}
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rate.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rate.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rate.java Sun Feb 21 20:57:25 2021
@@ -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();
}
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Sun Feb 21 20:57:25 2021
@@ -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.
* <p>
* 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 {
* </p>
*
* @param format A Format instance to be used as a default
- * @see java.text.Format#format
+ * @see Format#format
*/
public void setDefaultNumberFormat(Format format) {
for (Map.Entry<String, Format> entry : formats.entrySet()) {
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/FractionFormat.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/FractionFormat.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/FractionFormat.java Sun Feb 21 20:57:25 2021
@@ -24,10 +24,10 @@ import java.text.ParsePosition;
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.SimpleFraction;
import org.apache.poi.ss.formula.eval.NotImplementedException;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* <p>Format class that handles Excel style fractions, such as "# #/#" and "#/###"</p>
@@ -43,7 +43,7 @@ import org.apache.poi.util.POILogger;
@SuppressWarnings("serial")
public class FractionFormat extends Format {
- private static final POILogger LOGGER = POILogFactory.getLogger(FractionFormat.class);
+ private static final Logger LOGGER = LogManager.getLogger(FractionFormat.class);
private static final Pattern DENOM_FORMAT_PATTERN = Pattern.compile("(?:(#+)|(\\d+))");
//this was chosen to match the earlier limitation of max denom power
@@ -147,7 +147,7 @@ public class FractionFormat extends Form
fract = SimpleFraction.buildFractionMaxDenominator(decPart.doubleValue(), maxDenom);
}
} catch (RuntimeException e){
- LOGGER.log(POILogger.WARN, "Can't format fraction", e);
+ LOGGER.atWarn().withThrowable(e).log("Can't format fraction");
return Double.toString(doubleValue.doubleValue());
}
Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java Sun Feb 21 20:57:25 2021
@@ -25,6 +25,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
@@ -35,8 +37,6 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Various utility functions that make working with a cells and rows easier. The various methods
@@ -50,7 +50,7 @@ import org.apache.poi.util.POILogger;
*/
public final class CellUtil {
- private static final POILogger log = POILogFactory.getLogger(CellUtil.class);
+ private static final Logger LOGGER = LogManager.getLogger(CellUtil.class);
// FIXME: Move these constants into an enum
public static final String ALIGNMENT = "alignment";
@@ -258,7 +258,7 @@ public final class CellUtil {
* <p>This is necessary because Excel has an upper limit on the number of styles that it supports.</p>
*
* <p>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.</p>
*
* <p>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.</p>
*
* <p>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.</p>
*
* @param cell The cell that is to be changed.
@@ -333,7 +333,7 @@ public final class CellUtil {
*
* @param style cell style
* @return map of format properties (String -> Object)
- * @see #setFormatProperties(org.apache.poi.ss.usermodel.CellStyle, org.apache.poi.ss.usermodel.Workbook, java.util.Map)
+ * @see #setFormatProperties(CellStyle, Workbook, Map)
*/
private static Map<String, Object> getFormatProperties(CellStyle style) {
Map<String, Object> properties = new HashMap<>();
@@ -385,7 +385,7 @@ public final class CellUtil {
} else if (FILL_PATTERN.equals(key)) {
dest.put(key, getFillPattern(src, key));
} else {
- log.log(POILogger.INFO, "Ignoring unrecognized CellUtil format properties key: ", key);
+ LOGGER.atInfo().log("Ignoring unrecognized CellUtil format properties key: {}", key);
}
}
}
@@ -468,10 +468,7 @@ public final class CellUtil {
}
// @deprecated 3.15 beta 2. getBorderStyle will only work on BorderStyle enums instead of codes in the future.
else if (value instanceof Short) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Deprecation warning: CellUtil properties map uses Short values for "
- + name + ". Should use BorderStyle enums instead.");
- }
+ LOGGER.atWarn().log("Deprecation warning: CellUtil properties map uses Short values for {}. Should use BorderStyle enums instead.", name);
short code = ((Short) value).shortValue();
border = BorderStyle.valueOf(code);
}
@@ -500,10 +497,7 @@ public final class CellUtil {
}
// @deprecated 3.15 beta 2. getFillPattern will only work on FillPatternType enums instead of codes in the future.
else if (value instanceof Short) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Deprecation warning: CellUtil properties map uses Short values for "
- + name + ". Should use FillPatternType enums instead.");
- }
+ LOGGER.atWarn().log("Deprecation warning: CellUtil properties map uses Short values for {}. Should use FillPatternType enums instead.", name);
short code = ((Short) value).shortValue();
pattern = FillPatternType.forInt(code);
}
@@ -532,10 +526,7 @@ public final class CellUtil {
}
// @deprecated 3.15 beta 2. getHorizontalAlignment will only work on HorizontalAlignment enums instead of codes in the future.
else if (value instanceof Short) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Deprecation warning: CellUtil properties map used a Short value for "
- + name + ". Should use HorizontalAlignment enums instead.");
- }
+ LOGGER.atWarn().log("Deprecation warning: CellUtil properties map used a Short value for {}. Should use HorizontalAlignment enums instead.", name);
short code = ((Short) value).shortValue();
align = HorizontalAlignment.forInt(code);
}
@@ -564,10 +555,7 @@ public final class CellUtil {
}
// @deprecated 3.15 beta 2. getVerticalAlignment will only work on VerticalAlignment enums instead of codes in the future.
else if (value instanceof Short) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Deprecation warning: CellUtil properties map used a Short value for "
- + name + ". Should use VerticalAlignment enums instead.");
- }
+ LOGGER.atWarn().log("Deprecation warning: CellUtil properties map used a Short value for {}. Should use VerticalAlignment enums instead.", name);
short code = ((Short) value).shortValue();
align = VerticalAlignment.forInt(code);
}
Modified: poi/trunk/src/java/org/apache/poi/ss/util/DateFormatConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/DateFormatConverter.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/DateFormatConverter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/DateFormatConverter.java Sun Feb 21 20:57:25 2021
@@ -24,9 +24,9 @@ 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.util.LocaleID;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Convert java DateFormat patterns into Excel custom number formats.
@@ -49,7 +49,7 @@ import org.apache.poi.util.POILogger;
*/
@SuppressWarnings("unused")
public final class DateFormatConverter {
- private static final POILogger LOG = POILogFactory.getLogger(DateFormatConverter.class);
+ private static final Logger LOG = LogManager.getLogger(DateFormatConverter.class);
private DateFormatConverter() {
}
@@ -155,7 +155,7 @@ public final class DateFormatConverter
}
if (loc == null) {
- LOG.log(POILogger.ERROR, "Unable to find prefix for Locale '", languageTag, "' or its parent locales.");
+ LOG.atError().log("Unable to find prefix for Locale '{}' or its parent locales.", languageTag);
return "";
}
Modified: poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java Sun Feb 21 20:57:25 2021
@@ -31,6 +31,8 @@ import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.Picture;
@@ -38,14 +40,12 @@ import org.apache.poi.ss.usermodel.Pictu
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public final class ImageUtils {
- private static final POILogger LOG = POILogFactory.getLogger(ImageUtils.class);
+ private static final Logger LOG = LogManager.getLogger(ImageUtils.class);
private static final int WIDTH_UNITS = 1024;
private static final int HEIGHT_UNITS = 256;
@@ -56,8 +56,8 @@ public final class ImageUtils {
* Return the dimension of this image
*
* @param is the stream containing the image data
- * @param type type of the picture: {@link org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_JPEG},
- * {@link org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_PNG} or {@link org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_DIB}
+ * @param type type of the picture: {@link Workbook#PICTURE_TYPE_JPEG},
+ * {@link Workbook#PICTURE_TYPE_PNG} or {@link Workbook#PICTURE_TYPE_DIB}
*
* @return image dimension in pixels
*/
@@ -93,18 +93,18 @@ public final class ImageUtils {
r.dispose();
}
} else {
- LOG.log(POILogger.WARN, "ImageIO found no images");
+ LOG.atWarn().log("ImageIO found no images");
}
}
} catch (IOException e) {
//silently return if ImageIO failed to read the image
- LOG.log(POILogger.WARN, e);
+ LOG.atWarn().withThrowable(e).log("Failed to determine image dimensions");
}
break;
default:
- LOG.log(POILogger.WARN, "Only JPEG, PNG and DIB pictures can be automatically sized");
+ LOG.atWarn().log("Only JPEG, PNG and DIB pictures can be automatically sized");
}
return size;
}
Modified: poi/trunk/src/java/org/apache/poi/util/Configurator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/Configurator.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/Configurator.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/Configurator.java Sun Feb 21 20:57:25 2021
@@ -17,11 +17,14 @@ package org.apache.poi.util;
limitations under the License.
==================================================================== */
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
/**
* Helper for fetching int values from system properties
*/
public class Configurator {
- private static final POILogger LOG = POILogFactory.getLogger(Configurator.class);
+ private static final Logger LOG = LogManager.getLogger(Configurator.class);
public static int getIntValue(String systemProperty, int defaultValue) {
String property = System.getProperty(systemProperty);
@@ -31,7 +34,7 @@ public class Configurator {
try {
return Integer.parseInt(property);
} catch (Exception e) {
- LOG.log(POILogger.ERROR, "System property -D", systemProperty, " does not contains a valid integer: ", property);
+ LOG.atError().log("System property -D{} does not contains a valid integer: {}", systemProperty, property);
return defaultValue;
}
}
Modified: poi/trunk/src/java/org/apache/poi/util/IOUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IOUtils.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IOUtils.java Sun Feb 21 20:57:25 2021
@@ -33,11 +33,13 @@ import java.util.Locale;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.EmptyFileException;
@Internal
public final class IOUtils {
- private static final POILogger LOG = POILogFactory.getLogger( IOUtils.class );
+ private static final Logger LOG = LogManager.getLogger(IOUtils.class);
/**
* The default buffer size to use for the skip() methods.
@@ -395,8 +397,7 @@ public final class IOUtils {
try {
closeable.close();
} catch ( Exception exc ) {
- LOG.log( POILogger.ERROR, "Unable to close resource: ", exc,
- exc );
+ LOG.atError().withThrowable(exc).log("Unable to close resource");
}
}
Modified: poi/trunk/src/java/org/apache/poi/util/XMLHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/XMLHelper.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/XMLHelper.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/XMLHelper.java Sun Feb 21 20:57:25 2021
@@ -46,6 +46,9 @@ import javax.xml.transform.TransformerEx
import javax.xml.transform.TransformerFactory;
import javax.xml.validation.SchemaFactory;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -74,7 +77,7 @@ public final class XMLHelper {
};
- private static final POILogger LOG = POILogFactory.getLogger(XMLHelper.class);
+ private static final Logger LOG = LogManager.getLogger(XMLHelper.class);
private static long lastLog;
// DocumentBuilderFactory.newDocumentBuilder is thread-safe
@@ -290,7 +293,7 @@ public final class XMLHelper {
private static void logThrowable(Throwable t, String message, String name) {
if (System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
- LOG.log(POILogger.WARN, message + " [log suppressed for 5 minutes]", name, t);
+ LOG.atWarn().withThrowable(t).log("{} [log suppressed for 5 minutes]{}", message, name);
lastLog = System.currentTimeMillis();
}
}
@@ -298,22 +301,22 @@ public final class XMLHelper {
private static class DocHelperErrorHandler implements ErrorHandler {
public void warning(SAXParseException exception) {
- printError(POILogger.WARN, exception);
+ printError(Level.WARN, exception);
}
public void error(SAXParseException exception) {
- printError(POILogger.ERROR, exception);
+ printError(Level.ERROR, exception);
}
public void fatalError(SAXParseException exception) throws SAXException {
- printError(POILogger.FATAL, exception);
+ printError(Level.FATAL, exception);
throw exception;
}
/**
* Prints the error message.
*/
- private void printError(int type, SAXParseException ex) {
+ private void printError(Level type, SAXParseException ex) {
String systemId = ex.getSystemId();
if (systemId != null) {
int index = systemId.lastIndexOf('/');
@@ -326,7 +329,7 @@ public final class XMLHelper {
':' + ex.getColumnNumber() +
':' + ex.getMessage();
- LOG.log(type, message, ex);
+ LOG.atLevel(type).withThrowable(ex).log(message);
}
}
Modified: poi/trunk/src/multimodule/integration/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/integration/java9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/integration/java9/module-info.java (original)
+++ poi/trunk/src/multimodule/integration/java9/module-info.java Sun Feb 21 20:57:25 2021
@@ -16,6 +16,7 @@
==================================================================== */
module org.apache.poi.stress {
+ requires org.apache.logging.log4j;
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;
requires net.bytebuddy;
Modified: poi/trunk/src/multimodule/ooxml-lite/java9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-lite/java9/module-info.class?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/ooxml/java9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml/java9/module-info.class?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/ooxml/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml/java9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/ooxml/java9/module-info.java (original)
+++ poi/trunk/src/multimodule/ooxml/java9/module-info.java Sun Feb 21 20:57:25 2021
@@ -23,7 +23,7 @@ module org.apache.poi.ooxml {
requires org.apache.commons.codec;
requires commons.math3;
requires SparseBitSet;
- requires org.slf4j;
+ requires org.apache.logging.log4j;
requires java.logging;
requires java.desktop;
requires java.security.jgss;
Modified: poi/trunk/src/multimodule/ooxml/test9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml/test9/module-info.class?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/ooxml/test9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml/test9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/ooxml/test9/module-info.java (original)
+++ poi/trunk/src/multimodule/ooxml/test9/module-info.java Sun Feb 21 20:57:25 2021
@@ -23,7 +23,7 @@ module org.apache.poi.ooxml {
requires org.apache.commons.codec;
requires commons.math3;
requires SparseBitSet;
- requires org.slf4j;
+ requires org.apache.logging.log4j;
requires java.logging;
requires java.desktop;
requires java.security.jgss;
Modified: poi/trunk/src/multimodule/poi/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/poi/java9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/poi/java9/module-info.java (original)
+++ poi/trunk/src/multimodule/poi/java9/module-info.java Sun Feb 21 20:57:25 2021
@@ -20,7 +20,7 @@ module org.apache.poi.poi {
requires org.apache.commons.codec;
requires commons.math3;
requires SparseBitSet;
- requires org.slf4j;
+ requires org.apache.logging.log4j;
requires java.logging;
requires java.desktop;
Modified: poi/trunk/src/multimodule/poi/test9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/poi/test9/module-info.class?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/poi/test9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/poi/test9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/poi/test9/module-info.java (original)
+++ poi/trunk/src/multimodule/poi/test9/module-info.java Sun Feb 21 20:57:25 2021
@@ -20,7 +20,7 @@ module org.apache.poi.poi {
requires org.apache.commons.codec;
requires commons.math3;
requires SparseBitSet;
- requires org.slf4j;
+ requires org.apache.logging.log4j;
requires java.logging;
requires java.desktop;
Modified: poi/trunk/src/multimodule/scratchpad/java9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/scratchpad/java9/module-info.class?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/scratchpad/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/scratchpad/java9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/scratchpad/java9/module-info.java (original)
+++ poi/trunk/src/multimodule/scratchpad/java9/module-info.java Sun Feb 21 20:57:25 2021
@@ -19,6 +19,7 @@ module org.apache.poi.scratchpad {
requires transitive org.apache.poi.poi;
requires java.desktop;
requires commons.math3;
+ requires org.apache.logging.log4j;
provides org.apache.poi.extractor.ExtractorProvider with org.apache.poi.extractor.ole2.OLE2ScratchpadExtractorFactory;
provides org.apache.poi.sl.usermodel.SlideShowProvider with org.apache.poi.hslf.usermodel.HSLFSlideShowFactory;
Modified: poi/trunk/src/multimodule/scratchpad/test9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/scratchpad/test9/module-info.class?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/scratchpad/test9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/scratchpad/test9/module-info.java?rev=1886770&r1=1886769&r2=1886770&view=diff
==============================================================================
--- poi/trunk/src/multimodule/scratchpad/test9/module-info.java (original)
+++ poi/trunk/src/multimodule/scratchpad/test9/module-info.java Sun Feb 21 20:57:25 2021
@@ -19,6 +19,7 @@ module org.apache.poi.scratchpad {
requires transitive org.apache.poi.poi;
requires java.desktop;
requires commons.math3;
+ requires org.apache.logging.log4j;
provides org.apache.poi.extractor.ExtractorProvider with org.apache.poi.extractor.ole2.OLE2ScratchpadExtractorFactory;
provides org.apache.poi.sl.usermodel.SlideShowProvider with org.apache.poi.hslf.usermodel.HSLFSlideShowFactory;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org