Class Address

  • All Implemented Interfaces:
    java.lang.Comparable<Address>

    public class Address
    extends java.lang.Object
    implements java.lang.Comparable<Address>
    C class representing a cell address (no getters and setters to simplify handling)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int Column
      Column of the address (zero-based)
      int Row
      Row of the address (zero-based)
      Cell.AddressType Type  
    • Constructor Summary

      Constructors 
      Constructor Description
      Address​(int column, int row)
      Constructor with with row and column as arguments
      Address​(int column, int row, Cell.AddressType type)
      Constructor with with row, column and address type as arguments
      Address​(java.lang.String address)
      Constructor with address as string
      Address​(java.lang.String address, Cell.AddressType type)
      Constructor with address as string and address type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Address other)
      Compares two addresses and returns whether the passed one is bigger or not.
      boolean equals​(java.lang.Object o)
      Compares two addresses whether they are equal.
      java.lang.String getAddress()
      Gets the address as string
      java.lang.String getColumn()
      Gets the column address (A - XFD)
      java.lang.String toString()
      Returns the address as string or "Illegal Address" in case of an exception
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String getColumn()
        Gets the column address (A - XFD)
        Returns:
        Column address as letter(s)
      • toString

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