csheets.core
Class Address

java.lang.Object
  extended by csheets.core.Address
All Implemented Interfaces:
Serializable, Comparable<Address>

public class Address
extends Object
implements Comparable<Address>, Serializable

An address in a spreadsheet that denotes to the location of a cell.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
static char HIGHEST_CHAR
          The highest character to be used in a column name
static char LOWEST_CHAR
          The lowest character to be used in a column name
 
Constructor Summary
Address(int column, int row)
          Creates a new address from the given column and row indices.
 
Method Summary
 int compareTo(Address address)
          Compares this address with the given address for order.
 boolean equals(Object other)
          Returns whether the other object is an address with the same column and row coordinates as this address.
 int getColumn()
          Returns the column of the address.
 int getRow()
          Returns the row of the address.
 int hashCode()
          Returns the hash code of the address.
 String toString()
          Returns a string representation of the address on the form "B22", composed of the letter of the column and number of the row that intersect to form the address.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOWEST_CHAR

public static final char LOWEST_CHAR
The lowest character to be used in a column name

See Also:
Constant Field Values

HIGHEST_CHAR

public static final char HIGHEST_CHAR
The highest character to be used in a column name

See Also:
Constant Field Values
Constructor Detail

Address

public Address(int column,
               int row)
Creates a new address from the given column and row indices.

Parameters:
column - the column of the address
row - the row of the address
Method Detail

getColumn

public int getColumn()
Returns the column of the address.

Returns:
the column of the address

getRow

public int getRow()
Returns the row of the address.

Returns:
the row of the address

equals

public boolean equals(Object other)
Returns whether the other object is an address with the same column and row coordinates as this address.

Overrides:
equals in class Object
Parameters:
other - the object to check for equality
Returns:
true if the objects are equal

hashCode

public int hashCode()
Returns the hash code of the address.

Overrides:
hashCode in class Object
Returns:
an int with the column in the 16 high bits, row in the low 16.

compareTo

public int compareTo(Address address)
Compares this address with the given address for order. Ordering is first done on the addresses' columns, then on their rows.

Specified by:
compareTo in interface Comparable<Address>
Parameters:
address - the address to compared to
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public String toString()
Returns a string representation of the address on the form "B22", composed of the letter of the column and number of the row that intersect to form the address.

Overrides:
toString in class Object
Returns:
a string representation of the address