Improved source documentation.
Some PMD optimization.
This commit is contained in:
parent
1b59f8e5dc
commit
f5f9d5cbda
8 changed files with 34 additions and 25 deletions
|
@ -43,7 +43,7 @@ Optional attributes are:
|
||||||
Attribute | Description
|
Attribute | Description
|
||||||
----------- | -------------------------------------------------------------------------------------------
|
----------- | -------------------------------------------------------------------------------------------
|
||||||
`default` | The fallback value to output, if no cause is available.
|
`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
|
## hs:code
|
||||||
The `<hs:code/>` tag displays the current HTTP status code, if any. A shorthand for:
|
The `<hs:code/>` 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.
|
`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.
|
`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:
|
The reasons are defined in a [ResourceBundle](http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html) properties as follows:
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@ import java.util.ResourceBundle;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>Reasons</code> class.
|
* Populates the {@link #REASON_PHRASES reason phrases} map from {@link #BUNDLE_BASENAME bundle properties}, and
|
||||||
|
* implements accessor methods.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
||||||
* @created 2015-12-02
|
* @created 2015-12-02
|
||||||
|
@ -57,7 +58,7 @@ public class Reasons
|
||||||
private static final Map<String, String> REASON_PHRASES = new TreeMap<String, String>();
|
private static final Map<String, String> REASON_PHRASES = new TreeMap<String, String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the reason phrase for the specified status code.
|
* Returns the reason phrase for the specified status code.
|
||||||
*
|
*
|
||||||
* @param statusCode The 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.
|
* @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.
|
* @param args The command line arguments.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class Utils
|
||||||
/**
|
/**
|
||||||
* Disables the default constructor.
|
* Disables the default constructor.
|
||||||
*
|
*
|
||||||
* @throws UnsupportedOperationException if an error occurred. if the constructor is called.
|
* @throws UnsupportedOperationException If the constructor is called.
|
||||||
*/
|
*/
|
||||||
private Utils()
|
private Utils()
|
||||||
throws UnsupportedOperationException
|
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 out The writer to output the value to.
|
||||||
* @param value The string value.
|
* @param value The string value.
|
||||||
* @param defaultValue The default 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
|
throws IOException
|
||||||
{
|
{
|
||||||
if (xml)
|
if (xml)
|
||||||
|
@ -93,13 +93,14 @@ public final class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escapes a string value.
|
* Converts <code><</code>, <code>></code>, <code>&</code>, <code>'</code>, <code>"</code>
|
||||||
|
* 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();
|
final StringBuilder escaped = new StringBuilder();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import javax.servlet.jsp.PageContext;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>CauseTag</code> class.
|
* The <code><hs:cause></code> tag returns the cause (if any) for the current HTTP Status Error Code.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
||||||
* @created 2015-12-03
|
* @created 2015-12-03
|
||||||
|
|
|
@ -40,7 +40,7 @@ import javax.servlet.jsp.tagext.SimpleTagSupport;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>CodeTag</code> class.
|
* The <code><hs:code></code> tag returns the HTTP Status Error Code.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
||||||
* @created 2015-12-03
|
* @created 2015-12-03
|
||||||
|
|
|
@ -42,7 +42,8 @@ import javax.servlet.jsp.PageContext;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>ReasonTag</code> class.
|
* The <code><hs:reason></code> tag returns the Reason Phrase for the current (or specified) HTTP Status Error
|
||||||
|
* Code.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
||||||
* @created 2015-12-02
|
* @created 2015-12-02
|
||||||
|
@ -85,7 +86,7 @@ public class ReasonTag extends XmlSupport
|
||||||
* @param statusCode The status code.
|
* @param statusCode The status code.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void setCode(int statusCode)
|
public void setCode(final int statusCode)
|
||||||
{
|
{
|
||||||
this.statusCode = statusCode;
|
this.statusCode = statusCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ package net.thauvin.erik.httpstatus.taglibs;
|
||||||
import javax.servlet.jsp.tagext.SimpleTagSupport;
|
import javax.servlet.jsp.tagext.SimpleTagSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>XmlSupport</code> class.
|
* Adds support for the <code>default</code> and <code>escapeXml</code> tag attributes.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
||||||
* @created 2015-12-03
|
* @created 2015-12-03
|
||||||
|
@ -44,8 +44,14 @@ import javax.servlet.jsp.tagext.SimpleTagSupport;
|
||||||
*/
|
*/
|
||||||
public abstract class XmlSupport extends SimpleTagSupport
|
public abstract class XmlSupport extends SimpleTagSupport
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Default value string.
|
||||||
|
*/
|
||||||
protected String defaultValue;
|
protected String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape XML flag.
|
||||||
|
*/
|
||||||
protected boolean escapeXml = true;
|
protected boolean escapeXml = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,18 +60,18 @@ public abstract class XmlSupport extends SimpleTagSupport
|
||||||
* @param defaultValue The default value.
|
* @param defaultValue The default value.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void setDefault(String defaultValue)
|
public void setDefault(final String defaultValue)
|
||||||
{
|
{
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the escapeXMl flag.
|
* Sets the {@link net.thauvin.erik.httpstatus.Utils#escapeXml(String) xml} flag.
|
||||||
*
|
*
|
||||||
* @param escapeXml <code>true</code> or <code>false</code>
|
* @param escapeXml <code>true</code> or <code>false</code>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void setEscapeXml(boolean escapeXml)
|
public void setEscapeXml(final boolean escapeXml)
|
||||||
{
|
{
|
||||||
this.escapeXml = escapeXml;
|
this.escapeXml = escapeXml;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute>
|
<attribute>
|
||||||
<description>
|
<description>
|
||||||
Converts <,>,&,'," to their corresponding entity codes. Value is true by default.
|
Converts <, > ,& ,' ," to their corresponding entity codes. Value is true by default.
|
||||||
</description>
|
</description>
|
||||||
<name>escapeXml</name>
|
<name>escapeXml</name>
|
||||||
<required>false</required>
|
<required>false</required>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
<tag>
|
<tag>
|
||||||
<description>
|
<description>
|
||||||
Outputs the HTTP Status Error Code.
|
Returns the HTTP Status Error Code.
|
||||||
</description>
|
</description>
|
||||||
<name>code</name>
|
<name>code</name>
|
||||||
<tag-class>net.thauvin.erik.httpstatus.taglibs.CodeTag</tag-class>
|
<tag-class>net.thauvin.erik.httpstatus.taglibs.CodeTag</tag-class>
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute>
|
<attribute>
|
||||||
<description>
|
<description>
|
||||||
Converts <,>,&,'," to their corresponding entity codes. Value is true by default.
|
Converts <, >, &, ', " to their corresponding entity codes. Value is true by default.
|
||||||
</description>
|
</description>
|
||||||
<name>escapeXml</name>
|
<name>escapeXml</name>
|
||||||
<required>false</required>
|
<required>false</required>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue