barcode4j 2.1.0

org.krysalis.barcode4j.tools
Class Length

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

public class Length
extends java.lang.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 Summary
static java.lang.String CM
          String constant for centimeters.
static java.lang.String INCH
          String constant for inches.
static java.lang.String MM
          String constant for millimeters.
static java.lang.String POINT
          String constant for points.
 
Constructor Summary
Length(double value, java.lang.String unit)
          Creates a Length instance.
Length(java.lang.String text)
          Creates a Length instance.
Length(java.lang.String text, java.lang.String defaultUnit)
          Creates a Length instance.
 
Method Summary
 java.lang.String getUnit()
          Returns the unit.
 double getValue()
          Returns the value.
 double getValueAsMillimeter()
          Returns the value converted to internal units (mm).
protected  void parse(java.lang.String text, java.lang.String defaultUnit)
          Parses a value with unit.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INCH

public static final java.lang.String INCH
String constant for inches.

See Also:
Constant Field Values

POINT

public static final java.lang.String POINT
String constant for points.

See Also:
Constant Field Values

CM

public static final java.lang.String CM
String constant for centimeters.

See Also:
Constant Field Values

MM

public static final java.lang.String MM
String constant for millimeters.

See Also:
Constant Field Values
Constructor Detail

Length

public Length(double value,
              java.lang.String unit)
Creates a Length instance.

Parameters:
value - the value
unit - the unit (ex. "cm")

Length

public Length(java.lang.String text,
              java.lang.String defaultUnit)
Creates a Length instance.

Parameters:
text - the String to parse
defaultUnit - the default unit to assume

Length

public Length(java.lang.String text)
Creates a Length instance. The default unit assumed is "mm".

Parameters:
text - the String to parse
Method Detail

parse

protected void parse(java.lang.String text,
                     java.lang.String defaultUnit)
Parses a value with unit.

Parameters:
text - the String to parse
defaultUnit - the default unit to assume

getUnit

public java.lang.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 java.lang.String toString()

Overrides:
toString in class java.lang.Object

barcode4j 2.1.0

Copyright © 2000-2010 Jeremias Maerki. All rights reserved.