Package io.keikai.model
Class CellRegion
java.lang.Object
io.keikai.model.CellRegion
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PasteCellRegion
An immutable object that represents a block of cells with 4 indexes which are first and last row index, first and last column index.
It doesn't relate to a sheet.
You can use it to compare with another cell region, like diff(), equals(), contains(), or overlaps().
These methods compare 2 regions by their 4 indexes.
- Since:
- 3.5.0
- Author:
- dennis
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intfinal intfinal intfinal int -
Constructor Summary
ConstructorsConstructorDescriptionCellRegion(int row, int column) Create a region which only contains 1 cell.CellRegion(int row, int column, int lastRow, int lastColumn) Create a region with 4 indexesCellRegion(String areaReference) create a region with cell reference, e.g. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int row, int column) booleancontains(CellRegion region) static intconvertColumnStringToIndex(String colRef) static StringconvertIndexToColumnString(int columnIdx) diff(CellRegion target) booleanequals(int row, int column, int lastRow, int lastColumn) booleanintintintintintgetOverlap(CellRegion target) intgetRow()intinthashCode()intersect(CellRegion target) booleanisSingle()booleanoverlaps(CellRegion region) toString()
-
Field Details
-
row
public final int row -
column
public final int column -
lastRow
public final int lastRow -
lastColumn
public final int lastColumn
-
-
Constructor Details
-
CellRegion
public CellRegion(int row, int column) Create a region which only contains 1 cell. -
CellRegion
create a region with cell reference, e.g. "A1:B2" -
CellRegion
public CellRegion(int row, int column, int lastRow, int lastColumn) Create a region with 4 indexes
-
-
Method Details
-
getReferenceString
- Returns:
- a cell reference string it might be A1:B2 for multiple cells or A1 for one cell.
-
isSingle
public boolean isSingle()- Returns:
- return TRUE if this region only contains 1 cell, otherwise returns FALSE
-
contains
public boolean contains(int row, int column) - Returns:
- returns TRUE if this region contains (or equals to) the cell specified by row and column index, otherwise returns FALSE
-
contains
- Returns:
- returns TRUE if this region contains (or equals to) specified region, otherwise returns FALSE
-
overlaps
- Returns:
- returns TRUE if this region overlaps specified region, otherwise returns FALSE
-
equals
public boolean equals(int row, int column, int lastRow, int lastColumn) - Returns:
- returns TRUE if this region refers to the same scope as specified region, otherwise returns FALSE
-
toString
-
hashCode
public int hashCode() -
equals
-
getRow
public int getRow()- Returns:
- first row index
-
getColumn
public int getColumn()- Returns:
- first column index
-
getLastRow
public int getLastRow() -
getLastColumn
public int getLastColumn() -
getRowCount
public int getRowCount() -
getColumnCount
public int getColumnCount() -
convertIndexToColumnString
-
convertColumnStringToIndex
-
diff
- Returns:
- returns a list of regions that exclude the part which overlaps this region. If this region's area equals to specified region, returned list contains nothing.
-
getOverlap
- Returns:
- returns the overlapping region between this region and the specified region; null if no overlapping.
-
getCellCount
public int getCellCount()- Returns:
- returns the cell count which this region covers
-
cloneCellRegion
-
intersect
-