Class Address

  • All Implemented Interfaces:
    Comparable<Address>

    public class Address
    extends Object
    implements Comparable<Address>
    C class representing a cell address (no getters and setters to simplify handling)
    Author:
    Raphael Stoeckli
    • Field Detail

      • Column

        public final int Column
        Column of the address (zero-based)
      • Row

        public final int Row
        Row of the address (zero-based)
    • Constructor Detail

      • Address

        public Address​(int column,
                       int row)
        Constructor with with row and column as arguments
        Parameters:
        column - Column of the address (zero-based)
        row - Row of the address (zero-based)
        Throws:
        RangeException - Thrown if the resolved address is out of range
      • Address

        public Address​(String address)
        Constructor with address as string
        Parameters:
        address - Address string (e.g. 'A1:B12')
        Throws:
        RangeException - Thrown if the resolved address is out of range
      • Address

        public Address​(int column,
                       int row,
                       Cell.AddressType type)
        Constructor with with row, column and address type as arguments
        Parameters:
        column - Column of the address (zero-based)
        row - Row of the address (zero-based)
        type - Referencing type of the address
        Throws:
        RangeException - Thrown if the resolved address is out of range
      • Address

        public Address​(String address,
                       Cell.AddressType type)
        Constructor with address as string and address type. The address type overrides possible address variations in the string
        Parameters:
        address - Address string (e.g. 'A1:B12')
        type - Optional referencing type of the address
        Throws:
        RangeException - Thrown if the resolved address is out of range
    • Method Detail

      • equals

        public boolean equals​(Object o)
        Compares two addresses whether they are equal. The address type id neglected, only the row and column is considered
        Overrides:
        equals in class Object
        Parameters:
        o - Address to compare
        Returns:
        True if equal
      • compareTo

        public int compareTo​(Address other)
        Compares two addresses and returns whether the passed one is bigger or not. Bigger means: Higher column number and / or higher row number
        Specified by:
        compareTo in interface Comparable<Address>
        Parameters:
        other - Other address to compare
        Returns:
        1 If the other address is bigger, -1 if it is smaller and 0 ist it is equal
      • getAddress

        public String getAddress()
        Gets the address as string
        Returns:
        Address as string
        Throws:
        RangeException - Thrown if the column or row is out of range
      • getColumn

        public String getColumn()
        Gets the column address (A - XFD)
        Returns:
        Column address as letter(s)
      • toString

        public String toString()
        Returns the address as string or "Illegal Address" in case of an exception
        Overrides:
        toString in class Object
        Returns:
        Address or notification in case of an error