From 967715266e456dd77e605e2a28bdbab17bfa546a Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 25 Sep 2003 18:05:50 +0000 Subject: [PATCH] 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 --- .../com/samskivert/velocity/DataTool.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 projects/samskivert/src/java/com/samskivert/velocity/DataTool.java diff --git a/projects/samskivert/src/java/com/samskivert/velocity/DataTool.java b/projects/samskivert/src/java/com/samskivert/velocity/DataTool.java new file mode 100644 index 00000000..7c104df2 --- /dev/null +++ b/projects/samskivert/src/java/com/samskivert/velocity/DataTool.java @@ -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); + } +}