Class UnitRepresentation

java.lang.Object
uk.me.nxg.unity.UnitRepresentation
All Implemented Interfaces:
Iterator<UnitRepresentation>

public class UnitRepresentation extends Object implements Iterator<UnitRepresentation>
A description of the way that a unit is represented in a particular syntax.
  • Method Details

    • toString

      public String toString()
      Produce a compact string representation of the unit. This is intended to be a human-readable unit string, such as "m" for metres. If, however, you wish to get a unit-string representation of a unit expression, do not construct it yourself using this method, but instead use UnitExpr.toString(), the output of which may differ from the output of this method in certain circumstances.
      Overrides:
      toString in class Object
    • toDebugString

      public String toDebugString()
      Produce a slightly more detailed representation of the object's fields. This is mostly for debugging purposes, and the format of the string is not necessarily stable.
      Returns:
      a string with developer-ready extra information
    • mayHaveSIPrefixes

      public boolean mayHaveSIPrefixes()
      Indicates whether this unit may be used with SI prefixes.
      Returns:
      true if this unit may have SI prefixes
    • mayHaveBinaryPrefixes

      public boolean mayHaveBinaryPrefixes()
      Indicates whether this unit may be used with binary prefixes.
      Returns:
      true if this unit may have binary prefixes
    • isDeprecated

      public boolean isDeprecated()
      Indicates whether this syntax deprecates (but still permits) the use of this unit.
      Returns:
      true if use of this unit is deprecated
    • getAbbreviation

      public String getAbbreviation()
      Returns a symbolic abbreviation for this unit in this syntax. For example, it might return "m" for Metres.
      Returns:
      a string abbreviation for this unit
    • hasNext

      public boolean hasNext()
      If there is more than one representation for this unit in this syntax, then this will return the next one.
      Specified by:
      hasNext in interface Iterator<UnitRepresentation>
      Returns:
      true if there is a further representation of this unit
    • next

      public UnitRepresentation next()
      Returns true if hasNext() would succeed. return true if hasNext() would succeed.
      Specified by:
      next in interface Iterator<UnitRepresentation>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<UnitRepresentation>