Skip to content

Commit d3032e7

Browse files
Use custom MessageFormatUtil class instead of MessageFormat class
1 parent 3d17f9a commit d3032e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+551
-550
lines changed

src/main/java/com/itextpdf/html2pdf/attach/impl/DefaultHtmlProcessor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ This file is part of the iText (R) project.
7979
import org.slf4j.Logger;
8080
import org.slf4j.LoggerFactory;
8181

82-
import java.text.MessageFormat;
82+
import com.itextpdf.io.util.MessageFormatUtil;
8383
import java.util.ArrayList;
8484
import java.util.Arrays;
8585
import java.util.Collection;
@@ -185,7 +185,7 @@ public List<com.itextpdf.layout.element.IElement> processElements(INode root) {
185185
if (node instanceof IElementNode) {
186186
visit(node);
187187
} else if (node instanceof ITextNode) {
188-
logger.error(MessageFormat.format(LogMessageConstant.TEXT_WAS_NOT_PROCESSED, ((ITextNode) node).wholeText()));
188+
logger.error(MessageFormatUtil.format(LogMessageConstant.TEXT_WAS_NOT_PROCESSED, ((ITextNode) node).wholeText()));
189189
}
190190
}
191191
List<com.itextpdf.layout.element.IElement> elements = new ArrayList<>();
@@ -281,7 +281,7 @@ private void visit(INode node) {
281281
ITagWorker tagWorker = context.getTagWorkerFactory().getTagWorker(element, context);
282282
if (tagWorker == null) {
283283
if (!ignoredTags.contains(element.name())) {
284-
logger.error(MessageFormat.format(LogMessageConstant.NO_WORKER_FOUND_FOR_TAG, (element).name()));
284+
logger.error(MessageFormatUtil.format(LogMessageConstant.NO_WORKER_FOUND_FOR_TAG, (element).name()));
285285
}
286286
} else {
287287
context.getState().push(tagWorker);
@@ -306,7 +306,7 @@ private void visit(INode node) {
306306
ICssApplier cssApplier = context.getCssApplierFactory().getCssApplier(element);
307307
if (cssApplier == null) {
308308
if (!ignoredCssTags.contains(element.name())) {
309-
logger.error(MessageFormat.format(LogMessageConstant.NO_CSS_APPLIER_FOUND_FOR_TAG, element.name()));
309+
logger.error(MessageFormatUtil.format(LogMessageConstant.NO_CSS_APPLIER_FOUND_FOR_TAG, element.name()));
310310
}
311311
} else {
312312
cssApplier.apply(context, element, tagWorker);
@@ -317,7 +317,7 @@ private void visit(INode node) {
317317
boolean childProcessed = context.getState().top().processTagChild(tagWorker, context);
318318
PageBreakApplierUtil.addPageBreakElementAfter(context, context.getState().top(), element, tagWorker);
319319
if (!childProcessed) {
320-
logger.error(MessageFormat.format(LogMessageConstant.WORKER_UNABLE_TO_PROCESS_OTHER_WORKER,
320+
logger.error(MessageFormatUtil.format(LogMessageConstant.WORKER_UNABLE_TO_PROCESS_OTHER_WORKER,
321321
context.getState().top().getClass().getName(), tagWorker.getClass().getName()));
322322
}
323323
} else if (tagWorker.getElementResult() != null) {
@@ -333,7 +333,7 @@ private void visit(INode node) {
333333
if (!context.getState().empty()) {
334334
boolean contentProcessed = context.getState().top().processContent(content, context);
335335
if (!contentProcessed) {
336-
logger.error(MessageFormat.format(LogMessageConstant.WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT,
336+
logger.error(MessageFormatUtil.format(LogMessageConstant.WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT,
337337
context.getState().top().getClass().getName()));
338338
}
339339
} else {
@@ -362,7 +362,7 @@ protected void addFontFaceFonts() {
362362
}
363363
}
364364
if (!findSupportedSrc) {
365-
logger.error(MessageFormat.format(LogMessageConstant.UNABLE_TO_RETRIEVE_FONT, fontFace));
365+
logger.error(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_RETRIEVE_FONT, fontFace));
366366
}
367367
}
368368
}

src/main/java/com/itextpdf/html2pdf/attach/impl/FontFace.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
This file is part of the iText (R) project.
33
Copyright (c) 1998-2017 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
5-
5+
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU Affero General Public License version 3
88
as published by the Free Software Foundation with the addition of the
99
following permission added to Section 15 as permitted in Section 7(a):
1010
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
1111
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
1212
OF THIRD PARTY RIGHTS
13-
13+
1414
This program is distributed in the hope that it will be useful, but
1515
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1616
or FITNESS FOR A PARTICULAR PURPOSE.
@@ -20,31 +20,31 @@ This file is part of the iText (R) project.
2020
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2121
Boston, MA, 02110-1301 USA, or download the license from the following URL:
2222
http://itextpdf.com/terms-of-use/
23-
23+
2424
The interactive user interfaces in modified source and object code versions
2525
of this program must display Appropriate Legal Notices, as required under
2626
Section 5 of the GNU Affero General Public License.
27-
27+
2828
In accordance with Section 7(b) of the GNU Affero General Public License,
2929
a covered work must retain the producer line in every PDF that is created
3030
or manipulated using iText.
31-
31+
3232
You can be released from the requirements of the license by purchasing
3333
a commercial license. Buying such a license is mandatory as soon as you
3434
develop commercial activities involving the iText software without
3535
disclosing the source code of your own applications.
3636
These activities include: offering paid services to customers as an ASP,
3737
serving PDFs on the fly in a web application, shipping iText with a closed
3838
source product.
39-
39+
4040
For more information, please contact iText Software Corp. at this
4141
address: sales@itextpdf.com
4242
*/
4343
package com.itextpdf.html2pdf.attach.impl;
4444

4545
import com.itextpdf.html2pdf.css.CssDeclaration;
4646

47-
import java.text.MessageFormat;
47+
import com.itextpdf.io.util.MessageFormatUtil;
4848
import java.util.ArrayList;
4949
import java.util.List;
5050
import java.util.regex.Matcher;
@@ -138,25 +138,25 @@ private FontFace(String alias, List<FontFaceSrc> sources) {
138138
* Class that defines a font face source.
139139
*/
140140
static class FontFaceSrc {
141-
141+
142142
/** The UrlPattern used to compose a source path. */
143143
static final Pattern UrlPattern = Pattern.compile("^((local)|(url))\\(((\'[^\']*\')|(\"[^\"]*\")|([^\'\"\\)]*))\\)( format\\(((\'[^\']*\')|(\"[^\"]*\")|([^\'\"\\)]*))\\))?$");
144-
144+
145145
/** The Constant TypeGroup. */
146146
static final int TypeGroup = 1;
147-
147+
148148
/** The Constant UrlGroup. */
149149
static final int UrlGroup = 4;
150-
150+
151151
/** The Constant FormatGroup. */
152152
static final int FormatGroup = 9;
153153

154154
/** The font format. */
155155
final FontFormat format;
156-
156+
157157
/** The source path. */
158158
final String src;
159-
159+
160160
/** Indicates if the font is local. */
161161
final boolean isLocal;
162162

@@ -165,7 +165,7 @@ static class FontFaceSrc {
165165
*/
166166
@Override
167167
public String toString() {
168-
return MessageFormat.format("{0}({1}){2}", isLocal ? "local" : "url", src, format != FontFormat.None ? MessageFormat.format(" format({0})", format) : "");
168+
return MessageFormatUtil.format("{0}({1}){2}", isLocal ? "local" : "url", src, format != FontFormat.None ? MessageFormatUtil.format(" format({0})", format) : "");
169169
}
170170

171171
/**
@@ -245,15 +245,15 @@ private FontFaceSrc(String src, boolean isLocal, FontFormat format) {
245245
enum FontFormat {
246246
None,
247247
/** "truetype" */
248-
TrueType,
248+
TrueType,
249249
/** "opentype" */
250-
OpenType,
250+
OpenType,
251251
/** "woff" */
252-
WOFF,
252+
WOFF,
253253
/** "woff2" */
254-
WOFF2,
254+
WOFF2,
255255
/** "embedded-opentype" */
256-
EOT,
256+
EOT,
257257
/** "svg" */
258258
SVG
259259
}

src/main/java/com/itextpdf/html2pdf/attach/impl/OutlineHandler.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
This file is part of the iText (R) project.
33
Copyright (c) 1998-2017 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
5-
5+
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU Affero General Public License version 3
88
as published by the Free Software Foundation with the addition of the
99
following permission added to Section 15 as permitted in Section 7(a):
1010
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
1111
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
1212
OF THIRD PARTY RIGHTS
13-
13+
1414
This program is distributed in the hope that it will be useful, but
1515
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1616
or FITNESS FOR A PARTICULAR PURPOSE.
@@ -20,23 +20,23 @@ This file is part of the iText (R) project.
2020
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2121
Boston, MA, 02110-1301 USA, or download the license from the following URL:
2222
http://itextpdf.com/terms-of-use/
23-
23+
2424
The interactive user interfaces in modified source and object code versions
2525
of this program must display Appropriate Legal Notices, as required under
2626
Section 5 of the GNU Affero General Public License.
27-
27+
2828
In accordance with Section 7(b) of the GNU Affero General Public License,
2929
a covered work must retain the producer line in every PDF that is created
3030
or manipulated using iText.
31-
31+
3232
You can be released from the requirements of the license by purchasing
3333
a commercial license. Buying such a license is mandatory as soon as you
3434
develop commercial activities involving the iText software without
3535
disclosing the source code of your own applications.
3636
These activities include: offering paid services to customers as an ASP,
3737
serving PDFs on the fly in a web application, shipping iText with a closed
3838
source product.
39-
39+
4040
For more information, please contact iText Software Corp. at this
4141
address: sales@itextpdf.com
4242
*/
@@ -55,19 +55,19 @@ This file is part of the iText (R) project.
5555
import org.slf4j.Logger;
5656
import org.slf4j.LoggerFactory;
5757

58-
import java.text.MessageFormat;
58+
import com.itextpdf.io.util.MessageFormatUtil;
5959
import java.util.Deque;
6060
import java.util.HashMap;
6161
import java.util.LinkedList;
6262
import java.util.Map;
6363

6464
/**
6565
* A {@link OutlineHandler} handles creating outlines for tags.
66-
*
66+
*
6767
* This class is not reusable and a new instance shall be created for every new conversion process.
6868
*/
6969
public class OutlineHandler {
70-
70+
7171
/** The Constant DESTINATION_PREFIX. */
7272
private static final String DESTINATION_PREFIX = "pdfHTML-iText-outline-";
7373

@@ -76,13 +76,13 @@ public class OutlineHandler {
7676

7777
/** The destinations in process. */
7878
private Deque<String> destinationsInProcess = new LinkedList<String>();
79-
79+
8080
/** The levels in process. */
8181
private Deque<Integer> levelsInProcess = new LinkedList<Integer>();
8282

8383
/** The tag priorities mapping. */
8484
private Map<String, Integer> tagPrioritiesMapping = new HashMap<String, Integer>();
85-
85+
8686
/** The unique IDs. */
8787
private Map<String, Integer> uniqueIDs = new HashMap<String, Integer>();
8888

@@ -197,7 +197,7 @@ OutlineHandler addDestination(ITagWorker tagWorker, IElementNode element) {
197197
tagWorker.getElementResult().setProperty(Property.DESTINATION, content);
198198
} else {
199199
Logger logger = LoggerFactory.getLogger(OutlineHandler.class);
200-
logger.warn(MessageFormat.format(LogMessageConstant.NO_IPROPERTYCONTAINER_RESULT_FOR_THE_TAG, tagName));
200+
logger.warn(MessageFormatUtil.format(LogMessageConstant.NO_IPROPERTYCONTAINER_RESULT_FOR_THE_TAG, tagName));
201201
}
202202
}
203203
return this;

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/PageSizeParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This file is part of the iText (R) project.
4747
import com.itextpdf.html2pdf.css.util.CssUtils;
4848
import com.itextpdf.kernel.geom.PageSize;
4949
import com.itextpdf.layout.property.UnitValue;
50-
import java.text.MessageFormat;
50+
import com.itextpdf.io.util.MessageFormatUtil;
5151
import java.util.HashMap;
5252
import java.util.Map;
5353
import org.slf4j.Logger;
@@ -97,7 +97,7 @@ static PageSize fetchPageSize(String pageSizeStr, float em, float rem, PageSize
9797
pageSize = pageSizeBasedOnLength;
9898
} else {
9999
Logger logger = LoggerFactory.getLogger(PageSizeParser.class);
100-
logger.error(MessageFormat.format(LogMessageConstant.PAGE_SIZE_VALUE_IS_INVALID, pageSizeStr));
100+
logger.error(MessageFormatUtil.format(LogMessageConstant.PAGE_SIZE_VALUE_IS_INVALID, pageSizeStr));
101101
}
102102
} else {
103103
Boolean landscape = null;
@@ -129,7 +129,7 @@ static PageSize fetchPageSize(String pageSizeStr, float em, float rem, PageSize
129129
}
130130
} else {
131131
Logger logger = LoggerFactory.getLogger(PageSizeParser.class);
132-
logger.error(MessageFormat.format(LogMessageConstant.PAGE_SIZE_VALUE_IS_INVALID, pageSizeStr));
132+
logger.error(MessageFormatUtil.format(LogMessageConstant.PAGE_SIZE_VALUE_IS_INVALID, pageSizeStr));
133133
}
134134
}
135135

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/ButtonRenderer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
This file is part of the iText (R) project.
33
Copyright (c) 1998-2017 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
5-
5+
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU Affero General Public License version 3
88
as published by the Free Software Foundation with the addition of the
99
following permission added to Section 15 as permitted in Section 7(a):
1010
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
1111
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
1212
OF THIRD PARTY RIGHTS
13-
13+
1414
This program is distributed in the hope that it will be useful, but
1515
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1616
or FITNESS FOR A PARTICULAR PURPOSE.
@@ -20,29 +20,29 @@ This file is part of the iText (R) project.
2020
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2121
Boston, MA, 02110-1301 USA, or download the license from the following URL:
2222
http://itextpdf.com/terms-of-use/
23-
23+
2424
The interactive user interfaces in modified source and object code versions
2525
of this program must display Appropriate Legal Notices, as required under
2626
Section 5 of the GNU Affero General Public License.
27-
27+
2828
In accordance with Section 7(b) of the GNU Affero General Public License,
2929
a covered work must retain the producer line in every PDF that is created
3030
or manipulated using iText.
31-
31+
3232
You can be released from the requirements of the license by purchasing
3333
a commercial license. Buying such a license is mandatory as soon as you
3434
develop commercial activities involving the iText software without
3535
disclosing the source code of your own applications.
3636
These activities include: offering paid services to customers as an ASP,
3737
serving PDFs on the fly in a web application, shipping iText with a closed
3838
source product.
39-
39+
4040
For more information, please contact iText Software Corp. at this
4141
address: sales@itextpdf.com
4242
*/
4343
package com.itextpdf.html2pdf.attach.impl.layout.form.renderer;
4444

45-
import java.text.MessageFormat;
45+
import com.itextpdf.io.util.MessageFormatUtil;
4646
import java.util.List;
4747

4848
import org.slf4j.LoggerFactory;
@@ -108,7 +108,7 @@ protected void adjustFieldLayout() {
108108
flatBBox.setWidth(drawnLine.getOccupiedArea().getBBox().getWidth());
109109
}
110110
} else {
111-
LoggerFactory.getLogger(getClass()).error(MessageFormat.format(LogMessageConstant.ERROR_WHILE_LAYOUT_OF_FORM_FIELD_WITH_TYPE, "button"));
111+
LoggerFactory.getLogger(getClass()).error(MessageFormatUtil.format(LogMessageConstant.ERROR_WHILE_LAYOUT_OF_FORM_FIELD_WITH_TYPE, "button"));
112112
setProperty(Html2PdfProperty.FORM_FIELD_FLATTEN, true);
113113
baseline = flatBBox.getTop();
114114
flatBBox.setY(baseline).setHeight(0);

0 commit comments

Comments
 (0)