Package io.keikai.model
Class CellRegion
- java.lang.Object
-
- io.keikai.model.CellRegion
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PasteCellRegion
public class CellRegion extends Object implements Serializable
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description int
column
int
lastColumn
int
lastRow
int
row
-
Constructor Summary
Constructors Constructor Description CellRegion(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CellRegion
cloneCellRegion()
boolean
contains(int row, int column)
boolean
contains(CellRegion region)
static int
convertColumnStringToIndex(String colRef)
static String
convertIndexToColumnString(int columnIdx)
List<CellRegion>
diff(CellRegion target)
boolean
equals(int row, int column, int lastRow, int lastColumn)
boolean
equals(Object obj)
int
getCellCount()
int
getColumn()
int
getColumnCount()
int
getLastColumn()
int
getLastRow()
CellRegion
getOverlap(CellRegion target)
String
getReferenceString()
int
getRow()
int
getRowCount()
int
hashCode()
CellRegion
intersect(CellRegion target)
boolean
isSingle()
boolean
overlaps(CellRegion region)
String
toString()
-
-
-
Constructor Detail
-
CellRegion
public CellRegion(int row, int column)
Create a region which only contains 1 cell.
-
CellRegion
public CellRegion(String areaReference)
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 Detail
-
getReferenceString
public String 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
public boolean contains(CellRegion region)
- Returns:
- returns TRUE if this region contains (or equals to) specified region, otherwise returns FALSE
-
overlaps
public boolean overlaps(CellRegion region)
- 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
-
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
public static String convertIndexToColumnString(int columnIdx)
-
convertColumnStringToIndex
public static int convertColumnStringToIndex(String colRef)
-
diff
public List<CellRegion> diff(CellRegion target)
- 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
public CellRegion getOverlap(CellRegion target)
- 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
public CellRegion cloneCellRegion()
-
intersect
public CellRegion intersect(CellRegion target)
-
-