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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. Copyright (c) 2010 James Ahlborn
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package com.healthmarketscience.jackcess.impl;
  14. import java.io.IOException;
  15. import java.nio.ByteBuffer;
  16. /**
  17. * Interface for a handler which can encode/decode a specific access page
  18. * encoding.
  19. *
  20. * @author James Ahlborn
  21. */
  22. public interface CodecHandler
  23. {
  24. /**
  25. * Returns {@code true} if this handler can encode partial pages,
  26. * {@code false} otherwise. If this method returns {@code false}, the
  27. * {@link #encodePage} method will never be called with a non-zero
  28. * pageOffset.
  29. */
  30. public boolean canEncodePartialPage();
  31. /**
  32. * Returns {@code true} if this handler can decode a page inline,
  33. * {@code false} otherwise. If this method returns {@code false}, the
  34. * {@link #decodePage} method will always be called with separate buffers.
  35. */
  36. public boolean canDecodeInline();
  37. /**
  38. * Decodes the given page buffer.
  39. *
  40. * @param inPage the page to be decoded
  41. * @param outPage the decoded page. if {@link #canDecodeInline} is {@code
  42. * true}, this will be the same buffer as inPage.
  43. * @param pageNumber the page number of the given page
  44. *
  45. * @throws IOException if an exception occurs during decoding
  46. */
  47. public void decodePage(ByteBuffer inPage, ByteBuffer outPage, int pageNumber)
  48. throws IOException;
  49. /**
  50. * Encodes the given page buffer into a new page buffer and returns it. The
  51. * returned page buffer will be used immediately and discarded so that it
  52. * may be re-used for subsequent page encodings.
  53. *
  54. * @param page the page to be encoded, should not be modified
  55. * @param pageNumber the page number of the given page
  56. * @param pageOffset offset within the page at which to start writing the
  57. * page data
  58. *
  59. * @throws IOException if an exception occurs during decoding
  60. *
  61. * @return the properly encoded page buffer for the given page buffer
  62. */
  63. public ByteBuffer encodePage(ByteBuffer page, int pageNumber,
  64. int pageOffset)
  65. throws IOException;
  66. }