Here you can find the source of getListValue(Object container, int index)
public static Object getListValue(Object container, int index)
//package com.java2s; /*//from w w w. ja v a 2 s . co m * This file is part of the RUNA WFE project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; version 2.1 * of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ import java.util.List; public class Main { public static Object getListValue(Object container, int index) { if (container instanceof List) { List<?> list = (List<?>) container; if (list.size() > index) { return list.get(index); } else { throw new RuntimeException("List has insufficient size, index = " + index); } } else if (container.getClass().isArray()) { Object[] array = (Object[]) container; if (array.length > index) { return array[index]; } else { throw new RuntimeException("Array has insufficient length, index = " + index); } } else { throw new RuntimeException( "Unsupported array type " + (container != null ? container.getClass() : "null")); } } }