A DESCRIPTION OF THE REQUEST :
I wanted to put a 4-line piece of code into a JavaDoc comment, and I used the new @literal and @code tags to preformat the code. Both of them removed all line breaks, which makes them significantly less useful.
JUSTIFICATION :
I was delighted with the new @code and @literal tags until I tried to use them. I want to put a 4-line snippet of code into my javadocs, but both the @code and @literal tags removed all the line breaks. This is not what I expected, and makes these tags much less useful. I suspect the @literal tag should get this feature, and the @code tag should just set the font, but that's up to you.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I want a JavaDoc tag that lets me specify a multi-line piece of code, and preserves line breaks. In other words, one that gives me the effect of <PRE>.
ACTUAL -
Both @code and @literal, (either one of which seemed like it should work) removed all the line breaks.
Source Code:
================
package com.mm.bugs;
public class PreRFE
{
/**
* Here's an example of some sample code where the new code and literal
* tags don't work the way I expected.
* Here's a piece of sample code which gets reformatted completely by
* JavaDoc:
* private static class NameColumn extends AbstractEditColumn<Purchase>
* {
* NameColumn() { super("Name", String.class, 180); }
* public String getValue(Purchase pRow) { return pRow.getName(); }
* public void setValue(Object value, Purchase pPurchase) { pPurchase.setName(value.toString()); }
* public boolean getUpdateTable(Purchase pRow) { return true; }
* }
* So I thought of using the code tag, like this:
* {@code
* private static class NameColumn extends AbstractEditColumn<Purchase>
* {
* NameColumn() { super("Name", String.class, 180); }
* public String getValue(Purchase pRow) { return pRow.getName(); }
* public void setValue(Object value, Purchase pPurchase) { pPurchase.setName(value.toString()); }
* public boolean getUpdateTable(Purchase pRow) { return true; }
* }
* }
*
* This didn't work. Then I Tried the literal tag:
*
* {@literal
* private static class NameColumn extends AbstractEditColumn<Purchase>
* {
* NameColumn() { super("Name", String.class, 180); }
* public String getValue(Purchase pRow) { return pRow.getName(); }
* public void setValue(Object value, Purchase pPurchase) { pPurchase.setName(value.toString()); }
* public boolean getUpdateTable(Purchase pRow) { return true; }
* }
* }
*
* The only thing that works is the pre html tags
* <pre>
* private static class NameColumn extends AbstractEditColumn<Purchase>
* {
* NameColumn() { super("Name", String.class, 180); }
* public String getValue(Purchase pRow) { return pRow.getName(); }
* public void setValue(Object value, Purchase pPurchase) { pPurchase.setName(value.toString()); }
* public boolean getUpdateTable(Purchase pRow) { return true; }
* }
* </pre>
* I'd like a {@pre xxx} tag to handle cases like this. In retrospect I
* can see why the code and literal tags don't do what I want. However,
* if these tags are working as intended, it would be very useful to
* point out in the documentation that neither of these tags will
* preserve line breaks, and hence, shouldn't be used for code samples.
* That would save developers some surprises.
*
*/
public PreRFE() { }
}
###@###.### 10/21/04 20:28 GMT