org.apache.poi.hssf.record.cf
Class CellRange

java.lang.Object
  extended by org.apache.poi.hssf.record.cf.CellRange

public final class CellRange
extends java.lang.Object

Author:
Dmitriy Kumshayev

Field Summary
static int ENCLOSES
          first range encloses or is equal to the second
static int INSIDE
          first range is within the second range
static int NO_INTERSECTION
           
static int OVERLAP
           
 
Constructor Summary
CellRange(int firstRow, int lastRow, int firstColumn, int lastColumn)
           
 
Method Summary
 CellRange cloneCellRange()
           
 boolean contains(CellRange range)
          Check if the specified range is located inside of this cell range.
 boolean contains(int row, short column)
           
static Region[] convertCellRangesToRegions(CellRange[] cellRanges)
          Convert a List of CellRange objects to an array of regions
static CellRange[] convertRegionsToCellRanges(Region[] regions)
          Convert array of regions to a List of CellRange objects
 CellRange createEnclosingCellRange(CellRange range)
          Create an enclosing CellRange for the two cell ranges.
 int getFirstColumn()
           
 int getFirstRow()
           
 int getLastColumn()
           
 int getLastRow()
           
 boolean hasExactSharedBorder(CellRange range)
          Check if the specified cell range has a shared border with the current range.
 int intersect(CellRange another)
          Intersect this range with the specified range.
 boolean isFullColumnRange()
           
 boolean isFullRowRange()
           
static CellRange[] mergeCellRanges(CellRange[] cellRanges)
          Do all possible cell merges between cells of the list so that:
if a cell range is completely inside of another cell range, it gets removed from the list if two cells have a shared border, merge them into one bigger cell range
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_INTERSECTION

public static final int NO_INTERSECTION
See Also:
Constant Field Values

OVERLAP

public static final int OVERLAP
See Also:
Constant Field Values

INSIDE

public static final int INSIDE
first range is within the second range

See Also:
Constant Field Values

ENCLOSES

public static final int ENCLOSES
first range encloses or is equal to the second

See Also:
Constant Field Values
Constructor Detail

CellRange

public CellRange(int firstRow,
                 int lastRow,
                 int firstColumn,
                 int lastColumn)
Parameters:
firstRow -
lastRow - pass -1 for full column ranges
firstColumn -
lastColumn - pass -1 for full row ranges
Method Detail

isFullColumnRange

public boolean isFullColumnRange()

isFullRowRange

public boolean isFullRowRange()

getFirstRow

public int getFirstRow()

getLastRow

public int getLastRow()

getFirstColumn

public int getFirstColumn()

getLastColumn

public int getLastColumn()

intersect

public int intersect(CellRange another)
Intersect this range with the specified range.

Parameters:
another - - the specified range
Returns:
code which reflects how the specified range is related to this range.
Possible return codes are: NO_INTERSECTION - the specified range is outside of this range;
OVERLAP - both ranges partially overlap;
INSIDE - the specified range is inside of this one
ENCLOSES - the specified range encloses (possibly exactly the same as) this range

mergeCellRanges

public static CellRange[] mergeCellRanges(CellRange[] cellRanges)
Do all possible cell merges between cells of the list so that:
  • if a cell range is completely inside of another cell range, it gets removed from the list
  • if two cells have a shared border, merge them into one bigger cell range

    Parameters:
    cellRangeList -
    Returns:
    updated List of cell ranges

  • convertRegionsToCellRanges

    public static CellRange[] convertRegionsToCellRanges(Region[] regions)
    Convert array of regions to a List of CellRange objects

    Parameters:
    regions -
    Returns:
    List of CellRange objects

    convertCellRangesToRegions

    public static Region[] convertCellRangesToRegions(CellRange[] cellRanges)
    Convert a List of CellRange objects to an array of regions

    Parameters:
    List - of CellRange objects
    Returns:
    regions

    contains

    public boolean contains(CellRange range)
    Check if the specified range is located inside of this cell range.

    Parameters:
    range -
    Returns:
    true if this cell range contains the argument range inside if it's area

    contains

    public boolean contains(int row,
                            short column)

    hasExactSharedBorder

    public boolean hasExactSharedBorder(CellRange range)
    Check if the specified cell range has a shared border with the current range.

    Returns:
    true if the ranges have a complete shared border (i.e. the two ranges together make a simple rectangular region.

    createEnclosingCellRange

    public CellRange createEnclosingCellRange(CellRange range)
    Create an enclosing CellRange for the two cell ranges.

    Returns:
    enclosing CellRange

    cloneCellRange

    public CellRange cloneCellRange()

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object


    Copyright 2008 The Apache Software Foundation or its licensors, as applicable.