## org.apache.fop.fo.expr
Class Numeric

    java.lang.Object
      |
      +--org.apache.fop.fo.expr.Numeric

public class Numeric
extends java.lang.Object

Represents a "numeric" value as defined by the XSL FO Specification. This consists of one or more kinds of value specifications, from absolute numbers (units power of 0) to lengths (unit power of 1), relative lengths (ems), percentage lengths. A Numeric can be constructed from other Property types representing Numbers or Length-type values. Numeric provides methods to return Number and Length values based on its current value. It supports basic arithmetic operations involving Numerics.

Field Summary
`static int` `ABS_LENGTH`
`static int` `PC_LENGTH`
`static int` `TCOL_LENGTH`

Constructor Summary
`protected` `Numeric(int valType, double absValue, double pcValue, double tcolValue, int dim, PercentBase pcBase)` Construct a Numeric object by specifying one or more components, including absolute length, percent length, table units.
`` `Numeric(Length l)` Construct a Numeric object from a Length.
`` `Numeric(java.lang.Number num)` Construct a Numeric object from a Number.
`` `Numeric(PercentLength pclen)` Construct a Numeric object from a PercentLength.
`` `Numeric(TableColLength tclen)` Construct a Numeric object from a TableColLength.

Method Summary
`Numeric` `abs()` Return the absolute value of this Numeric.
`Numeric` `add(Numeric op)` Add the operand from the current value and return a new Numeric representing the result.
`java.lang.Double` `asDouble()`
`Length` `asLength()` Return the current value as a Length if possible.
`java.lang.Number` `asNumber()` Return the current value as a Number if possible.
`Numeric` `divide(Numeric op)` Divide the the current value by the operand and return a new Numeric representing the result.
`Numeric` `max(Numeric op)` Return a Numeric which is the maximum of the current value and the operand.
`Numeric` `min(Numeric op)` Return a Numeric which is the minimum of the current value and the operand.
`Numeric` `multiply(Numeric op)` Multiply the the current value by the operand and return a new Numeric representing the result.
`Numeric` `subtract(Numeric op)` Subtract the operand from the current value and return a new Numeric representing the result.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ABS_LENGTH

    public static final int ABS_LENGTH

### PC_LENGTH

    public static final int PC_LENGTH

### TCOL_LENGTH

    public static final int TCOL_LENGTH

Constructor Detail

### Numeric

    protected Numeric(int valType,
                      double absValue,
                      double pcValue,
                      double tcolValue,
                      int dim,
                      PercentBase pcBase)

  Construct a Numeric object by specifying one or more components, including absolute length, percent length, table units.
  Parameters:
    `valType` - A combination of bits representing the value types.
    `absValue` - The value of a Number or resolved Length value if the ABS_LENGTH flag is set.
    `pcValue` - The decimal percent value if the PC_LENGTH flag is set
    `tcolValue` - The decimal table unit value if the TCOL_LENGTH flag is set.
    `dim` - The dimension of the value. 0 for a Number, 1 for a Length (any type), >1, <0 if Lengths have been multiplied or divided.

### Numeric

    public Numeric(java.lang.Number num)

  Construct a Numeric object from a Number.
  Parameters:
    `num` - The number.

### Numeric

    public Numeric(Length l)

  Construct a Numeric object from a Length.
  Parameters:
    `l` - The Length.

### Numeric

    public Numeric(PercentLength pclen)

  Construct a Numeric object from a PercentLength.
  Parameters:
    `pclen` - The PercentLength.

### Numeric

    public Numeric(TableColLength tclen)

  Construct a Numeric object from a TableColLength.
  Parameters:
    `tclen` - The TableColLength.

Method Detail

### asLength

    public Length asLength()

  Return the current value as a Length if possible. This constructs a new Length or Length subclass based on the current value type of the Numeric. If the stored value has a unit dimension other than 1, null is returned.

### asNumber

    public java.lang.Number asNumber()

  Return the current value as a Number if possible. Calls asDouble().

### asDouble

    public java.lang.Double asDouble()

### subtract

    public Numeric subtract(Numeric op)
                     throws PropertyException

  Subtract the operand from the current value and return a new Numeric representing the result.
  Parameters:
    `op` - The value to subtract.
  Returns:
    A Numeric representing the result.
  Throws:
    PropertyException - If the dimension of the operand is different from the dimension of this Numeric.

### add

    public Numeric add(Numeric op)
                throws PropertyException

  Add the operand from the current value and return a new Numeric representing the result.
  Parameters:
    `op` - The value to add.
  Returns:
    A Numeric representing the result.
  Throws:
    PropertyException - If the dimension of the operand is different from the dimension of this Numeric.

### multiply

    public Numeric multiply(Numeric op)
                     throws PropertyException

  Multiply the the current value by the operand and return a new Numeric representing the result.
  Parameters:
    `op` - The multiplier.
  Returns:
    A Numeric representing the result.
  Throws:
    PropertyException - If both Numerics have "mixed" type.

### divide

    public Numeric divide(Numeric op)
                   throws PropertyException

  Divide the the current value by the operand and return a new Numeric representing the result.
  Parameters:
    `op` - The divisor.
  Returns:
    A Numeric representing the result.
  Throws:
    PropertyException - If both Numerics have "mixed" type.

### abs

    public Numeric abs()

  Return the absolute value of this Numeric.
  Returns:
    A new Numeric object representing the absolute value.

### max

    public Numeric max(Numeric op)
                throws PropertyException

  Return a Numeric which is the maximum of the current value and the operand.
  Throws:
    PropertyException - If the dimensions or value types of the object and the operand are different.

### min

    public Numeric min(Numeric op)
                throws PropertyException

  Return a Numeric which is the minimum of the current value and the operand.
  Throws:
    PropertyException - If the dimensions or value types of the object and the operand are different.

Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.