1 16 package org.apache.myfaces.component.html.ext; 17 18 import javax.faces.component.StateHolder; 19 import java.io.Serializable ; 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 28 class _SerializableListDataModel 29 extends _SerializableDataModel 30 { 31 33 public _SerializableListDataModel(int first, int rows, List list) 34 { 35 _first = first; 36 _rows = rows; 37 _rowCount = list.size(); 38 if (_rows <= 0) 39 { 40 _rows = _rowCount - first; 41 } 42 43 if (_rows == _rowCount) 44 { 45 if (list instanceof Serializable || list instanceof StateHolder) 47 { 48 _list = list; 49 } 50 else 51 { 52 _list = new ArrayList (list); 54 } 55 } 56 else 57 { 58 int size = _rows > 0 && _rows < _rowCount ? _rows : _rowCount; 59 _list = new ArrayList (size); 60 if (size > _rowCount - _first) 61 { 62 size = _rowCount - _first; 63 } 64 for (int i = 0; i < size; i++) 65 { 66 _list.add(list.get(_first + i)); 67 } 68 } 69 } 70 } 71 | Popular Tags |