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.

ErrorHandler.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright (c) 2008 Health Market Science, Inc.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  14. USA
  15. You can contact Health Market Science at info@healthmarketscience.com
  16. or at the following address:
  17. Health Market Science
  18. 2700 Horizon Drive
  19. Suite 200
  20. King of Prussia, PA 19406
  21. */
  22. package com.healthmarketscience.jackcess;
  23. import java.io.IOException;
  24. /**
  25. * Handler for errors encountered while reading a column of row data from a
  26. * Table. An instance of this class may be configured at the Database, Table,
  27. * or Cursor level to customize error handling as desired. The default
  28. * instance used is {@link Database#DEFAULT_ERROR_HANDLER}, which just
  29. * rethrows any exceptions encountered.
  30. *
  31. * @author James Ahlborn
  32. */
  33. public interface ErrorHandler
  34. {
  35. /**
  36. * Handles an error encountered while reading a column of data from a Table
  37. * row. Handler may either throw an exception (which will be propagated
  38. * back to the caller) or return a replacement for this row's column value
  39. * (in which case the row will continue to be read normally).
  40. *
  41. * @param column the info for the column being read
  42. * @param columnData the actual column data for the column being read (which
  43. * may be {@code null} dependening on when the exception
  44. * was thrown during the reading process)
  45. * @param rowState the current row state for the caller
  46. * @param error the error that was encountered
  47. *
  48. * @return replacement for this row's column
  49. */
  50. public Object handleRowError(Column column,
  51. byte[] columnData,
  52. Table.RowState rowState,
  53. Exception error)
  54. throws IOException;
  55. }