org.webmacro.servlet
Class MathTool

java.lang.Object
  |
  +--org.webmacro.servlet.MathTool
All Implemented Interfaces:
ContextTool

public class MathTool
extends java.lang.Object
implements ContextTool

A ContextTool for performing the more useful methods from java.lang.Math.

Author:
Eric B. Ridge (mailto:ebr@tcdi.com)

Field Summary
static double PI
          the value of PI, as defined by java.lang.Math.PI
 
Constructor Summary
MathTool()
          default contsructor.
MathTool(Context context)
          public constructor.
 
Method Summary
static double abs(double a)
           
static float abs(float a)
           
static int abs(int a)
           
static long abs(long a)
           
 void destroy(java.lang.Object o)
          Perform necessary cleanup work
static MathTool getInstance()
           
 java.lang.Object init(Context context)
          Tool initialization method.
static double max(double a, double b)
           
static float max(float a, float b)
           
static int max(int a, int b)
           
static long max(long a, long b)
           
static double min(double a, double b)
           
static float min(float a, float b)
           
static int min(int a, int b)
           
static long min(long a, long b)
           
static int mod(int a, int b)
           
static int pow(int base, int power)
           
static long pow(long base, long power)
           
static int random(int start, int end)
          Creates a pseudo-random Integer between start and end, inclusive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PI

public static final double PI
the value of PI, as defined by java.lang.Math.PI
Constructor Detail

MathTool

public MathTool()
default contsructor. Does nothing

MathTool

public MathTool(Context context)
public constructor. Does nothing. The MathTool doesn't interact with the Context, so it is ignored
Method Detail

getInstance

public static final MathTool getInstance()
Returns:
the static instance of the MathTool

min

public static final int min(int a,
                            int b)
Returns:
the smaller of the specified number

min

public static final long min(long a,
                             long b)

min

public static final float min(float a,
                              float b)

min

public static final double min(double a,
                               double b)

max

public static final int max(int a,
                            int b)
Returns:
the larger of the specified number

max

public static final long max(long a,
                             long b)

max

public static final float max(float a,
                              float b)

max

public static final double max(double a,
                               double b)

random

public static final int random(int start,
                               int end)
Creates a pseudo-random Integer between start and end, inclusive

pow

public static final int pow(int base,
                            int power)
Returns:
base raised to the specified power

pow

public static final long pow(long base,
                             long power)

abs

public static final int abs(int a)
Returns:
the absolute value of the specified number

abs

public static final long abs(long a)

abs

public static final float abs(float a)

abs

public static final double abs(double a)

mod

public static final int mod(int a,
                            int b)
Returns:
a modulo b

init

public java.lang.Object init(Context context)
                      throws PropertyException
Tool initialization method. The MathTool doesn't interact with the context, so the context parameter is ignored.
Specified by:
init in interface ContextTool

destroy

public void destroy(java.lang.Object o)
Perform necessary cleanup work
Specified by:
destroy in interface ContextTool