Skip to content

Commit

Permalink
Apply auto-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Sep 26, 2023
1 parent c636956 commit f08fbb9
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 72 deletions.
24 changes: 8 additions & 16 deletions api/src/main/java/org/openjax/xml/api/CharacterDatas.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,7 @@ private static StringBuilder unescape(final StringBuilder out, final char[] char
* </pre>
*
* @param str The string to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @return A new {@link StringBuilder} with the unescaped representation of {@code str}.
* @throws NullPointerException If {@code str} is null.
* @throws IllegalArgumentException If {@code quote} is not {@code '"'} or {@code '\''}.
Expand All @@ -721,8 +720,7 @@ public static StringBuilder unescapeFromAttr(final CharSequence str, final char
*
* @param out The {@link StringBuilder} to which the unescaped contents of {@code str} are to be appended.
* @param str The string to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @return The provided {@link StringBuilder} with the unescaped representation of {@code str}.
* @throws NullPointerException If {@code out} or {@code str} is null.
* @throws IllegalArgumentException If {@code quote} is not {@code '"'} or {@code '\''}.
Expand All @@ -748,8 +746,7 @@ public static StringBuilder unescapeFromAttr(final StringBuilder out, final Char
* </pre>
*
* @param chars The {@code char[]} to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @return A new {@link StringBuilder} with the unescaped representation of {@code chars}.
* @throws NullPointerException If {@code chars} is null.
* @throws IllegalArgumentException If {@code quote} is not {@code '"'} or {@code '\''}.
Expand All @@ -776,8 +773,7 @@ public static StringBuilder unescapeFromAttr(final char[] chars, final char quot
*
* @param out The {@link StringBuilder} to which the unescaped contents of {@code chars} are to be appended.
* @param chars The {@code char[]} to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @return The provided {@link StringBuilder} with the unescaped representation of {@code chars}.
* @throws NullPointerException If {@code out} or {@code chars} is null.
* @throws IllegalArgumentException If {@code quote} is not {@code '"'} or {@code '\''}.
Expand All @@ -803,8 +799,7 @@ public static StringBuilder unescapeFromAttr(final StringBuilder out, final char
* </pre>
*
* @param str The string to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @param off Start index from which to unescape characters.
* @param len Number of characters to escape.
* @return A new {@link StringBuilder} with the unescaped representation of {@code str}.
Expand Down Expand Up @@ -835,8 +830,7 @@ public static StringBuilder unescapeFromAttr(final CharSequence str, final char
*
* @param out The {@link StringBuilder} to which the unescaped contents of {@code str} are to be appended.
* @param str The string to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @param off Start index from which to unescape characters.
* @param len Number of characters to escape.
* @return The provided {@link StringBuilder} with the unescaped representation of {@code str}.
Expand Down Expand Up @@ -867,8 +861,7 @@ public static StringBuilder unescapeFromAttr(final StringBuilder out, final Char
* </pre>
*
* @param chars The {@code char[]} to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @param off Start index from which to unescape characters.
* @param len Number of characters to escape.
* @return A new {@link StringBuilder} with the unescaped representation of {@code chars}.
Expand Down Expand Up @@ -900,8 +893,7 @@ public static StringBuilder unescapeFromAttr(final char[] chars, final char quot
*
* @param out The {@link StringBuilder} to which the unescaped contents of {@code chars} are to be appended.
* @param chars The {@code char[]} to unescape.
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or
* {@code '\''}).
* @param quote The quote character used to delimit the attribute's value in the XML document (either {@code '"'} or {@code '\''}).
* @param off Start index from which to unescape characters.
* @param len Number of characters to escape.
* @return The provided {@link StringBuilder} with the unescaped representation of {@code chars}.
Expand Down
9 changes: 4 additions & 5 deletions api/src/main/java/org/openjax/xml/api/XmlElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,13 @@ public int hashCode() {
/**
* Returns an XML string representation of this element with the specified number of spaces to indent child elements.
*
* @param indent Number of spaces to indent child elements. If the specified indent value is greater than {@code 0}, child
* elements are indented and placed on a new line. If the indent value is {@code 0}, child elements are not indented, nor
* placed on a new line.
* @param indent Number of spaces to indent child elements. If the specified indent value is greater than {@code 0}, child elements
* are indented and placed on a new line. If the indent value is {@code 0}, child elements are not indented, nor placed on
* a new line.
* @return An XML string representation of this element.
* @throws NullPointerException If a child element is null, or the name or value of an attribute is null.
* @throws IllegalArgumentException If the name of an attribute is not a valid
* <a href= "https://www.w3.org/TR/1999/REC-xml-names-19990114/#dt-qname">xs:qName</a>, or if {@code indent} is
* negative.
* <a href= "https://www.w3.org/TR/1999/REC-xml-names-19990114/#dt-qname">xs:qName</a>, or if {@code indent} is negative.
* @throws StackOverflowError If the graph of child elements has cycles.
*/
public String toString(final int indent) {
Expand Down
4 changes: 2 additions & 2 deletions dom/src/main/java/org/openjax/xml/dom/DOMParsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public void fatalError(final SAXParseException exception) {
// treat validation errors as fatal
@Override
public void error(final SAXParseException e) throws SAXParseException {
if (logger.isErrorEnabled()) logger.error("[" + e.getLineNumber() + "," + e.getColumnNumber() + "]" + (e.getSystemId() != null ? " systemId=\"" + e.getSystemId() + "\"" : ""));
if (logger.isErrorEnabled()) { logger.error("[" + e.getLineNumber() + "," + e.getColumnNumber() + "]" + (e.getSystemId() != null ? " systemId=\"" + e.getSystemId() + "\"" : "")); }
throw e;
}

// dump warnings too
@Override
public void warning(final SAXParseException e) {
final String message = e.getMessage() != null ? " " + e.getMessage() : "";
if (logger.isWarnEnabled()) logger.warn("[" + e.getLineNumber() + "," + e.getColumnNumber() + "] systemId=\"" + e.getSystemId() + "\"" + message);
if (logger.isWarnEnabled()) { logger.warn("[" + e.getLineNumber() + "," + e.getColumnNumber() + "] systemId=\"" + e.getSystemId() + "\"" + message); }
}
};

Expand Down
8 changes: 4 additions & 4 deletions dom/src/main/java/org/openjax/xml/dom/DOMs.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public final class DOMs {
* Returns a string representation of a {@link Node}, or an empty string if {@code node} is null. This method handles all child
* nodes recursively.
*
* @implNote Only elements, attributes and text nodes and considered. Other facets like processing instructions, comments and
* CDATA are not considered.
* @implNote Only elements, attributes and text nodes and considered. Other facets like processing instructions, comments and CDATA
* are not considered.
* @param node The {@link Node} to convert.
* @param styles An array of {@link DOMStyle} style preferences.
* @return A string representation of a {@link Node}.
Expand All @@ -49,8 +49,8 @@ public static String domToString(final Node node, final DOMStyle ... styles) {
* Returns a string representation of a {@link Node}, or an empty string if {@code node} is null. This method handles all child
* nodes recursively.
*
* @implNote Only elements, attributes and text nodes and considered. Other facets like processing instructions, comments and
* CDATA are not considered.
* @implNote Only elements, attributes and text nodes and considered. Other facets like processing instructions, comments and CDATA
* are not considered.
* @param node The {@link Node} to convert.
* @param namespaceToPrefix Map of namespace-to-prefix assignments.
* @param schemaLocations Map of namespace-to-schemaLocation assignments.
Expand Down
4 changes: 2 additions & 2 deletions dom/src/main/java/org/openjax/xml/dom/Documents.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/
public final class Documents {
/**
* Set the specified namespace URI to each node of the provided document, which includes all child elements, and conditionally
* their attributes if {@code attributeFormQualified} is {@code true}.
* Set the specified namespace URI to each node of the provided document, which includes all child elements, and conditionally their
* attributes if {@code attributeFormQualified} is {@code true}.
*
* @param document The {@link Document}.
* @param namespaceURI The namespace URI.
Expand Down
8 changes: 4 additions & 4 deletions sax/src/main/java/org/openjax/xml/sax/FasterSAXHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ default boolean comment(final int commentLen) throws IOException {
/**
* Callback method for attribute occurrences.
*
* @param prefixLen The length of the prefix part of the attribute name, which is {@code == 0} if the attribute name does not have
* a prefix, and {@code >= 2} if the attribute name does not has a prefix, as this includes the {@code ':'} character.
* @param prefixLen The length of the prefix part of the attribute name, which is {@code == 0} if the attribute name does not have a
* prefix, and {@code >= 2} if the attribute name does not has a prefix, as this includes the {@code ':'} character.
* @param localPartLen The length of the local part of the attribute name.
* @param skip The length of the data to skip, which matches the regex: {@code "[ \n\r\t]*=[ \n\r\t]*\""}.
* @param valueLen The length of the attribute value (does not include the surrounding quotes).
Expand Down Expand Up @@ -133,8 +133,8 @@ default boolean startElement() throws IOException {
/**
* Called when an element's "end tag" is encountered.
* <p>
* The "end tag" is either a dedicated tag that resembles {@code "</ELEMENT>"} for elements that may have child elements, or can
* be the "start tag" that ends with {@code "/>"} for elements that have no child elements.
* The "end tag" is either a dedicated tag that resembles {@code "</ELEMENT>"} for elements that may have child elements, or can be
* the "start tag" that ends with {@code "/>"} for elements that have no child elements.
*
* @return Whether parsing should continue.
* @throws IOException If an I/O error has occurred.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ public class LoggingErrorHandler implements ErrorHandler {
public void warning(final SAXParseException exception) throws SAXParseException {
final String message = exception.getMessage() + " (" + exception.getLineNumber() + "," + exception.getColumnNumber() + ")";
if (exception.getMessage() != null && exception.getMessage().startsWith("schema_reference.4")) {
if (logger.isErrorEnabled()) logger.error(message);
if (logger.isErrorEnabled()) { logger.error(message); }
throw exception;
}

if (logger.isWarnEnabled()) logger.warn(message);
if (logger.isWarnEnabled()) { logger.warn(message); }
}

@Override
public void error(final SAXParseException exception) {
if (logger.isErrorEnabled()) logger.error(exception.getMessage() + " (" + exception.getLineNumber() + "," + exception.getColumnNumber() + ")");
if (logger.isErrorEnabled()) { logger.error(exception.getMessage() + " (" + exception.getLineNumber() + "," + exception.getColumnNumber() + ")"); }
}

@Override
public void fatalError(final SAXParseException exception) {
if (logger.isErrorEnabled()) logger.error(exception.getMessage() + " (" + exception.getLineNumber() + "," + exception.getColumnNumber() + ")");
if (logger.isErrorEnabled()) { logger.error(exception.getMessage() + " (" + exception.getLineNumber() + "," + exception.getColumnNumber() + ")"); }
}
}
2 changes: 1 addition & 1 deletion sax/src/main/java/org/openjax/xml/sax/SAXParsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static SAXParserFactory newFactory(final boolean validating) throws Pars
}
catch (final FactoryConfigurationError e) {
factory = SAXParserFactory.newInstance();
if (logger.isWarnEnabled()) logger.warn("Unable to create SAXParserFactory of type org.apache.xerces.jaxp.SAXParserFactoryImpl. Factory of " + factory.getClass().getName() + " created instead.", e);
if (logger.isWarnEnabled()) { logger.warn("Unable to create SAXParserFactory of type org.apache.xerces.jaxp.SAXParserFactoryImpl. Factory of " + factory.getClass().getName() + " created instead.", e); }
}

factory.setNamespaceAware(true);
Expand Down
2 changes: 1 addition & 1 deletion sax/src/main/java/org/openjax/xml/sax/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private static void validate(final CachedInputSource inputSource, final XmlPrevi
}

@SuppressWarnings("unchecked")
private static <E extends Exception>void checkException(final ValidatorErrorHandler validatorErrorHandler, final Throwable suppressor) throws E, SAXParseException {
private static <E extends Exception> void checkException(final ValidatorErrorHandler validatorErrorHandler, final Throwable suppressor) throws E, SAXParseException {
if (validatorErrorHandler.errors != null) {
final Iterator<SAXParseException> iterator = validatorErrorHandler.errors.iterator();
final SAXParseException exception = iterator.next();
Expand Down
4 changes: 2 additions & 2 deletions sax/src/main/java/org/openjax/xml/sax/XmlCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private void toTR9401(final Set<String> uris, final StringBuilder builder) {
}

/**
* Closes this {@link XmlCatalog}. This method calls {@link XmlEntity#close()} on each {@link XmlEntity} instance referenced in
* this {@link XmlCatalog}.
* Closes this {@link XmlCatalog}. This method calls {@link XmlEntity#close()} on each {@link XmlEntity} instance referenced in this
* {@link XmlCatalog}.
*
* @throws IOException If an I/O error has occurred.
*/
Expand Down
8 changes: 4 additions & 4 deletions sax/src/main/java/org/openjax/xml/sax/XmlPreview.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public XmlCatalog getCatalog() {
* Specifies whether the XML document represented by this {@link XmlPreview} instance only contains references that locally
* accessible via the {@code file:} protocol.
*
* @return Whether the XML document represented by this {@link XmlPreview} instance only contains references that locally
* accessible via the {@code file:} protocol.
* @return Whether the XML document represented by this {@link XmlPreview} instance only contains references that locally accessible
* via the {@code file:} protocol.
*/
public boolean isLocal() {
return isLocal;
Expand All @@ -89,8 +89,8 @@ public QName getRootElement() {
}

/**
* Returns the "targetNamespace" attribute of the XML document represented by this {@link XmlPreview} instance. This method is
* only useful for XML Schema Documents (i.e. when {@link #isSchema()} is {@code true}).
* Returns the "targetNamespace" attribute of the XML document represented by this {@link XmlPreview} instance. This method is only
* useful for XML Schema Documents (i.e. when {@link #isSchema()} is {@code true}).
*
* @return The "targetNamespace" attribute of the XML document represented by this {@link XmlPreview} instance.
*/
Expand Down
8 changes: 4 additions & 4 deletions sax/src/main/java/org/openjax/xml/sax/XmlPreviewHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,17 @@ public URL put(final String key, final URL value) {
}

/**
* Returns the map of namespace-to-URL entries of "import" references for the XML document represented by the {@link XmlCatalog}
* in this {@link XmlPreviewHandler} instance.
* Returns the map of namespace-to-URL entries of "import" references for the XML document represented by the {@link XmlCatalog} in
* this {@link XmlPreviewHandler} instance.
* <ul>
* <li>If {@link #isSchema()} is {@code true}, this method represents the {@code <xs:import/>} elements of an XML Schema
* Document.</li>
* <li>If {@link #isSchema()} is {@code false}, this method represents the {@code xsi:schemaLocation} attribute of an XML
* Document.</li>
* </ul>
*
* @return The map of namespace-to-URL entries of "import" references for the XML document represented by the {@link XmlCatalog}
* in this {@link XmlPreviewHandler} instance.
* @return The map of namespace-to-URL entries of "import" references for the XML document represented by the {@link XmlCatalog} in
* this {@link XmlPreviewHandler} instance.
*/
Map<String,URL> getImports() {
return imports;
Expand Down
12 changes: 6 additions & 6 deletions sax/src/test/java/org/openjax/xml/sax/XMLManifestParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public void testEmptyXml() throws IOException, SAXParseException {
@Test
public void testDoctypeXml() throws Exception {
final URL url = ClassLoader.getSystemClassLoader().getResource("doctype.xml");
// try (final ReplayReader reader = new ReplayReader(new InputStreamReader(url.openStream()))) {
XmlPreviewParser.parse(url);
// try (final ReplayReader reader = new ReplayReader(new InputStreamReader(url.openStream()))) {
XmlPreviewParser.parse(url);

// final char[] chars = new char[19];
// assertEquals(chars.length, reader.read(chars));
// assertEquals("<!DOCTYPE catalog [", new String(chars));
// }
// final char[] chars = new char[19];
// assertEquals(chars.length, reader.read(chars));
// assertEquals("<!DOCTYPE catalog [", new String(chars));
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public String toString() {
}

/**
* Returns the schema location {@link URL} for the specified {@code publicId} and {@code systemId}, or {@code null} if the
* provided {@code publicId} and {@code systemId} do not match one of:
* Returns the schema location {@link URL} for the specified {@code publicId} and {@code systemId}, or {@code null} if the provided
* {@code publicId} and {@code systemId} do not match one of:
*
* <pre>
* http://www.w3.org/2001/XMLSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static String transform(final URL stylesheet, final InputStream in, final
}

public static void transform(final URL stylesheet, final InputStream in, final String systemId, final File out) throws IOException, TransformerException {
transform(stylesheet,in, systemId, out, (Map<String,String>)null);
transform(stylesheet, in, systemId, out, (Map<String,String>)null);
}

public static void transform(final URL stylesheet, final InputStream in, final String systemId, final File out, final Map<String,String> parameters) throws IOException, TransformerException {
Expand Down
Loading

0 comments on commit f08fbb9

Please sign in to comment.