@@ -264,6 +264,81 @@ private XMLDocument(
264
264
this .cache = cache ;
265
265
}
266
266
267
+ /**
268
+ * Factory method, to avoid checked exceptions.
269
+ * @param file The path of the XML
270
+ * @return XML
271
+ * @since 0.35.0
272
+ */
273
+ @ SuppressWarnings ("PMD.ProhibitPublicStaticMethods" )
274
+ public static XML make (final File file ) {
275
+ try {
276
+ return new XMLDocument (file );
277
+ } catch (final FileNotFoundException ex ) {
278
+ throw new IllegalArgumentException (ex );
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Factory method, to avoid checked exceptions.
284
+ * @param file The path of the XML
285
+ * @return XML
286
+ * @since 0.35.0
287
+ */
288
+ @ SuppressWarnings ("PMD.ProhibitPublicStaticMethods" )
289
+ public static XML make (final Path file ) {
290
+ try {
291
+ return new XMLDocument (file );
292
+ } catch (final FileNotFoundException ex ) {
293
+ throw new IllegalArgumentException (ex );
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Factory method, to avoid checked exceptions.
299
+ * @param uri The URI of the XML
300
+ * @return XML
301
+ * @since 0.35.0
302
+ */
303
+ @ SuppressWarnings ("PMD.ProhibitPublicStaticMethods" )
304
+ public static XML make (final URI uri ) {
305
+ try {
306
+ return new XMLDocument (uri );
307
+ } catch (final IOException ex ) {
308
+ throw new IllegalArgumentException (ex );
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Factory method, to avoid checked exceptions.
314
+ * @param url The URL of the XML
315
+ * @return XML
316
+ * @since 0.35.0
317
+ */
318
+ @ SuppressWarnings ("PMD.ProhibitPublicStaticMethods" )
319
+ public static XML make (final URL url ) {
320
+ try {
321
+ return new XMLDocument (url );
322
+ } catch (final IOException ex ) {
323
+ throw new IllegalArgumentException (ex );
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Factory method, to avoid checked exceptions.
329
+ * @param stream The input stream with the XML
330
+ * @return XML
331
+ * @since 0.35.0
332
+ */
333
+ @ SuppressWarnings ("PMD.ProhibitPublicStaticMethods" )
334
+ public static XML make (final InputStream stream ) {
335
+ try {
336
+ return new XMLDocument (stream );
337
+ } catch (final IOException ex ) {
338
+ throw new IllegalArgumentException (ex );
339
+ }
340
+ }
341
+
267
342
@ Override
268
343
public String toString () {
269
344
return XMLDocument .asString (this .cache );
0 commit comments