Skip to content

Commit

Permalink
Merge pull request #348 from paulhoadley/javadoc-fix
Browse files Browse the repository at this point in the history
Improves Javadoc comments.
  • Loading branch information
paulhoadley committed Jan 3, 2013
2 parents e7f6753 + e24259f commit 5101c11
Showing 1 changed file with 50 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@
import er.extensions.foundation.ERXStringUtilities;

/**
* Simple component that can convert a string that has
* line breaks and tabs in it into an html string that
* has <BR> and &nbsp instead. Very useful for preserving
* line breaks that are typed into a WOTextBox.
* <br/>
* Synopsis:<br/>
* <p>
* Converts a string that has line breaks and tabs in it into a corresponding
* HTML string with <code>&lt;br /&gt;</code> and (five of)
* <code>&amp;nbsp;</code> instead. Useful, for example, for preserving line
* breaks that are typed into a {@code WOTextBox}. Note that this component
* renders its output via a {@code WOString} element with
* {@code escapeHTML=false}, which is a security risk if the value being
* rendered comes from an untrusted source.
* </p>
*
* <h3>Synopsis</h3>
* <p>
* value=<i>aString</i>;[valueWhenEmpty=<i>aString</i>;]
* </p>
*
* @binding value string to be converted
* @binding valueWhenEmpty if null or length of zero what to
* display
* @binding valueWhenEmpty what to display when <code>value</code> is null or
* empty
*/
public class ERXStringWithLineBreaks extends ERXStatelessComponent {
/**
Expand All @@ -32,30 +39,36 @@ public class ERXStringWithLineBreaks extends ERXStatelessComponent {
*/
private static final long serialVersionUID = 1L;

/** holds the html-ified string */
/**
* Holds the HTML-ified string
*/
public String _value;

/**
* Public constructor
* @param context current context
*/
/**
* Constructor
*
* @param context
* current context
*/
public ERXStringWithLineBreaks(WOContext context) {
super(context);
}

/**
* Nulls out cached instance variable: _value
*/
/**
* Nulls out cached instance variable: _value
*/
public void reset() {
super.reset();
_value = null;
}
/**
* Converts '\r\n', '\n', '\r' into "&lt;br /&gt;" and
* converts '\t' into five non-breaking spaces.
* @return converts string bound to binding: <b>value</b>
* into html-ified line breaks.
*/

/**
* Converts '<code>\r\n</code>', '<code>\n</code>', '<code>\r</code>' into '
* <code>&lt;br /&gt;</code>' and converts '<code>\t</code>' into five
* non-breaking spaces.
*
* @return converted string
*/
// FIXME: Should use ERXSimpleHTMLFormatter
public String value() {
if (_value == null) {
Expand All @@ -79,11 +92,13 @@ protected String valueToString(Object value) {
return result;
}

/**
* Set the value to be displayed.<br />
* This is useful when you want to return a string from a DirectAction for example for debugging purposes.
* @param newValue Object to display
*/
/**
* Sets the value to be displayed. This is useful when you want to return a
* string from a DirectAction, for example, for debugging purposes.
*
* @param newValue
* Object to display
*/
public void setValue(Object newValue) {
if(newValue != null) {
_value = valueToString(newValue);
Expand All @@ -98,11 +113,12 @@ public String tabs() {
return "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}

/**
* Returns binding <b>valueWhenEmpty</b>.
* @return value to display when the string is empty
*/
public Object valueWhenEmpty() {
return valueToString(objectValueForBinding("valueWhenEmpty"));
}
/**
* Returns binding {@code valueWhenEmpty}.
*
* @return value to display when the string is empty
*/
public Object valueWhenEmpty() {
return valueToString(objectValueForBinding("valueWhenEmpty"));
}
}

0 comments on commit 5101c11

Please sign in to comment.