/** * Inserts the specified element at the specified position in this list. Shifts the element * currently at that position (if any) and any subsequent elements to the right (adds one to * their indices). * <p/> * This method is guaranteed to work since it will create empty beans to fill the gap between * the current list size and the requested index to enable the element to be set. This method * also performs any necessary type conversion. * * @param index index at which the specified element is to be inserted. * @param element element to be inserted. */ @Override public void add(int index, Object element) { if (index >= this.size()) { get(index); } element = convert(element); super.add(index, element); }
/** * Replaces the element at the specified position in this list with the specified element. * <p/> * This method is guaranteed to work since it will create empty beans to fill the gap between * the current list size and the requested index to enable the element to be set. This method * also performs any necessary type conversion. * * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. */ @Override public Object set(int index, Object element) { if (index >= this.size()) { get(index); } element = convert(element); return super.set(index, element); }
/** * Returns the element at the specified position in this list. * <p/> * An object is guaranteed to be returned since it will create empty beans to fill the gap * between the current list size and the requested index. * * @param index index of element to return. * @return the element at the specified position in this list. */ @Override public synchronized Object get(int index) { while (index >= this.size()) { try { this.add(getObjectFactory().buildBean(clazz, ActionContext.getContext().getContextMap())); } catch (Exception e) { throw new XWorkException(e); } } return super.get(index); }