Skip to content

Commit d970456

Browse files
Use custom MessageFormatUtil class instead of MessageFormat class
1 parent cb37a0b commit d970456

File tree

61 files changed

+218
-219
lines changed

Some content is hidden

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

61 files changed

+218
-219
lines changed

forms/src/main/java/com/itextpdf/forms/PdfPageFormCopier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ This file is part of the iText (R) project.
5050
import org.slf4j.Logger;
5151
import org.slf4j.LoggerFactory;
5252

53-
import java.text.MessageFormat;
53+
import com.itextpdf.io.util.MessageFormatUtil;
5454
import java.util.*;
5555

5656
/**
@@ -146,7 +146,7 @@ public void copy(PdfPage fromPage, PdfPage toPage) {
146146
toPage.removeAnnotation(annot);
147147
field = mergeFieldsWithTheSameName(PdfFormField.makeFormField(clonedAnnot, toPage.getDocument()));
148148

149-
logger.warn(MessageFormat.format(LogMessageConstant.DOCUMENT_ALREADY_HAS_FIELD, annotNameString));
149+
logger.warn(MessageFormatUtil.format(LogMessageConstant.DOCUMENT_ALREADY_HAS_FIELD, annotNameString));
150150
PdfArray kids = field.getKids();
151151
if (kids != null) {
152152
field.getPdfObject().remove(PdfName.Kids);

io/src/main/java/com/itextpdf/io/IOException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.io;
4545

46-
import java.text.MessageFormat;
46+
import com.itextpdf.io.util.MessageFormatUtil;
4747
import java.util.ArrayList;
4848
import java.util.Collections;
4949
import java.util.List;
@@ -251,7 +251,7 @@ public String getMessage() {
251251
if (messageParams == null || messageParams.size() == 0) {
252252
return super.getMessage();
253253
} else {
254-
return MessageFormat.format(super.getMessage(), getMessageParams());
254+
return MessageFormatUtil.format(super.getMessage(), getMessageParams());
255255
}
256256
}
257257

io/src/main/java/com/itextpdf/io/font/FontProgramFactory.java

Lines changed: 2 additions & 2 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.io.source.RandomAccessFileOrArray;
4848
import com.itextpdf.io.source.RandomAccessSourceFactory;
4949

50-
import java.text.MessageFormat;
50+
import com.itextpdf.io.util.MessageFormatUtil;
5151
import java.util.Set;
5252

5353
/**
@@ -491,7 +491,7 @@ static byte[] readFontBytesFromPath(String path) throws java.io.IOException {
491491
RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(path));
492492
int bufLen = (int) raf.length();
493493
if (bufLen < raf.length()) {
494-
throw new IOException(MessageFormat.format("Source data from \"{0}\" is bigger than byte array can hold.", path));
494+
throw new IOException(MessageFormatUtil.format("Source data from \"{0}\" is bigger than byte array can hold.", path));
495495
}
496496
byte[] buf = new byte[bufLen];
497497
raf.readFully(buf);

io/src/main/java/com/itextpdf/io/font/FontRegisterProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This file is part of the iText (R) project.
4848
import org.slf4j.Logger;
4949
import org.slf4j.LoggerFactory;
5050

51-
import java.text.MessageFormat;
51+
import com.itextpdf.io.util.MessageFormatUtil;
5252
import java.util.ArrayList;
5353
import java.util.HashMap;
5454
import java.util.List;
@@ -318,7 +318,7 @@ void registerFont(String path, String alias) {
318318
fontNames.put(psName, path);
319319
fontNames.put(fullName, path);
320320
}
321-
LOGGER.trace(MessageFormat.format("Registered {0}", path));
321+
LOGGER.trace(MessageFormatUtil.format("Registered {0}", path));
322322
} catch (java.io.IOException e) {
323323
throw new IOException(e);
324324
}
@@ -355,7 +355,7 @@ int registerFontDirectory(String dir) {
355355
* @return the number of fonts registered
356356
*/
357357
int registerFontDirectory(String dir, boolean scanSubdirectories) {
358-
LOGGER.debug(MessageFormat.format("Registering directory {0}, looking for fonts", dir));
358+
LOGGER.debug(MessageFormatUtil.format("Registering directory {0}, looking for fonts", dir));
359359
int count = 0;
360360
try {
361361
String[] files = FileUtil.listFilesInDirectory(dir, scanSubdirectories);

io/src/main/java/com/itextpdf/io/font/TrueTypeFont.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This file is part of the iText (R) project.
5353
import org.slf4j.Logger;
5454
import org.slf4j.LoggerFactory;
5555

56-
import java.text.MessageFormat;
56+
import com.itextpdf.io.util.MessageFormatUtil;
5757
import java.util.LinkedHashMap;
5858
import java.util.Map;
5959
import java.util.Set;
@@ -296,7 +296,7 @@ private void initializeFontProperties() throws java.io.IOException {
296296
int index = cmap.get(charCode)[0];
297297
if (index >= maxGlyphId) {
298298
Logger LOGGER = LoggerFactory.getLogger(TrueTypeFont.class);
299-
LOGGER.warn(MessageFormat.format(LogMessageConstant.FONT_HAS_INVALID_GLYPH, getFontNames().getFontName(), index));
299+
LOGGER.warn(MessageFormatUtil.format(LogMessageConstant.FONT_HAS_INVALID_GLYPH, getFontNames().getFontName(), index));
300300
continue;
301301
}
302302
Glyph glyph = new Glyph(index, glyphWidths[index], charCode, bBoxes != null ? bBoxes[index] : null);

io/src/main/java/com/itextpdf/io/font/otf/Glyph.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import com.itextpdf.io.util.TextUtil;
4747

4848
import java.io.Serializable;
49-
import java.text.MessageFormat;
49+
import com.itextpdf.io.util.MessageFormatUtil;
5050
import java.util.Arrays;
5151

5252
public class Glyph implements Serializable {
@@ -336,7 +336,7 @@ public char[] getUnicodeChars() {
336336
}
337337

338338
public String toString() {
339-
return MessageFormat.format("[id={0}, chars={1}, uni={2}, width={3}]",
339+
return MessageFormatUtil.format("[id={0}, chars={1}, uni={2}, width={3}]",
340340
toHex(code), chars != null ? Arrays.toString(chars) : "null", toHex(unicode), width);
341341
}
342342

io/src/main/java/com/itextpdf/io/font/otf/OtfReadCommon.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This file is part of the iText (R) project.
4545

4646
import com.itextpdf.io.source.RandomAccessFileOrArray;
4747

48-
import java.text.MessageFormat;
48+
import com.itextpdf.io.util.MessageFormatUtil;
4949
import java.util.ArrayList;
5050
import java.util.Collections;
5151
import java.util.HashSet;
@@ -61,7 +61,7 @@ public static int[] readUShortArray(RandomAccessFileOrArray rf, int size, int lo
6161
}
6262
return ret;
6363
}
64-
64+
6565
public static int[] readUShortArray(RandomAccessFileOrArray rf, int size) throws java.io.IOException {
6666
return readUShortArray(rf, size, 0);
6767
}
@@ -92,7 +92,7 @@ public static List<Integer> readCoverageFormat(RandomAccessFileOrArray rf, int c
9292
}
9393

9494
} else {
95-
throw new UnsupportedOperationException(MessageFormat.format("Invalid coverage format: {0}", coverageFormat));
95+
throw new UnsupportedOperationException(MessageFormatUtil.format("Invalid coverage format: {0}", coverageFormat));
9696
}
9797

9898
return Collections.unmodifiableList(glyphIds);
@@ -136,7 +136,7 @@ public static GposValueRecord readGposValueRecord(OpenTypeFontTableReader tableR
136136
}
137137
return vr;
138138
}
139-
139+
140140
public static GposAnchor readGposAnchor(OpenTypeFontTableReader tableReader, int location) throws java.io.IOException {
141141
if (location == 0) {
142142
return null;
@@ -155,7 +155,7 @@ public static GposAnchor readGposAnchor(OpenTypeFontTableReader tableReader, int
155155

156156
return t;
157157
}
158-
158+
159159
public static List<OtfMarkRecord> readMarkArray(OpenTypeFontTableReader tableReader, int location) throws java.io.IOException {
160160
tableReader.rf.seek(location);
161161
int markCount = tableReader.rf.readUnsignedShort();
@@ -175,7 +175,7 @@ public static List<OtfMarkRecord> readMarkArray(OpenTypeFontTableReader tableRea
175175
}
176176
return marks;
177177
}
178-
178+
179179
public static SubstLookupRecord[] readSubstLookupRecords(RandomAccessFileOrArray rf, int substCount) throws java.io.IOException {
180180
SubstLookupRecord[] substPosLookUpRecords = new SubstLookupRecord[substCount];
181181
for (int i = 0; i < substCount; ++i) {

io/src/main/java/com/itextpdf/io/image/JpegImageHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This file is part of the iText (R) project.
4848
import com.itextpdf.io.color.IccProfile;
4949

5050
import java.io.InputStream;
51-
import java.text.MessageFormat;
51+
import com.itextpdf.io.util.MessageFormatUtil;
5252
import java.util.HashMap;
5353
import java.util.Map;
5454

@@ -314,7 +314,7 @@ private static void processParameters(InputStream jpegStream, String errorID, Im
314314
// make sure this is consistent with JFIF data
315315
if (image.getDpiX() != 0 && image.getDpiX() != dx) {
316316
Logger logger = LoggerFactory.getLogger(JpegImageHelper.class);
317-
logger.debug(MessageFormat.format("Inconsistent metadata (dpiX: {0} vs {1})", image.getDpiX(), dx));
317+
logger.debug(MessageFormatUtil.format("Inconsistent metadata (dpiX: {0} vs {1})", image.getDpiX(), dx));
318318
} else {
319319
image.setDpi(dx, image.getDpiY());
320320
}
@@ -324,7 +324,7 @@ private static void processParameters(InputStream jpegStream, String errorID, Im
324324
// make sure this is consistent with JFIF data
325325
if (image.getDpiY() != 0 && image.getDpiY() != dy) {
326326
Logger logger = LoggerFactory.getLogger(JpegImageHelper.class);
327-
logger.debug(MessageFormat.format("Inconsistent metadata (dpiY: {0} vs {1})", image.getDpiY(), dy));
327+
logger.debug(MessageFormatUtil.format("Inconsistent metadata (dpiY: {0} vs {1})", image.getDpiY(), dy));
328328
} else {
329329
image.setDpi(image.getDpiX(), dx);
330330
}

io/src/main/java/com/itextpdf/io/image/PngImageHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This file is part of the iText (R) project.
5353

5454
import java.io.ByteArrayInputStream;
5555
import java.io.InputStream;
56-
import java.text.MessageFormat;
56+
import com.itextpdf.io.util.MessageFormatUtil;
5757
import java.util.HashMap;
5858
import java.util.Map;
5959

@@ -210,7 +210,7 @@ private static void processPng(InputStream pngStream, PngParameters png) throws
210210
png.palShades = true;
211211
png.genBWMask = (!png.palShades && (pal0 > 1 || png.transRedGray >= 0));
212212
if (!png.palShades && !png.genBWMask && pal0 == 1) {
213-
png.additional.put("Mask", MessageFormat.format("[{0} {1}]", palIdx, palIdx));
213+
png.additional.put("Mask", MessageFormatUtil.format("[{0} {1}]", palIdx, palIdx));
214214
}
215215
boolean needDecode = (png.interlaceMethod == 1) || (png.bitDepth == 16) || ((png.colorType & 4) != 0) || png.palShades || png.genBWMask;
216216
switch (png.colorType) {
@@ -379,7 +379,7 @@ private static void readPng(InputStream pngStream, PngParameters png) throws jav
379379
if (png.bitDepth == 16)
380380
png.transRedGray = gray;
381381
else
382-
png.additional.put("Mask", MessageFormat.format("[{0} {1}]", gray, gray));
382+
png.additional.put("Mask", MessageFormatUtil.format("[{0} {1}]", gray, gray));
383383
}
384384
break;
385385
case 2:
@@ -393,7 +393,7 @@ private static void readPng(InputStream pngStream, PngParameters png) throws jav
393393
png.transGreen = green;
394394
png.transBlue = blue;
395395
} else
396-
png.additional.put("Mask", MessageFormat.format("[{0} {1} {2} {3} {4} {5}]", red, red, green, green, blue, blue));
396+
png.additional.put("Mask", MessageFormatUtil.format("[{0} {1} {2} {3} {4} {5}]", red, red, green, green, blue, blue));
397397
}
398398
break;
399399
case 3:

io/src/main/java/com/itextpdf/io/source/ByteBuffer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This file is part of the iText (R) project.
4444
package com.itextpdf.io.source;
4545

4646
import java.io.Serializable;
47-
import java.text.MessageFormat;
47+
import com.itextpdf.io.util.MessageFormatUtil;
4848

4949
public class ByteBuffer implements Serializable {
5050

@@ -121,7 +121,7 @@ public ByteBuffer appendHex(byte b) {
121121

122122
public byte get(int index) {
123123
if (index >= count) {
124-
throw new IndexOutOfBoundsException(MessageFormat.format("Index: {0}, Size: {1}", index, count));
124+
throw new IndexOutOfBoundsException(MessageFormatUtil.format("Index: {0}, Size: {1}", index, count));
125125
}
126126
return buffer[index];
127127
}

0 commit comments

Comments
 (0)