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.

HRESIAbstractType.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hwpf.model.types;
  16. import org.apache.poi.util.Internal;
  17. /**
  18. * Hyphenation (HRESI).
  19. * <p>
  20. * Class and fields descriptions are quoted from Microsoft Office Word 97-2007
  21. * Binary File Format (.doc) Specification
  22. */
  23. @Internal
  24. public abstract class HRESIAbstractType {
  25. public static final byte HRES_NO = 0;
  26. public static final byte HRES_NORMAL = 1;
  27. public static final byte HRES_ADD_LETTER_BEFORE = 2;
  28. public static final byte HRES_CHANGE_LETTER_BEFORE = 3;
  29. public static final byte HRES_DELETE_LETTER_BEFORE = 4;
  30. public static final byte HRES_CHANGE_LETTER_AFTER = 5;
  31. public static final byte HRES_DELETE_BEFORE_CHANGE_BEFORE = 6;
  32. protected byte field_1_hres;
  33. protected byte field_2_chHres;
  34. protected HRESIAbstractType() {}
  35. protected HRESIAbstractType(HRESIAbstractType other) {
  36. field_1_hres = other.field_1_hres;
  37. field_2_chHres = other.field_2_chHres;
  38. }
  39. protected void fillFields( byte[] data, int offset )
  40. {
  41. field_1_hres = data[ 0x0 + offset ];
  42. field_2_chHres = data[ 0x1 + offset ];
  43. }
  44. public void serialize( byte[] data, int offset )
  45. {
  46. data[ 0x0 + offset] = field_1_hres;
  47. data[ 0x1 + offset] = field_2_chHres;
  48. }
  49. /**
  50. * Size of record (exluding 4 byte header)
  51. */
  52. public static int getSize()
  53. {
  54. return 4 + + 1 + 1;
  55. }
  56. public String toString()
  57. {
  58. return "[HRESI]\n" +
  59. " .hres = " +
  60. " (" + getHres() + " )\n" +
  61. " .chHres = " +
  62. " (" + getChHres() + " )\n" +
  63. "[/HRESI]\n";
  64. }
  65. /**
  66. * Hyphenation rule.
  67. *
  68. * @return One of
  69. * <ul>
  70. * <li>{@link #HRES_NO}
  71. * <li>{@link #HRES_NORMAL}
  72. * <li>{@link #HRES_ADD_LETTER_BEFORE}
  73. * <li>{@link #HRES_CHANGE_LETTER_BEFORE}
  74. * <li>{@link #HRES_DELETE_LETTER_BEFORE}
  75. * <li>{@link #HRES_CHANGE_LETTER_AFTER}
  76. * <li>{@link #HRES_DELETE_BEFORE_CHANGE_BEFORE}
  77. * </ul>
  78. */
  79. public byte getHres()
  80. {
  81. return field_1_hres;
  82. }
  83. /**
  84. * Hyphenation rule.
  85. *
  86. * @param field_1_hres One of
  87. * <ul>
  88. * <li>{@link #HRES_NO}
  89. * <li>{@link #HRES_NORMAL}
  90. * <li>{@link #HRES_ADD_LETTER_BEFORE}
  91. * <li>{@link #HRES_CHANGE_LETTER_BEFORE}
  92. * <li>{@link #HRES_DELETE_LETTER_BEFORE}
  93. * <li>{@link #HRES_CHANGE_LETTER_AFTER}
  94. * <li>{@link #HRES_DELETE_BEFORE_CHANGE_BEFORE}
  95. * </ul>
  96. */
  97. public void setHres( byte field_1_hres )
  98. {
  99. this.field_1_hres = field_1_hres;
  100. }
  101. /**
  102. * The character that will be used to add or change a letter when hres is 2, 3, 5 or 6.
  103. */
  104. public byte getChHres()
  105. {
  106. return field_2_chHres;
  107. }
  108. /**
  109. * The character that will be used to add or change a letter when hres is 2, 3, 5 or 6.
  110. */
  111. public void setChHres( byte field_2_chHres )
  112. {
  113. this.field_2_chHres = field_2_chHres;
  114. }
  115. } // END OF CLASS