Skip to content

Commit 981acc7

Browse files
committed
Encapsulate scijava-meta javax.xml module dep
1 parent e3b4aa7 commit 981acc7

File tree

3 files changed

+33
-47
lines changed

3 files changed

+33
-47
lines changed

scijava-meta/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929

3030
module org.scijava.meta {
31-
requires transitive java.xml;
31+
requires java.xml;
3232

3333
requires org.scijava.common3;
3434

scijava-meta/src/main/java/org/scijava/meta/POM.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@
3535
import java.net.URL;
3636
import java.util.*;
3737

38-
import javax.xml.parsers.ParserConfigurationException;
39-
4038
import org.scijava.common3.Apps;
4139
import org.scijava.common3.Classes;
4240
import org.scijava.common3.URLs;
4341
import org.scijava.common3.Versioned;
44-
import org.xml.sax.SAXException;
4542

4643
/**
4744
* Helper class for working with Maven POMs.
@@ -53,30 +50,22 @@ public class POM extends XML implements Comparable<POM>, Versioned {
5350
private String version;
5451

5552
/** Parses a POM from the given file. */
56-
public POM(final File file) throws ParserConfigurationException, SAXException,
57-
IOException
58-
{
53+
public POM(final File file) throws IOException {
5954
super(file);
6055
}
6156

6257
/** Parses a POM from the given URL. */
63-
public POM(final URL url) throws ParserConfigurationException, SAXException,
64-
IOException
65-
{
58+
public POM(final URL url) throws IOException {
6659
super(url);
6760
}
6861

6962
/** Parses a POM from the given input stream. */
70-
public POM(final InputStream in) throws ParserConfigurationException,
71-
SAXException, IOException
72-
{
63+
public POM(final InputStream in) throws IOException {
7364
super(in);
7465
}
7566

7667
/** Parses a POM from the given string. */
77-
public POM(final String s) throws ParserConfigurationException, SAXException,
78-
IOException
79-
{
68+
public POM(final String s) throws IOException {
8069
super(s);
8170
}
8271

@@ -295,7 +284,7 @@ private static POM findPOM(final URL location, final String groupId,
295284
final File pomFile = new File(baseDir, "pom.xml");
296285
return new POM(pomFile);
297286
}
298-
catch (final IOException | ParserConfigurationException | SAXException e) {
287+
catch (final IOException e) {
299288
return null;
300289
}
301290
}
@@ -324,9 +313,7 @@ public static List<POM> getAllPOMs() {
324313
try {
325314
poms.add(new POM(url));
326315
}
327-
catch (final IOException | ParserConfigurationException
328-
| SAXException exc)
329-
{
316+
catch (final IOException exc) {
330317
// NB: empty catch block
331318
// ignore and continue
332319
}

scijava-meta/src/main/java/org/scijava/meta/XML.java

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,22 @@ public class XML {
8181
"scijava.log.level"));
8282

8383
/** Parses XML from the given file. */
84-
public XML(final File file) throws ParserConfigurationException, SAXException,
85-
IOException
86-
{
84+
public XML(final File file) throws IOException {
8785
this(file.getAbsolutePath(), loadXML(file));
8886
}
8987

9088
/** Parses XML from the given URL. */
91-
public XML(final URL url) throws ParserConfigurationException, SAXException,
92-
IOException
93-
{
89+
public XML(final URL url) throws IOException {
9490
this(url.getPath(), loadXML(url));
9591
}
9692

9793
/** Parses XML from the given input stream. */
98-
public XML(final InputStream in) throws ParserConfigurationException,
99-
SAXException, IOException
100-
{
94+
public XML(final InputStream in) throws IOException {
10195
this(null, loadXML(in));
10296
}
10397

10498
/** Parses XML from the given string. */
105-
public XML(final String s) throws ParserConfigurationException, SAXException,
106-
IOException
107-
{
99+
public XML(final String s) throws IOException {
108100
this(null, loadXML(s));
109101
}
110102

@@ -262,34 +254,41 @@ public static ArrayList<Element> elements(final Element el,
262254
// -- Helper methods --
263255

264256
/** Loads an XML document from the given file. */
265-
private static Document loadXML(final File file)
266-
throws ParserConfigurationException, SAXException, IOException
267-
{
268-
return createBuilder().parse(file.getAbsolutePath());
257+
private static Document loadXML(final File file) throws IOException {
258+
try {
259+
return createBuilder().parse(file.getAbsolutePath());
260+
}
261+
catch (ParserConfigurationException | SAXException exc) {
262+
throw new IOException(exc);
263+
}
269264
}
270265

271266
/** Loads an XML document from the given URL. */
272-
private static Document loadXML(final URL url)
273-
throws ParserConfigurationException, SAXException, IOException
274-
{
267+
private static Document loadXML(final URL url) throws IOException {
275268
try (final InputStream in = url.openStream()) {
276269
final Document document = loadXML(in);
277270
return document;
278271
}
279272
}
280273

281274
/** Loads an XML document from the given input stream. */
282-
protected static Document loadXML(final InputStream in)
283-
throws ParserConfigurationException, SAXException, IOException
284-
{
285-
return createBuilder().parse(in);
275+
protected static Document loadXML(final InputStream in) throws IOException {
276+
try {
277+
return createBuilder().parse(in);
278+
}
279+
catch (ParserConfigurationException | SAXException exc) {
280+
throw new IOException(exc);
281+
}
286282
}
287283

288284
/** Loads an XML document from the given input stream. */
289-
protected static Document loadXML(final String s)
290-
throws ParserConfigurationException, SAXException, IOException
291-
{
292-
return createBuilder().parse(new ByteArrayInputStream(s.getBytes()));
285+
protected static Document loadXML(final String s) throws IOException {
286+
try {
287+
return createBuilder().parse(new ByteArrayInputStream(s.getBytes()));
288+
}
289+
catch (ParserConfigurationException | SAXException exc) {
290+
throw new IOException(exc);
291+
}
293292
}
294293

295294
/** Creates an XML document builder. */

0 commit comments

Comments
 (0)