11package com .itextpdf .io ;
22
3+ import java .text .MessageFormat ;
34import java .util .ArrayList ;
45import java .util .Collections ;
56import java .util .List ;
67
78public class IOException extends RuntimeException {
89
9- public static final String _1BitSamplesAreNotSupportedForHorizontalDifferencingPredictor = "1. bit.samples.are.not.supported.for.horizontal.differencing.predictor" ;
10- public static final String _1CorruptedJfifMarker = "1. corrupted.jfif.marker" ;
11- public static final String _1IsNotAValidJpegFile = "1. is.not.a.valid.jpeg.file" ;
12- public static final String _1MustHave8BitsPerComponent = "1. must.have.8.bits.per.component" ;
13- public static final String _1UnsupportedJpegMarker2 = "1. unsupported.jpeg.marker.2 " ;
14- public static final String _1IsNotAnAFMorPfmFontFile = "1. is.not.an.afm.or.pfm.font.file" ;
10+ public static final String _1BitSamplesAreNotSupportedForHorizontalDifferencingPredictor = "{0} bit.samples.are.not.supported.for.horizontal.differencing.predictor" ;
11+ public static final String _1CorruptedJfifMarker = "{0} corrupted.jfif.marker" ;
12+ public static final String _1IsNotAValidJpegFile = "{0} is.not.a.valid.jpeg.file" ;
13+ public static final String _1MustHave8BitsPerComponent = "{0} must.have.8.bits.per.component" ;
14+ public static final String _1UnsupportedJpegMarker2 = "{0} unsupported.jpeg.marker {1} " ;
15+ public static final String _1IsNotAnAFMorPfmFontFile = "{0} is.not.an.afm.or.pfm.font.file" ;
1516
1617 public static final String AllFillBitsPrecedingEolCodeMustBe0 = "all.fill.bits.preceding.eol.code.must.be.0" ;
1718 public static final String BadEndiannessTagNot0x4949Or0x4d4d = "bad.endianness.tag.not.0x4949.or.0x4d4d" ;
1819 public static final String BadMagicNumberShouldBe42 = "bad.magic.number.should.be.42" ;
1920 public static final String BitsPerComponentMustBe1_2_4or8 = "bits.per.component.must.be.1.2.4.or.8" ;
20- public static final String BitsPerSample1IsNotSupported = "bits.per.sample.1. is.not.supported" ;
21+ public static final String BitsPerSample1IsNotSupported = "bits.per.sample {0} is.not.supported" ;
2122 public static final String BmpImageException = "bmp.image.exception" ;
2223 public static final String BytesCanBeAssignedToByteArrayOutputStreamOnly = "bytes.can.be.assigned.to.bytearrayoutputstream.only" ;
2324 public static final String BytesCanBeResetInByteArrayOutputStreamOnly = "bytes.can.be.reset.in.bytearrayoutputstream.only" ;
2425
2526 public static final String CannotGetTiffImageColor = "cannot.get.tiff.image.color" ;
26- public static final String CannotFind1Frame = "cannot.find.1. frame" ;
27+ public static final String CannotFind1Frame = "cannot.find {0} frame" ;
2728 public static final String CannotHandleBoxSizesHigherThan2_32 = "cannot.handle.box.sizes.higher.than.2.32" ;
2829 public static final String CannotInflateTiffImage = "cannot.inflate.tiff.image" ;
2930 public static final String CannotReadTiffImage = "cannot.read.tiff.image" ;
@@ -33,12 +34,12 @@ public class IOException extends RuntimeException {
3334 public static final String CannotWriteIntNumber = "cannot.write.int.number" ;
3435 public static final String CcittCompressionTypeMustBeCcittg4Ccittg3_1dOrCcittg3_2d = "ccitt.compression.type.must.be.ccittg4.ccittg3.1d.or.ccittg3.2d" ;
3536 public static final String ComponentsMustBe1_3Or4 = "components.must.be.1.3.or.4" ;
36- public static final String Compression1IsNotSupported = "compression.1. is.not.supported" ;
37- public static final String CompressionJpegIsOnlySupportedWithASingleStripThisImageHas1Strips = "compression.jpeg.is.only.supported.with.a.single.strip.this.image.has.1. strips" ;
37+ public static final String Compression1IsNotSupported = "compression {0} is.not.supported" ;
38+ public static final String CompressionJpegIsOnlySupportedWithASingleStripThisImageHas1Strips = "compression.jpeg.is.only.supported.with.a.single.strip.this.image.has {0} strips" ;
3839 public static final String DirectoryNumberTooLarge = "directory.number.too.large" ;
3940 public static final String EolCodeWordEncounteredInBlackRun = "eol.code.word.encountered.in.black.run" ;
4041 public static final String EolCodeWordEncounteredInWhiteRun = "eol.code.word.encountered.in.white.run" ;
41- public static final String ErrorAtFilePointer1 = "error.at.file.pointer.1 " ;
42+ public static final String ErrorAtFilePointer1 = "error.at.file.pointer {0} " ;
4243 public static final String ErrorReadingString = "error.reading.string" ;
4344 public static final String ErrorWithJpMarker = "error.with.jp.marker" ;
4445
@@ -51,22 +52,21 @@ public class IOException extends RuntimeException {
5152 public static final String FdfStartxrefNotFound = "fdf.startxref.not.found" ;
5253
5354 public static final String FirstScanlineMustBe1dEncoded = "first.scanline.must.be.1d.encoded" ;
54- // TODO parametrized message
55- public static final String FontFileNotFound = "font.file.not.found" ;
55+ public static final String FontFile1NotFound = "font.file {0} not.found" ;
5656 public static final String ImageFormatCannotBeRecognized = "image.format.cannot.be.recognized" ;
5757 public static final String GifImageException = "gif.image.exception" ;
5858 public static final String GtNotExpected = "gt.not.expected" ;
5959 public static final String GifSignatureNotFound = "gif.signature.not.found" ;
6060 public static final String IllegalValueForPredictorInTiffFile = "illegal.value.for.predictor.in.tiff.file" ;
61- public static final String Font1IsNotRecognized = "font.1. is.not.recognized" ;
61+ public static final String Font1IsNotRecognized = "font {0} is.not.recognized" ;
6262 public static final String FontIsNotRecognized = "font.is.not.recognized" ;
6363
6464 public static final String ImageCanNotBeAnImageMask = "image.can.not.be.an.image.mask" ;
6565 public static final String ImageMaskCannotContainAnotherImageMask = "image.mask.cannot.contain.another.image.mask" ;
6666 public static final String ImageMaskIsNotAMaskDidYouDoMakeMask = "image.mask.is.not.a.mask.did.you.do.makemask" ;
6767 public static final String IncompletePalette = "incomplete.palette" ;
6868
69- public static final String InvalidTTCFile = "1. is.not.a.valid.ttc.file" ;
69+ public static final String InvalidTTCFile = "{0} is.not.a.valid.ttc.file" ;
7070 public static final String InvalidBmpFileCompression = "invalid.bmp.file.compression" ;
7171 public static final String InvalidCodeEncountered = "invalid.code.encountered" ;
7272 public static final String InvalidCodeEncounteredWhileDecoding2dGroup3CompressedData = "invalid.code.encountered.while.decoding.2d.group.3.compressed.data" ;
@@ -79,7 +79,7 @@ public class IOException extends RuntimeException {
7979 public static final String JpegImageException = "jpeg.image.exception" ;
8080 public static final String Jpeg2000ImageException = "jpeg2000.image.exception" ;
8181 public static final String MissingTagSForOjpegCompression = "missing.tag.s.for.ojpeg.compression" ;
82- public static final String PageNumberMustBeGtEq1 = "page.number.must.be.gt.eq.1 " ;
82+ public static final String PageNumberMustBeGtEq1 = "page.number.must.be.gt.eq {0} " ;
8383 public static final String PdfEncodings = "pdf.encodings" ;
8484 public static final String PdfHeaderNotFound = "pdf.header.not.found" ;
8585 public static final String PdfStartxrefNotFound = "pdf.startxref.not.found" ;
@@ -97,15 +97,13 @@ public class IOException extends RuntimeException {
9797 public static final String TransparencyLengthMustBeEqualTo2WithCcittImages = "transparency.length.must.be.equal.to.2.with.ccitt.images" ;
9898 public static final String UnexpectedCloseBracket = "unexpected.close.bracket" ;
9999 public static final String UnexpectedGtGt = "unexpected.gt.gt" ;
100- public static final String UnknownCompressionType1 = "unknown.compression.type.1 " ;
100+ public static final String UnknownCompressionType1 = "unknown.compression.type {0} " ;
101101 public static final String UnsupportedBoxSizeEqEq0 = "unsupported.box.size.eq.eq.0" ;
102- public static final String WrongNumberOfComponentsInIccProfile = "icc.profile.contains.1. components.the.image.data.contains.2. components" ;
102+ public static final String WrongNumberOfComponentsInIccProfile = "icc.profile.contains {0} components.the.image.data.contains {2} components" ;
103103
104104 protected Object object ;
105105 private List <Object > messageParams ;
106106
107- private final String ERROR_MESSAGE_LOCALE_PATH = "com.itextpdf.io.l10n.error.exception_messages" ;
108-
109107 public IOException (String message ) {
110108 super (message );
111109 }
@@ -130,7 +128,11 @@ public IOException(String message, Throwable cause, Object object) {
130128
131129 @ Override
132130 public String getMessage () {
133- return ResourceLocaleBundle .getMessage (ERROR_MESSAGE_LOCALE_PATH , super .getMessage (), messageParams );
131+ if (messageParams == null || messageParams .isEmpty ()) {
132+ return super .getMessage ();
133+ } else {
134+ return MessageFormat .format (super .getMessage (), messageParams .toArray ());
135+ }
134136 }
135137
136138 public IOException setMessageParams (Object ... messageParams ) {
0 commit comments