有时候,我们在书写代码的时候需要处理一些具有重复性的数据,比如,我要定义一个枚举,来源如下:
![](https://img.haomeiwen.com/i10458422/117c8b76a9e1f20b.png)
这时候一个个地敲就有些慢了。这时候就该祭出我们的Excel了。
首先,把内容复制后,贴入Excel
![](https://img.haomeiwen.com/i10458422/eaa799d188b7bd73.png)
然后使用Data->Text To Columns,中文版的话是数据->分列,把它分割成单个元素。
![](https://img.haomeiwen.com/i10458422/b0d6ed014cee76a1.png)
这里我们选固定长度,因为当前这种情况用固定长度拆分更容易。
![](https://img.haomeiwen.com/i10458422/fe81776546b242be.png)
不过在许多其他的情况下,我们一般常用的是用各种分隔符来切分。
拆分好之后,调整一下。现在每列一种数据了,我们插入几列,并输入其他的内容,比如枚举的名称和括号:
![](https://img.haomeiwen.com/i10458422/0f03bc710d817264.png)
然后,在最后一列,用函数 & 符号连接所有的元素。
![](https://img.haomeiwen.com/i10458422/286208bfc0e3ed10.png)
最后,直接贴到代码中:
public enum PageSegmentMode {
OSD_ONLY(0),//Orientation and script detection (OSD) only.
AUTO_SEG_WITH_OSD(1),//Automatic page segmentation with OSD.
AUTO_SEG_NO_OSD(2),//Automatic page segmentation, but no OSD, or OCR.
FULLY_AUTO_NO_OSD(3),//Fully automatic page segmentation, but no OSD. (Default)
SINGLE_COLUMN_WITH_VARIABLE_SIZE(4),//Assume a single column of text of variable sizes.
SINGLE_BLOCK_WITH_VERTICAL_TXT(5),//Assume a single uniform block of vertically aligned text.
SINGLE_BLOCK_TXT(6),//Assume a single uniform block of text.
SINGLE_TXT_LINE(7),//Treat the image as a single text line.
SINGLE_WORD(8),//Treat the image as a single word.
SINGLE_WORD_IN_CIRCLE(9),//Treat the image as a single word in a circle.
SINGLE_CHAR(10),//Treat the image as a single character.
SPARSE_TXT_AS_MUCH_AS_POSSIBLE(11),//Sparse text. Find as much text as possible in no particular order.
SPARSE_TXT_WITH_OSD(12),//Sparse text with OSD.
RAW_LINE(13),//Raw line. Treat the image as a single text line, bypassing hacks that are Tesseract-specific.
private int value;
PageSegmentMode(int value) {
this.value = value;
}
}
或者,我们可以直接把JavaDoc也给它加上。单独选中每一行之后,点击插入,就会在每一行之前插入一行。然后把javadoc所需的内容放上去。
![](https://img.haomeiwen.com/i10458422/e20a39c52f772143.png)
/**Orientation and script detection (OSD) only. */
OSD_ONLY (0),
/**Automatic page segmentation with OSD. */
AUTO_SEG_WITH_OSD (1),
/** Automatic page segmentation, but no OSD, or OCR. */
AUTO_SEG_NO_OSD (2),
/** Fully automatic page segmentation, but no OSD. (Default) */
FULLY_AUTO_NO_OSD (3),
/**Assume a single column of text of variable sizes. */
SINGLE_COLUMN_WITH_VARIABLE_SIZE (4),
/**Assume a single uniform block of vertically aligned text. */
SINGLE_BLOCK_WITH_VERTICAL_TXT (5),
/**Assume a single uniform block of text. */
SINGLE_BLOCK_TXT (6),
/**Treat the image as a single text line. */
SINGLE_TXT_LINE (7),
/**Treat the image as a single word. */
SINGLE_WORD (8),
/**Treat the image as a single word in a circle. */
SINGLE_WORD_IN_CIRCLE (9),
/**Treat the image as a single character. */
SINGLE_CHAR (10),
/**Sparse text. Find as much text as possible in no particular order. */
SPARSE_TXT_AS_MUCH_AS_POSSIBLE (11),
/**Sparse text with OSD. */
SPARSE_TXT_WITH_OSD (12),
/**Raw line. Treat the image as a single text line, bypassing hacks that are Tesseract-specific. */
RAW_LINE (13)
之后整理一下格式,javadoc就好了。
网友评论