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.

CodecHandler.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright (c) 2010 James Ahlborn
  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. */
  16. package com.healthmarketscience.jackcess;
  17. import java.io.IOException;
  18. import java.nio.ByteBuffer;
  19. /**
  20. * Interface for a handler which can encode/decode a specific access page
  21. * encoding.
  22. *
  23. * @author James Ahlborn
  24. */
  25. public interface CodecHandler
  26. {
  27. /**
  28. * Returns {@code true} if this handler can encode partial pages,
  29. * {@code false} otherwise. If this method returns {@code false}, the
  30. * {@link #encodePage} method will never be called with a non-zero
  31. * pageOffset.
  32. */
  33. public boolean canEncodePartialPage();
  34. /**
  35. * Decodes the given page buffer inline.
  36. *
  37. * @param page the page to be decoded
  38. * @param pageNumber the page number of the given page
  39. *
  40. * @throws IOException if an exception occurs during decoding
  41. */
  42. public void decodePage(ByteBuffer page, int pageNumber) throws IOException;
  43. /**
  44. * Encodes the given page buffer into a new page buffer and returns it. The
  45. * returned page buffer will be used immediately and discarded so that it
  46. * may be re-used for subsequent page encodings.
  47. *
  48. * @param page the page to be encoded, should not be modified
  49. * @param pageNumber the page number of the given page
  50. * @param pageOffset offset within the page at which to start writing the
  51. * page data
  52. *
  53. * @throws IOException if an exception occurs during decoding
  54. *
  55. * @return the properly encoded page buffer for the given page buffer
  56. */
  57. public ByteBuffer encodePage(ByteBuffer page, int pageNumber,
  58. int pageOffset)
  59. throws IOException;
  60. }