aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-06-20 00:16:41 +0000
committerJaven O'Neal <onealj@apache.org>2016-06-20 00:16:41 +0000
commit8ee07a27f56301041bfb213f5f0dbc52f34b5641 (patch)
tree2a8079c68d6fa70e0ba5af196ffb949e3c05645d /src/java/org/apache/poi
parent5be01c04f434d8df94f6ab96c1434a315e8fd10b (diff)
downloadpoi-8ee07a27f56301041bfb213f5f0dbc52f34b5641.tar.gz
poi-8ee07a27f56301041bfb213f5f0dbc52f34b5641.zip
bug 56454: add CellRangeAddress#containsRow and containsColumn
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749239 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi')
-rw-r--r--src/java/org/apache/poi/ss/util/CellRangeAddressBase.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java b/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java
index 05ebdd2c2a..f94444d9a7 100644
--- a/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java
+++ b/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java
@@ -118,10 +118,31 @@ public abstract class CellRangeAddressBase {
* @param rowInd The row, 0-based.
* @param colInd The column, 0-based.
* @return True if the coordinates lie within the bounds, false otherwise.
+ * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
*/
public boolean isInRange(int rowInd, int colInd) {
- return _firstRow <= rowInd && rowInd <= _lastRow &&
- _firstCol <= colInd && colInd <= _lastCol;
+ return _firstRow <= rowInd && rowInd <= _lastRow && //containsRow
+ _firstCol <= colInd && colInd <= _lastCol; //containsColumn
+ }
+
+ /**
+ * Check if the row is in the specified cell range
+ *
+ * @param rowInd the row to check
+ * @return true if the range contains the row [rowInd]
+ */
+ public boolean containsRow(int rowInd) {
+ return _firstRow <= rowInd && rowInd <= _lastRow;
+ }
+
+ /**
+ * Check if the column is in the specified cell range
+ *
+ * @param colInd the column to check
+ * @return true if the range contains the column [colInd]
+ */
+ public boolean containsColumn(int colInd) {
+ return _firstCol <= colInd && colInd <= _lastCol;
}
/**
@@ -129,6 +150,7 @@ public abstract class CellRangeAddressBase {
*
* @param other a candidate cell range address to check for intersection with this range
* @return returns true if this range and other range have at least 1 cell in common
+ * @see #isInRange(int, int) for checking if a single cell intersects
*/
public boolean intersects(CellRangeAddressBase other) {
return this._firstRow <= other._lastRow &&