com.samskivert.velocity
Class DataTool

java.lang.Object
  extended by com.samskivert.velocity.DataTool

public class DataTool
extends Object

Some helpful methods for dealing with data in velocity.


Constructor Summary
DataTool()
           
 
Method Summary
 double add(double a, double b)
          Double addition.
 float div(float a, float b)
          Floating point divide.
 Object get(Object array, int index)
          Returns the object in the array at index.
 int length(Object array)
          Returns the length of the specified array.
 int percent(int num, int denom)
          Returns the numerator as a percentage of the denominator (100 * num / denom), handles 0/0 (returns 0), but will div0 on N/0 where N !
<T extends Comparable<? super T>>
List<T>
sort(Collection<T> data)
          Copies the data from the supplied collection into a list, sorts it and returns the list.
<T extends Comparable<? super T>>
List<T>
sort(Iterator<T> iter)
          Copies the data from the supplied iterator into a list, sorts it and returns the list.
<T extends Comparable<? super T>>
List<T>
sort(List<T> list)
          Sorts the supplied list and returns it.
 Object unwrap(Object array)
          Returns the object at location zero in the array, super useful for those length 1 arrays (like when you are storing primitives in a hash)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataTool

public DataTool()
Method Detail

unwrap

public Object unwrap(Object array)
Returns the object at location zero in the array, super useful for those length 1 arrays (like when you are storing primitives in a hash)


get

public Object get(Object array,
                  int index)
Returns the object in the array at index. Wrapped as an object if it is a primitive.


length

public int length(Object array)
Returns the length of the specified array.


percent

public int percent(int num,
                   int denom)
Returns the numerator as a percentage of the denominator (100 * num / denom), handles 0/0 (returns 0), but will div0 on N/0 where N != 0.


div

public float div(float a,
                 float b)
Floating point divide.


add

public double add(double a,
                  double b)
Double addition.


sort

public <T extends Comparable<? super T>> List<T> sort(List<T> list)
Sorts the supplied list and returns it. The elements must implement Comparable.


sort

public <T extends Comparable<? super T>> List<T> sort(Collection<T> data)
Copies the data from the supplied collection into a list, sorts it and returns the list. The elements must implement Comparable.


sort

public <T extends Comparable<? super T>> List<T> sort(Iterator<T> iter)
Copies the data from the supplied iterator into a list, sorts it and returns the list. The elements must implement Comparable.



Copyright © 2000-2008 Michael Bayne. All Rights Reserved.