Har, let there be some useful functions for dealing with arrays. Oh

velocity developers, what were ye thinking taking away the wonders of
arrays from us?


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1231 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
eric
2003-09-25 18:05:50 +00:00
parent 8c83a7277c
commit 967715266e
@@ -0,0 +1,31 @@
//
// $Id: DataTool.java,v 1.1 2003/09/25 18:05:50 eric Exp $
package com.samskivert.velocity;
import java.lang.reflect.Array;
/**
* Some helpful methods for dealing with data in velocity.
*/
public class DataTool
{
/**
* 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)
*/
public Object unwrap (Object array)
{
return get(array, 0);
}
/**
* Returns the object in the array at index. Wrapped as an object if
* it is a primitive.
*/
public Object get (Object array, int index)
{
return Array.get(array, index);
}
}