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.

GeneralIndexCodes.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. Copyright (c) 2011 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. /**
  15. * Various constants used for creating "general" (access 2010+) sort order
  16. * text index entries.
  17. *
  18. * @author James Ahlborn
  19. */
  20. public class GeneralIndexCodes extends GeneralLegacyIndexCodes {
  21. // stash the codes in some resource files
  22. private static final String CODES_FILE =
  23. DatabaseImpl.RESOURCE_PATH + "index_codes_gen.txt";
  24. private static final String EXT_CODES_FILE =
  25. DatabaseImpl.RESOURCE_PATH + "index_codes_ext_gen.txt";
  26. private static final class Codes
  27. {
  28. /** handlers for the first 256 chars. use nested class to lazy load the
  29. handlers */
  30. private static final CharHandler[] _values = loadCodes(
  31. CODES_FILE, FIRST_CHAR, LAST_CHAR);
  32. }
  33. private static final class ExtCodes
  34. {
  35. /** handlers for the rest of the chars in BMP 0. use nested class to
  36. lazy load the handlers */
  37. private static final CharHandler[] _values = loadCodes(
  38. EXT_CODES_FILE, FIRST_EXT_CHAR, LAST_EXT_CHAR);
  39. }
  40. static final GeneralIndexCodes GEN_INSTANCE = new GeneralIndexCodes();
  41. GeneralIndexCodes() {
  42. }
  43. /**
  44. * Returns the CharHandler for the given character.
  45. */
  46. @Override
  47. CharHandler getCharHandler(char c)
  48. {
  49. if(c <= LAST_CHAR) {
  50. return Codes._values[c];
  51. }
  52. int extOffset = asUnsignedChar(c) - asUnsignedChar(FIRST_EXT_CHAR);
  53. return ExtCodes._values[extOffset];
  54. }
  55. }