Package org.apache.poi.ss.util
Class CellRangeAddressBase
- java.lang.Object
-
- org.apache.poi.ss.util.CellRangeAddressBase
-
- All Implemented Interfaces:
Iterable<CellAddress>
,Duplicatable
,GenericRecord
- Direct Known Subclasses:
CellRangeAddress
,CellRangeAddress8Bit
public abstract class CellRangeAddressBase extends Object implements Iterable<CellAddress>, Duplicatable, GenericRecord
See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'Common superclass of 8-bit and 16-bit versions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CellRangeAddressBase.CellPosition
Indicates a cell or range is in the given relative position in a range.
-
Constructor Summary
Constructors Modifier Constructor Description protected
CellRangeAddressBase(int firstRow, int lastRow, int firstCol, int lastCol)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsColumn(int colInd)
Check if the column is in the specified cell rangeboolean
containsRow(int rowInd)
Check if the row is in the specified cell rangeboolean
equals(Object other)
int
getFirstColumn()
int
getFirstRow()
Map<String,Supplier<?>>
getGenericProperties()
int
getLastColumn()
int
getLastRow()
protected int
getMaxColumn()
protected int
getMaxRow()
protected int
getMinColumn()
protected int
getMinRow()
int
getNumberOfCells()
Set<CellRangeAddressBase.CellPosition>
getPosition(int rowInd, int colInd)
Useful for logic like table/range styling, where some elements apply based on relative position in a range.int
hashCode()
boolean
intersects(CellRangeAddressBase other)
Determines whether or not this CellRangeAddress and the specified CellRangeAddress intersect.boolean
isFullColumnRange()
boolean
isFullRowRange()
boolean
isInRange(int rowInd, int colInd)
Determines if the given coordinates lie within the bounds of this range.boolean
isInRange(Cell cell)
Determines if the givenCell
lies within the bounds of this range.boolean
isInRange(CellAddress ref)
Determines if the givenCellAddress
lies within the bounds of this range.boolean
isInRange(CellReference ref)
Determines if the givenCellReference
lies within the bounds of this range.Iterator<CellAddress>
iterator()
Returns an iterator over the CellAddresses in this cell range in row-major order.void
setFirstColumn(int firstCol)
void
setFirstRow(int firstRow)
void
setLastColumn(int lastCol)
void
setLastRow(int lastRow)
Spliterator<CellAddress>
spliterator()
Returns a spliterator over the CellAddresses in this cell range in row-major order.String
toString()
void
validate(SpreadsheetVersion ssVersion)
Validate the range limits against the supplied version of Excel-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.poi.common.Duplicatable
copy
-
Methods inherited from interface org.apache.poi.common.usermodel.GenericRecord
getGenericChildren, getGenericRecordType
-
-
-
-
Method Detail
-
validate
public void validate(SpreadsheetVersion ssVersion)
Validate the range limits against the supplied version of Excel- Parameters:
ssVersion
- the version of Excel to validate against- Throws:
IllegalArgumentException
- if the range limits are outside of the allowed range
-
isFullColumnRange
public final boolean isFullColumnRange()
-
isFullRowRange
public final boolean isFullRowRange()
-
getFirstColumn
public final int getFirstColumn()
- Returns:
- column number for the upper left hand corner
-
getFirstRow
public final int getFirstRow()
- Returns:
- row number for the upper left hand corner
-
getLastColumn
public final int getLastColumn()
- Returns:
- column number for the lower right hand corner
-
getLastRow
public final int getLastRow()
- Returns:
- row number for the lower right hand corner
-
isInRange
public boolean isInRange(int rowInd, int colInd)
Determines if the given coordinates lie within the bounds of this range.- Parameters:
rowInd
- The row, 0-based.colInd
- The column, 0-based.- Returns:
- True if the coordinates lie within the bounds, false otherwise.
- See Also:
for checking if two ranges overlap
-
isInRange
public boolean isInRange(CellReference ref)
Determines if the givenCellReference
lies within the bounds of this range.NOTE: It is up to the caller to ensure the reference is for the correct sheet, since this instance doesn't have a sheet reference.
- Parameters:
ref
- the CellReference to check- Returns:
- True if the reference lies within the bounds, false otherwise.
- See Also:
for checking if two ranges overlap
-
isInRange
public boolean isInRange(CellAddress ref)
Determines if the givenCellAddress
lies within the bounds of this range.NOTE: It is up to the caller to ensure the reference is for the correct sheet, since this instance doesn't have a sheet reference.
- Parameters:
ref
- the CellAddress to check- Returns:
- True if the reference lies within the bounds, false otherwise.
- See Also:
for checking if two ranges overlap
-
isInRange
public boolean isInRange(Cell cell)
Determines if the givenCell
lies within the bounds of this range.NOTE: It is up to the caller to ensure the reference is for the correct sheet, since this instance doesn't have a sheet reference.
- Parameters:
cell
- the Cell to check- Returns:
- True if the cell lies within the bounds, false otherwise.
- See Also:
for checking if two ranges overlap
-
containsRow
public boolean containsRow(int rowInd)
Check if the row is in the specified cell range- Parameters:
rowInd
- the row to check- Returns:
- true if the range contains the row [rowInd]
-
containsColumn
public boolean containsColumn(int colInd)
Check if the column is in the specified cell range- Parameters:
colInd
- the column to check- Returns:
- true if the range contains the column [colInd]
-
intersects
public boolean intersects(CellRangeAddressBase other)
Determines whether or not this CellRangeAddress and the specified CellRangeAddress intersect.- Parameters:
other
- a candidate cell range address to check for intersection with this range- Returns:
- returns true if this range and other range have at least 1 cell in common
- See Also:
for checking if a single cell intersects
-
getPosition
public Set<CellRangeAddressBase.CellPosition> getPosition(int rowInd, int colInd)
Useful for logic like table/range styling, where some elements apply based on relative position in a range.- Returns:
- set of
CellRangeAddressBase.CellPosition
s occupied by the given coordinates. Empty if the coordinates are not in the range, never null. - Since:
- 3.17 beta 1
-
setFirstColumn
public final void setFirstColumn(int firstCol)
- Parameters:
firstCol
- column number for the upper left hand corner
-
setFirstRow
public final void setFirstRow(int firstRow)
- Parameters:
firstRow
- row number for the upper left hand corner
-
setLastColumn
public final void setLastColumn(int lastCol)
- Parameters:
lastCol
- column number for the lower right hand corner
-
setLastRow
public final void setLastRow(int lastRow)
- Parameters:
lastRow
- row number for the lower right hand corner
-
getNumberOfCells
public int getNumberOfCells()
- Returns:
- the size of the range (number of cells in the area).
-
iterator
public Iterator<CellAddress> iterator()
Returns an iterator over the CellAddresses in this cell range in row-major order.- Specified by:
iterator
in interfaceIterable<CellAddress>
- Since:
- POI 4.0.0
-
spliterator
public Spliterator<CellAddress> spliterator()
Returns a spliterator over the CellAddresses in this cell range in row-major order.- Specified by:
spliterator
in interfaceIterable<CellAddress>
- Since:
- POI 5.2.0
-
getMinRow
protected int getMinRow()
-
getMaxRow
protected int getMaxRow()
-
getMinColumn
protected int getMinColumn()
-
getMaxColumn
protected int getMaxColumn()
-
getGenericProperties
public Map<String,Supplier<?>> getGenericProperties()
- Specified by:
getGenericProperties
in interfaceGenericRecord
-
-