Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

DBMutator.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright (c) 2016 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.charset.Charset;
  16. /**
  17. * Common helper class used to maintain state during database mutation.
  18. *
  19. * @author James Ahlborn
  20. */
  21. abstract class DBMutator
  22. {
  23. private final DatabaseImpl _database;
  24. protected DBMutator(DatabaseImpl database) {
  25. _database = database;
  26. }
  27. public DatabaseImpl getDatabase() {
  28. return _database;
  29. }
  30. public JetFormat getFormat() {
  31. return _database.getFormat();
  32. }
  33. public PageChannel getPageChannel() {
  34. return _database.getPageChannel();
  35. }
  36. public Charset getCharset() {
  37. return _database.getCharset();
  38. }
  39. public int reservePageNumber() throws IOException {
  40. return getPageChannel().allocateNewPage();
  41. }
  42. public static int calculateNameLength(String name) {
  43. return (name.length() * JetFormat.TEXT_FIELD_UNIT_SIZE) + 2;
  44. }
  45. protected ColumnImpl.SortOrder getDbSortOrder() {
  46. try {
  47. return _database.getDefaultSortOrder();
  48. } catch(IOException e) {
  49. // ignored, just use the jet format default
  50. }
  51. return null;
  52. }
  53. }