You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DataSource.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2000-2013 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client.data;
  17. /**
  18. * Source of data for widgets showing lazily loaded data based on indexable
  19. * items (e.g. rows) of a specified type. The data source is a lazy view into a
  20. * larger data set.
  21. *
  22. * @since 7.2
  23. * @author Vaadin Ltd
  24. * @param <T>
  25. * the row type
  26. */
  27. public interface DataSource<T> {
  28. /**
  29. * Informs the data source that data for the given range is needed. A data
  30. * source only has one active region at a time, so calling this method
  31. * discards the previously set range.
  32. * <p>
  33. * This method triggers lazy loading of data if necessary. The change
  34. * handler registered using {@link #setDataChangeHandler(DataChangeHandler)}
  35. * is informed when new data has been loaded.
  36. *
  37. * @param firstRowIndex
  38. * the index of the first needed row
  39. * @param numberOfRows
  40. * the number of needed rows
  41. */
  42. public void ensureAvailability(int firstRowIndex, int numberOfRows);
  43. /**
  44. * Retrieves the data for the row at the given index. If the row data is not
  45. * available, returns <code>null</code>.
  46. * <p>
  47. * This method does not trigger loading of unavailable data.
  48. * {@link #ensureAvailability(int, int)} should be used to signal what data
  49. * will be needed.
  50. *
  51. * @param rowIndex
  52. * the index of the row to retrieve data for
  53. * @return data for the row; or <code>null</code> if no data is available
  54. */
  55. public T getRow(int rowIndex);
  56. /**
  57. * Returns the current best guess for the number of rows in the container.
  58. *
  59. * @return the current estimation of the container size
  60. */
  61. public int getEstimatedSize();
  62. /**
  63. * Sets a data change handler to inform when data is updated, added or
  64. * removed.
  65. *
  66. * @param dataChangeHandler
  67. * the data change handler
  68. */
  69. public void setDataChangeHandler(DataChangeHandler dataChangeHandler);
  70. }