JavaDoc可重用参数值

好吧,我这里有这个代码,这是我对标准Swing TableModel的替代实现。 我认为这是一个绝对的噩梦,我的问题是,我有很多rowIndex和columIndex参数,有没有一种方法可以在它们之间共享描述,以实现更标准化,更少的手指工作方式? 谢谢!!

package atablemodel; import java.util.ArrayList; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableModel; /** * My custom swing TableModel version 1.x will represent a complete table model * while version 2.x adds several methods for updating an existing table version * 0.x is an incomplete version * Completely changed everything to work with arraylist instead of array, which means * that ATableModel Object can now simply be updated instead of recreated * @author alex * @version 2.0 * @see AbstractTableModel * @see TableModel */ @SuppressWarnings("serial") public class ATableModel extends AbstractTableModel { private ArrayList cn = new ArrayList(); private ArrayList<ArrayList> rd = new ArrayList<ArrayList>(); /** * Creates my custom TableModel * * @param columnames The names for the columns * @param rowdata The data for the rows */ public ATableModel(String[] columnames, Object[][] rowdata) { for (int i = 0; i < columnames.length; i++) { cn.add(columnames[i]); } for (int i = 0; i < rowdata.length; i++) { ArrayList rdot1 = new ArrayList(); for (int i2 = 0; i2 < rowdata[i].length; i2++) { rdot1.add(new RowDataObject(rowdata[i][i2])); } rd.add(rdot1); } } /** * Looks up the column name for the specified column * * @param column The number of the column to look up * @return The name (string) of the column */ public String getColumnName(int column) { return cn.get(column); } /** * This method will simply tell you if a cell is editable * This is only here because it is in the Default TableModel * @deprecated use {@link #getCellEditable(int, int)} instead * @param columnIndex The column * @param rowIndex The row * @return A boolean indicating if the cell is editable or not */ public boolean isCellEditable(int rowIndex, int columnIndex) { return getCellEditable(rowIndex, columnIndex); } /** * Sets the value at a certain cell; TAKE NOTE!: this set the cell to * editable before changing the value, and returns it to either uneditable, * or editable depending on what the cell was before in {@link #rde} * * @param aValue The value to set * @param rowIndex The row * @param columnIndex The column */ public void setValueAt(Object aValue, int rowIndex, int columnIndex) { boolean editable = getRDO(rowIndex, columnIndex).getEditable(); getRDO(rowIndex, columnIndex).setEditable(true); getRDO(rowIndex, columnIndex).setData(aValue); getRDO(rowIndex, columnIndex).setEditable(editable); } /** * gets the number of columns; returns the length of columnnames, so if your * rowdata and columnnames don't match up, it might not give you the info * you want * * @return Number of columns */ public int getColumnCount() { return cn.size(); } /** * gets the number of rows * * @return number of rows */ public int getRowCount() { return rd.size(); } /** * gets the value for a specified cell * * @param rowIndex The row * @param columnIndex The column * @return the value (if any) at the specified cell */ public Object getValueAt(int rowIndex, int columnIndex) { return getRDO(rowIndex, columnIndex).getData(); /* getValueAt(0, 3); returns d */ } /** * do not use, useless unless absolutely necessary for some reason * * @deprecated */ public TableModel returnTableModel() { return this; } /** * gets a boolean indicating if the cell is editable or not * * @param rowIndex The row * @param columnIndex The column * @return A boolean indicating whether the cell is editable */ public boolean getCellEditable(int rowIndex, int columnIndex) { return getRDO(rowIndex, columnIndex).getEditable(); } /** * sets all cells editable * * @param rowIndex The row * @param columnIndex The column * @param editable set all cells to this value */ public void setCellEditable(int rowIndex, int columnIndex, boolean editable) { getRDO(rowIndex, columnIndex).setEditable(editable); } /** * Sets all cells in the current rowdata to {@code editable} * * @param editable What to set all of the cells editable values to */ public void setAllCellsEditable(boolean editable) { int x, y; for (x = 0; x < rd.size(); x++) { for (y = 0; y < rd.get(x).size(); y++) { getRDO(x, y).setEditable(editable); } } } /** * Set all the cells of a single row to editable or not * * @param rowIndex The row to set editable * @param editable what to set the cells editable values to */ public void setRowEditable(int rowIndex, boolean editable) { for (RowDataObject rdo : getRDORow(rowIndex)) { rdo.setEditable(editable); } } /** * Set all the cells in one column to editable * * @param columnIndex The column to set editable * @param editable what to set all the cells editable values to */ public void setColumnEditable(int columnIndex, boolean editable) { for (RowDataObject rdo : getRDOCol(columnIndex)) { rdo.setEditable(editable); } } public RowDataObject getRDO(int rowIndex, int columnIndex) { return rd.get(rowIndex).get(columnIndex); } public ArrayList getRDORow(int rowIndex) { //ArrayList rdor; /*for (int i = 0; i < rd.get(rowIndex).size(); i++) { }*/ return rd.get(rowIndex); } public ArrayList getRDOCol(int columnIndex) { ArrayList rdoc = new ArrayList(); for (int i = 0; i < rd.size(); i++) { rdoc.add(rd.get(i).get(columnIndex)); } return rdoc; } } /* * rd[2][5] 0 1 2 3 4 0 {abcde} 1 {fghij} * * {abcde}, {fghij} */ 

没有任何一个是不可能的

  • 修补标准doclet(或替换自己的doclet)
  • 修补Javadoc核心
  • 在将源代码提供给JavaDoc之前预处理源代码
  • 运行Javadoc后对HTML输出进行后处理。

这是恕我直言,可以自由复制和粘贴的唯一情况之一。 我认为任何宏观处理魔术都会有点过分。