diff --git a/README.md b/README.md index 0de6239..6d8dca1 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Optional attributes are: Attribute | Description ----------- | ------------------------------------------------------------------------------------------- `default` | The fallback value to output, if no cause is available. -`escapeXml` | Converts <,>,&,'," to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. +`escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. ## hs:code The `` tag displays the current HTTP status code, if any. A shorthand for: @@ -60,7 +60,7 @@ Attribute | Description ----------- | ------------------------------------------------------------------------------------------- `code` | The HTTP status error code. If not specified the current status code is used. `default` | The fallback value to output, if no reason is available. -`escapeXml` | Converts <,>,&,'," to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. +`escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. The reasons are defined in a [ResourceBundle](http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html) properties as follows: diff --git a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java index 830807c..86e6972 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java @@ -38,7 +38,8 @@ import java.util.ResourceBundle; import java.util.TreeMap; /** - * The Reasons class. + * Populates the {@link #REASON_PHRASES reason phrases} map from {@link #BUNDLE_BASENAME bundle properties}, and + * implements accessor methods. * * @author Erik C. Thauvin * @created 2015-12-02 @@ -57,7 +58,7 @@ public class Reasons private static final Map REASON_PHRASES = new TreeMap(); /** - * Gets the reason phrase for the specified status code. + * Returns the reason phrase for the specified status code. * * @param statusCode The status code. * @@ -69,7 +70,7 @@ public class Reasons } /** - * Gets the reason phrase for the specified status code. + * Returns the reason phrase for the specified status code. * * @param statusCode The status code. * @@ -81,7 +82,7 @@ public class Reasons } /** - * Outputs the status codes and reason phrases. + * Prints the status codes and reason phrases. * * @param args The command line arguments. */ diff --git a/src/main/java/net/thauvin/erik/httpstatus/Utils.java b/src/main/java/net/thauvin/erik/httpstatus/Utils.java index fcc2606..899c010 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Utils.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Utils.java @@ -49,7 +49,7 @@ public final class Utils /** * Disables the default constructor. * - * @throws UnsupportedOperationException if an error occurred. if the constructor is called. + * @throws UnsupportedOperationException If the constructor is called. */ private Utils() throws UnsupportedOperationException @@ -58,14 +58,14 @@ public final class Utils } /** - * Writes a string value. + * Writes a string value to the specified writer. The default value is used when the actual value is null. * * @param out The writer to output the value to. * @param value The string value. * @param defaultValue The default value. - * @param xml The xml flag. + * @param xml The {@link #escapeXml(String) xml} flag. */ - public static void outWrite(Writer out, String value, String defaultValue, boolean xml) + public static void outWrite(final Writer out, final String value, final String defaultValue, final boolean xml) throws IOException { if (xml) @@ -93,13 +93,14 @@ public final class Utils } /** - * Escapes a string value. + * Converts <, >, &, ', " + * to their corresponding entity codes. * - * @param value The string value to escape. + * @param value The string value to convert. * - * @return The escaped string value. + * @return The converted string value. */ - public static String escapeXml(String value) + public static String escapeXml(final String value) { final StringBuilder escaped = new StringBuilder(); diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java index d9f9be6..6822fce 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java @@ -41,7 +41,7 @@ import javax.servlet.jsp.PageContext; import java.io.IOException; /** - * The CauseTag class. + * The <hs:cause> tag returns the cause (if any) for the current HTTP Status Error Code. * * @author Erik C. Thauvin * @created 2015-12-03 diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java index c2f1517..d591f0a 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java @@ -40,7 +40,7 @@ import javax.servlet.jsp.tagext.SimpleTagSupport; import java.io.IOException; /** - * The CodeTag class. + * The <hs:code> tag returns the HTTP Status Error Code. * * @author Erik C. Thauvin * @created 2015-12-03 diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java index 5894cdb..6de2327 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java @@ -42,7 +42,8 @@ import javax.servlet.jsp.PageContext; import java.io.IOException; /** - * The ReasonTag class. + * The <hs:reason> tag returns the Reason Phrase for the current (or specified) HTTP Status Error + * Code. * * @author Erik C. Thauvin * @created 2015-12-02 @@ -85,7 +86,7 @@ public class ReasonTag extends XmlSupport * @param statusCode The status code. */ @SuppressWarnings("unused") - public void setCode(int statusCode) + public void setCode(final int statusCode) { this.statusCode = statusCode; } diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java index d466137..09324e6 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java @@ -36,7 +36,7 @@ package net.thauvin.erik.httpstatus.taglibs; import javax.servlet.jsp.tagext.SimpleTagSupport; /** - * The XmlSupport class. + * Adds support for the default and escapeXml tag attributes. * * @author Erik C. Thauvin * @created 2015-12-03 @@ -44,8 +44,14 @@ import javax.servlet.jsp.tagext.SimpleTagSupport; */ public abstract class XmlSupport extends SimpleTagSupport { + /** + * Default value string. + */ protected String defaultValue; + /** + * Escape XML flag. + */ protected boolean escapeXml = true; /** @@ -54,18 +60,18 @@ public abstract class XmlSupport extends SimpleTagSupport * @param defaultValue The default value. */ @SuppressWarnings("unused") - public void setDefault(String defaultValue) + public void setDefault(final String defaultValue) { this.defaultValue = defaultValue; } /** - * Sets the escapeXMl flag. + * Sets the {@link net.thauvin.erik.httpstatus.Utils#escapeXml(String) xml} flag. * * @param escapeXml true or false */ @SuppressWarnings("unused") - public void setEscapeXml(boolean escapeXml) + public void setEscapeXml(final boolean escapeXml) { this.escapeXml = escapeXml; } diff --git a/src/main/resources/META-INF/httpstatus.tld b/src/main/resources/META-INF/httpstatus.tld index 2c42b1f..11de943 100644 --- a/src/main/resources/META-INF/httpstatus.tld +++ b/src/main/resources/META-INF/httpstatus.tld @@ -60,7 +60,7 @@ - Converts <,>,&,'," to their corresponding entity codes. Value is true by default. + Converts <, > ,& ,' ," to their corresponding entity codes. Value is true by default. escapeXml false @@ -70,7 +70,7 @@ - Outputs the HTTP Status Error Code. + Returns the HTTP Status Error Code. code net.thauvin.erik.httpstatus.taglibs.CodeTag @@ -102,7 +102,7 @@ - Converts <,>,&,'," to their corresponding entity codes. Value is true by default. + Converts <, >, &, ', " to their corresponding entity codes. Value is true by default. escapeXml false