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.

TBDAbstractType.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.BitField;
  17. import org.apache.poi.util.Internal;
  18. /**
  19. * The TBD is a substructure of the PAP.
  20. */
  21. @Internal
  22. public abstract class TBDAbstractType {
  23. private static final BitField jc = new BitField(0x07);
  24. private static final BitField tlc = new BitField(0x38);
  25. private static final BitField reserved = new BitField(0xc0);
  26. protected byte field_1_value;
  27. protected TBDAbstractType() { }
  28. protected TBDAbstractType(TBDAbstractType other) {
  29. field_1_value = other.field_1_value;
  30. }
  31. protected void fillFields( byte[] data, int offset )
  32. {
  33. field_1_value = data[ 0x0 + offset ];
  34. }
  35. public void serialize( byte[] data, int offset )
  36. {
  37. data[ 0x0 + offset] = field_1_value;
  38. }
  39. /**
  40. * Size of record
  41. */
  42. public static int getSize()
  43. {
  44. return 0 + 1;
  45. }
  46. public String toString()
  47. {
  48. StringBuilder builder = new StringBuilder();
  49. builder.append("[TBD]\n");
  50. builder.append(" .value = ");
  51. builder.append(" (").append(getValue()).append(" )\n");
  52. builder.append(" .jc = ").append(getJc()).append('\n');
  53. builder.append(" .tlc = ").append(getTlc()).append('\n');
  54. builder.append(" .reserved = ").append(getReserved()).append('\n');
  55. builder.append("[/TBD]\n");
  56. return builder.toString();
  57. }
  58. /**
  59. * Get the value field for the TBD record.
  60. */
  61. @Internal
  62. public byte getValue()
  63. {
  64. return field_1_value;
  65. }
  66. /**
  67. * Set the value field for the TBD record.
  68. */
  69. @Internal
  70. public void setValue( byte field_1_value )
  71. {
  72. this.field_1_value = field_1_value;
  73. }
  74. /**
  75. * Sets the jc field value.
  76. * Justification code
  77. */
  78. @Internal
  79. public void setJc( byte value )
  80. {
  81. field_1_value = (byte)jc.setValue(field_1_value, value);
  82. }
  83. /**
  84. * Justification code
  85. * @return the jc field value.
  86. */
  87. @Internal
  88. public byte getJc()
  89. {
  90. return ( byte )jc.getValue(field_1_value);
  91. }
  92. /**
  93. * Sets the tlc field value.
  94. * Tab leader code
  95. */
  96. @Internal
  97. public void setTlc( byte value )
  98. {
  99. field_1_value = (byte)tlc.setValue(field_1_value, value);
  100. }
  101. /**
  102. * Tab leader code
  103. * @return the tlc field value.
  104. */
  105. @Internal
  106. public byte getTlc()
  107. {
  108. return ( byte )tlc.getValue(field_1_value);
  109. }
  110. /**
  111. * Sets the reserved field value.
  112. *
  113. */
  114. @Internal
  115. public void setReserved( byte value )
  116. {
  117. field_1_value = (byte)reserved.setValue(field_1_value, value);
  118. }
  119. /**
  120. *
  121. * @return the reserved field value.
  122. */
  123. @Internal
  124. public byte getReserved()
  125. {
  126. return ( byte )reserved.getValue(field_1_value);
  127. }
  128. } // END OF CLASS