ArrayDataModel

package javax.faces.model;

public class ArrayDataModel extends DataModel
{
// FIELDS027  
private int _rowIndex = -1;028  
private Object[] _data;029030 // CONSTRUCTORS031
public ArrayDataModel() {
super();
}
public ArrayDataModel(Object[] array)
{     
if (array == null) throw new NullPointerException("array");
setWrappedData(array);
}
// METHODS043
public int getRowCount()
{      
if (_data == null)  
     {           
return -1;
      }     
return _data.length;
}
public Object getRowData() {
if (_data == null)   
               {
            return null;    
  }        if (!isRowAvailable())
       {          throw new IllegalArgumentException("row is unavailable");
        }
return _data[_rowIndex];
}
public int getRowIndex()
{ return _rowIndex;
}
public Object getWrappedData() { return _data;
}
public boolean isRowAvailable() {
if (_data == null)       {
          return false;      }
        return _rowIndex >= 0 && _rowIndex < _data.length;
}
public void setRowIndex(int rowIndex)
{ if (rowIndex < -1)       {
            throw new IllegalArgumentException("illegal rowIndex " + rowIndex);
      }        int oldRowIndex = _rowIndex;
_rowIndex = rowIndex;
        if (_data != null && oldRowIndex != _rowIndex)
     {
           Object data = isRowAvailable() ? getRowData() : null;
            DataModelEvent event = new DataModelEvent(this, _rowIndex, data);
            DataModelListener[] listeners = getDataModelListeners();
            for (int i = 0; i < listeners.length; i++)
          {
                listeners[i].rowSelected(event);
            }
        }
}
public void setWrappedData(Object data)
{
       _data = (Object[])data;
int rowIndex = _data != null ? 0 : -1;
       setRowIndex(rowIndex);
}
}

你可能感兴趣的:(array)