From c1de892f7a5b51131b9d098f81e32c60df78d875 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Tue, 14 Jan 2014 13:59:11 +0100 Subject: [PATCH] make(URL) methods for XSDDocument and XSLDocument --- src/main/java/com/jcabi/xml/StrictXML.java | 2 +- src/main/java/com/jcabi/xml/XSDDocument.java | 17 +++++++++++++++++ src/main/java/com/jcabi/xml/XSLDocument.java | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jcabi/xml/StrictXML.java b/src/main/java/com/jcabi/xml/StrictXML.java index cefa9b3a..0734ece2 100644 --- a/src/main/java/com/jcabi/xml/StrictXML.java +++ b/src/main/java/com/jcabi/xml/StrictXML.java @@ -121,7 +121,7 @@ public Node node() { * @param errors The errors * @return List of messages to print */ - private static Collection print( + private static Iterable print( final Collection errors) { final Collection lines = new ArrayList(errors.size()); for (final SAXParseException error : errors) { diff --git a/src/main/java/com/jcabi/xml/XSDDocument.java b/src/main/java/com/jcabi/xml/XSDDocument.java index 90319487..d044c172 100644 --- a/src/main/java/com/jcabi/xml/XSDDocument.java +++ b/src/main/java/com/jcabi/xml/XSDDocument.java @@ -92,6 +92,7 @@ public XSDDocument(@NotNull(message = "XSD text can't be NULL") * Public ctor, from URL. * @param url Location of document * @throws IOException If fails to read + * @since 0.7.4 */ public XSDDocument(@NotNull(message = "URL can't be NULL") final URL url) throws IOException { @@ -133,6 +134,22 @@ public static XSD make(@NotNull(message = "XSD input stream can't be NULL") } } + /** + * Make an instance of XSD schema without I/O exceptions. + * @param url URL with content + * @return XSD schema + * @see #make(InputStream) + * @since 0.7.4 + */ + public static XSD make(@NotNull(message = "URL can't be NULL") + final URL url) { + try { + return new XSDDocument(url); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + } + @Override public String toString() { return new XMLDocument(this.xsd).toString(); diff --git a/src/main/java/com/jcabi/xml/XSLDocument.java b/src/main/java/com/jcabi/xml/XSLDocument.java index c54c6f56..d64845c1 100644 --- a/src/main/java/com/jcabi/xml/XSLDocument.java +++ b/src/main/java/com/jcabi/xml/XSLDocument.java @@ -102,6 +102,7 @@ public XSLDocument(@NotNull(message = "XSL can't be NULL") * Public ctor, from URL. * @param url Location of document * @throws IOException If fails to read + * @since 0.7.4 */ public XSLDocument(@NotNull(message = "URL can't be NULL") final URL url) throws IOException { @@ -143,6 +144,22 @@ public static XSL make(@NotNull(message = "XSL input stream can't be NULL") } } + /** + * Make an instance of XSL stylesheet without I/O exceptions. + * @param url URL with content + * @return XSL stylesheet + * @see #make(InputStream) + * @since 0.7.4 + */ + public static XSL make(@NotNull(message = "URL can't be NULL") + final URL url) { + try { + return new XSLDocument(url); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + } + @Override public String toString() { return new XMLDocument(this.xsl).toString();