Skip to content

Commit

Permalink
make(URL) methods for XSDDocument and XSLDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Jan 14, 2014
1 parent c9a0854 commit c1de892
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/xml/StrictXML.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public Node node() {
* @param errors The errors
* @return List of messages to print
*/
private static Collection<String> print(
private static Iterable<String> print(
final Collection<SAXParseException> errors) {
final Collection<String> lines = new ArrayList<String>(errors.size());
for (final SAXParseException error : errors) {
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/jcabi/xml/XSDDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/jcabi/xml/XSLDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c1de892

Please sign in to comment.