Package io.keikai.model
Class CellRegion
- java.lang.Object
-
- io.keikai.model.CellRegion
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
PasteCellRegion
public class CellRegion extends java.lang.Object implements java.io.SerializableAn 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 intcolumnintlastColumnintlastRowintrow
-
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(java.lang.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 CellRegioncloneCellRegion()booleancontains(int row, int column)booleancontains(CellRegion region)static intconvertColumnStringToIndex(java.lang.String colRef)static java.lang.StringconvertIndexToColumnString(int columnIdx)java.util.List<CellRegion>diff(CellRegion target)booleanequals(int row, int column, int lastRow, int lastColumn)booleanequals(java.lang.Object obj)intgetCellCount()intgetColumn()intgetColumnCount()intgetLastColumn()intgetLastRow()CellRegiongetOverlap(CellRegion target)java.lang.StringgetReferenceString()intgetRow()intgetRowCount()inthashCode()CellRegionintersect(CellRegion target)booleanisSingle()booleanoverlaps(CellRegion region)java.lang.StringtoString()
-
-
-
Constructor Detail
-
CellRegion
public CellRegion(int row, int column)Create a region which only contains 1 cell.
-
CellRegion
public CellRegion(java.lang.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 java.lang.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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
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 java.lang.String convertIndexToColumnString(int columnIdx)
-
convertColumnStringToIndex
public static int convertColumnStringToIndex(java.lang.String colRef)
-
diff
public java.util.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)
-
-