Skip to content

Commit 53c65a9

Browse files
committed
Added missing javadoc
1 parent a4548d3 commit 53c65a9

File tree

11 files changed

+351
-12
lines changed

11 files changed

+351
-12
lines changed

src/main/groovy/com/jameskleeh/excel/CellStyleBuilder.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import java.awt.Color
3939
* A class to build an {@link org.apache.poi.xssf.usermodel.XSSFCellStyle} from a map
4040
*
4141
* @author James Kleeh
42-
* @since 1.0.0
42+
* @since 0.1.0
4343
*/
4444
@CompileStatic
4545
class CellStyleBuilder {
@@ -440,6 +440,12 @@ class CellStyleBuilder {
440440
}
441441
}
442442

443+
/**
444+
* Merges multiple maps
445+
*
446+
* @param sources The maps to merge
447+
* @return The merged map
448+
*/
443449
@CompileStatic(TypeCheckingMode.SKIP)
444450
Map merge(Map[] sources) {
445451
if (sources.length == 0) {

src/main/groovy/com/jameskleeh/excel/Column.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import org.apache.poi.xssf.usermodel.XSSFSheet
2727
import org.apache.poi.xssf.usermodel.XSSFWorkbook
2828
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy
2929

30+
/**
31+
* A class designed to be a delegate when a column is created
32+
*
33+
* @author James Kleeh
34+
* @since 0.2.0
35+
*/
3036
@CompileStatic
3137
class Column extends CreatesCells {
3238

@@ -50,10 +56,16 @@ class Column extends CreatesCells {
5056
cell
5157
}
5258

59+
/**
60+
* @see CreatesCells#skipCells
61+
*/
5362
void skipCells(int num) {
5463
rowIdx += num
5564
}
5665

66+
/**
67+
* @see CreatesCells#merge(Map style, Closure callable)
68+
*/
5769
@Override
5870
void merge(Map style, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Column) Closure callable) {
5971
Map existingDefaultOptions = defaultOptions
@@ -78,6 +90,9 @@ class Column extends CreatesCells {
7890
defaultOptions = existingDefaultOptions
7991
}
8092

93+
/**
94+
* @see CreatesCells#merge(Closure callable)
95+
*/
8196
@Override
8297
void merge(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Column) Closure callable) {
8398
merge(null, callable)

src/main/groovy/com/jameskleeh/excel/Excel.groovy

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import java.util.concurrent.atomic.AtomicInteger
2626
/**
2727
* A class to store cell renderers and formatters used to set cell
2828
* data and format
29+
*
30+
* @author James Kleeh
31+
* @since 0.1.0
2932
*/
3033
@CompileStatic
3134
class Excel {
@@ -47,14 +50,34 @@ class Excel {
4750
registerCellFormat(Date, 'm/d/yyyy')
4851
}
4952

53+
/**
54+
* Registers a cell renderer. What is returned from the closure will be set to the cell value
55+
*
56+
* @param clazz The class to render
57+
* @param priority The priority
58+
* @param callable The closure to call
59+
*/
5060
static void registerCellRenderer(Class clazz, Integer priority, Closure callable) {
5161
rendererEntries.add(new Entry(clazz, callable, priority))
5262
}
5363

64+
/**
65+
* Registers a cell renderer. What is returned from the closure will be set to the cell value
66+
*
67+
* @param clazz The class to render
68+
* @param callable The closure to call
69+
*/
5470
static void registerCellRenderer(Class clazz, Closure callable) {
5571
registerCellRenderer(clazz, -1, callable)
5672
}
5773

74+
/**
75+
* Registers a cell format
76+
*
77+
* @param clazz The class to render
78+
* @param priority The priority
79+
* @param format The format to apply
80+
*/
5881
static void registerCellFormat(Class clazz, Integer priority, String format) {
5982
int builtInFormat = BuiltinFormats.getBuiltinFormat(format)
6083
if (builtInFormat > -1) {
@@ -64,18 +87,43 @@ class Excel {
6487
}
6588
}
6689

90+
/**
91+
* Registers a cell format
92+
*
93+
* @param clazz The class to render
94+
* @param format The format to apply
95+
*/
6796
static void registerCellFormat(Class clazz, String format) {
6897
registerCellFormat(clazz, -1, format)
6998
}
7099

100+
/**
101+
* Registers a cell format
102+
*
103+
* @param clazz The class to render
104+
* @param priority The priority
105+
* @param format The format to apply
106+
*/
71107
static void registerCellFormat(Class clazz, Integer priority, int format) {
72108
formatEntries.add(new FormatEntry(clazz, format, priority))
73109
}
74110

111+
/**
112+
* Registers a cell format
113+
*
114+
* @param clazz The class to render
115+
* @param format The format to apply
116+
*/
75117
static void registerCellFormat(Class clazz, int format) {
76118
registerCellFormat(clazz, -1, format)
77119
}
78120

121+
/**
122+
* Queries the renderers registered
123+
*
124+
* @param clazz The class to search for
125+
* @return The renderer. Null if not found
126+
*/
79127
static Closure getRenderer(Class clazz) {
80128
for (Entry entry : rendererEntries) {
81129
if (entry.clazz == clazz || entry.clazz.isAssignableFrom(clazz)) {
@@ -85,6 +133,12 @@ class Excel {
85133
null
86134
}
87135

136+
/**
137+
* Queries the formats registered
138+
*
139+
* @param clazz The class to search for
140+
* @return The format. Null if not found
141+
*/
88142
static Object getFormat(Class clazz) {
89143
for (FormatEntry entry : formatEntries) {
90144
if (entry.clazz == clazz || entry.clazz.isAssignableFrom(clazz)) {

src/main/groovy/com/jameskleeh/excel/ExcelBuilder.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,30 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook
2323

2424
/**
2525
* The main class used to start building an excel document
26+
*
27+
* @author James Kleeh
28+
* @since 0.1.0
2629
*/
2730
@CompileStatic
2831
class ExcelBuilder {
2932

33+
/**
34+
* Builds an excel document and sends the data to an output stream. The output stream is NOT closed.
35+
*
36+
* @param outputStream An output stream to push data onto
37+
* @param callable The closure to build the document
38+
*/
3039
static void output(OutputStream outputStream, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Workbook) Closure callable) {
3140
XSSFWorkbook wb = build(callable)
3241
wb.write(outputStream)
3342
}
3443

44+
/**
45+
* Builds an excel document
46+
*
47+
* @param callable The closure to build the document
48+
* @return The native workbook
49+
*/
3550
static XSSFWorkbook build(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Workbook) Closure callable) {
3651
XSSFWorkbook wb = new XSSFWorkbook()
3752
callable.resolveStrategy = Closure.DELEGATE_FIRST

src/main/groovy/com/jameskleeh/excel/Font.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package com.jameskleeh.excel
2222
* Text decoration to apply to cell styles
2323
*
2424
* @author James Kleeh
25-
* @since 1.0.0
25+
* @since 0.1.0
2626
*/
2727
enum Font {
2828
ITALIC, STRIKEOUT, BOLD, UNDERLINE

src/main/groovy/com/jameskleeh/excel/Formula.groovy

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.apache.poi.xssf.usermodel.XSSFCell
2626
* A class to get references to cells for use in formulas
2727
*
2828
* @author James Kleeh
29-
* @since 1.0.0
29+
* @since 0.1.0
3030
*/
3131
@CompileStatic
3232
class Formula {
@@ -39,10 +39,16 @@ class Formula {
3939
this.columnIndexes = columnIndexes
4040
}
4141

42+
/**
43+
* @return The current row number (1 based)
44+
*/
4245
int getRow() {
4346
cell.rowIndex + 1
4447
}
4548

49+
/**
50+
* @return The current column (A..Z)
51+
*/
4652
String getColumn() {
4753
relativeColumn(0)
4854
}
@@ -67,21 +73,48 @@ class Formula {
6773
}
6874
}
6975

76+
/**
77+
* Retrieves a cell relative to the current cell. Use negative values to reference rows and columns before the current cell and positive values to reference rows and columns after the current cell.
78+
*
79+
* @param columnIndex The column index
80+
* @param rowIndex The row index
81+
* @return A cell relative to the current cell
82+
*/
7083
String relativeCell(int columnIndex, int rowIndex) {
7184
relativeColumn(columnIndex) + relativeRow(rowIndex)
7285
}
7386

87+
/**
88+
* Retrieves a cell relative to the current cell. Use negative values to reference previous columns and positive values to reference columns after the current cell.
89+
*
90+
* @param columnIndex The column index
91+
* @return A cell relative to the current cell
92+
*/
7493
String relativeCell(int columnIndex) {
7594
relativeCell(columnIndex, 0)
7695
}
7796

97+
/**
98+
* Retrieves an exact cell reference
99+
*
100+
* @param columnIndex The column index
101+
* @param rowIndex The row index
102+
* @return The desired cell
103+
*/
78104
String exactCell(int columnIndex, int rowIndex) {
79105
if (rowIndex < 0) {
80106
throw new IllegalArgumentException("An invalid row index of $rowIndex was specified")
81107
}
82108
exactColumn(columnIndex) + (rowIndex + 1)
83109
}
84110

111+
/**
112+
* Retrieves an exact cell reference based on a previously defined column definition (created by {@link com.jameskleeh.excel.internal.CreatesCells#column} and row index
113+
*
114+
* @param columnName The column identifier
115+
* @param rowIndex The row index
116+
* @return The desired cell
117+
*/
85118
String exactCell(String columnName, int rowIndex) {
86119
if (columnIndexes && columnIndexes.containsKey(columnName)) {
87120
exactCell(columnIndexes[columnName], rowIndex)
@@ -90,6 +123,12 @@ class Formula {
90123
}
91124
}
92125

126+
/**
127+
* Retrieves an exact cell reference based on a previously defined column definition (created by {@link com.jameskleeh.excel.internal.CreatesCells#column}
128+
*
129+
* @param columnName The column identifier
130+
* @return The actual header column
131+
*/
93132
String exactCell(String columnName) {
94133
exactCell(columnName, 0)
95134
}

src/main/groovy/com/jameskleeh/excel/Row.groovy

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook
2828

2929
/**
3030
* A class used to create a row in an excel document
31+
*
32+
* @author James Kleeh
33+
* @since 0.1.0
3134
*/
3235
@CompileStatic
3336
class Row extends CreatesCells {
@@ -49,11 +52,19 @@ class Row extends CreatesCells {
4952
cell
5053
}
5154

55+
/**
56+
* @see CreatesCells#skipCells
57+
*/
5258
@Override
5359
void skipCells(int num) {
5460
cellIdx += num
5561
}
5662

63+
/**
64+
* Skip to a previously defined column created by {@link CreatesCells#column}
65+
*
66+
* @param id The column identifier
67+
*/
5768
void skipTo(Object id) {
5869
if (columnIndexes && columnIndexes.containsKey(id)) {
5970
cellIdx = columnIndexes[id]
@@ -62,6 +73,9 @@ class Row extends CreatesCells {
6273
}
6374
}
6475

76+
/**
77+
* @see CreatesCells#merge(Map style, Closure callable)
78+
*/
6579
@Override
6680
void merge(final Map style, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Row) Closure callable) {
6781
Map existingDefaultOptions = defaultOptions
@@ -86,17 +100,12 @@ class Row extends CreatesCells {
86100
defaultOptions = existingDefaultOptions
87101
}
88102

103+
/**
104+
* @see CreatesCells#merge(Closure callable)
105+
*/
89106
@Override
90107
void merge(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Row) Closure callable) {
91108
merge(null, callable)
92109
}
93110

94-
@Override
95-
void merge(Object value, Integer count, final Map style = null) {
96-
merge(style) {
97-
cell(value)
98-
skipCells(count)
99-
}
100-
}
101-
102111
}

0 commit comments

Comments
 (0)