Class Length

java.lang.Object
org.krysalis.barcode4j.tools.Length

public class Length extends Object
This class represents a length (value plus unit). It is used to parse expressions like "0.21mm".
Version:
$Id: Length.java,v 1.3 2008-05-13 13:00:46 jmaerki Exp $
Author:
Jeremias Maerki
  • Field Details

  • Constructor Details

    • Length

      public Length(double value, String unit)
      Creates a Length instance.
      Parameters:
      value - the value
      unit - the unit (ex. "cm")
    • Length

      public Length(String text, String defaultUnit)
      Creates a Length instance.
      Parameters:
      text - the String to parse
      defaultUnit - the default unit to assume
    • Length

      public Length(String text)
      Creates a Length instance. The default unit assumed is "mm".
      Parameters:
      text - the String to parse
  • Method Details

    • parse

      protected void parse(String text, String defaultUnit)
      Parses a value with unit.
      Parameters:
      text - the String to parse
      defaultUnit - the default unit to assume
    • getUnit

      public String getUnit()
      Returns the unit.
      Returns:
      String
    • getValue

      public double getValue()
      Returns the value.
      Returns:
      double
    • getValueAsMillimeter

      public double getValueAsMillimeter()
      Returns the value converted to internal units (mm).
      Returns:
      the value (in mm)
    • toString

      public String toString()
      Overrides:
      toString in class Object