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.

FtrHeader.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.hssf.record.common;
  16. import java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.common.Duplicatable;
  19. import org.apache.poi.common.usermodel.GenericRecord;
  20. import org.apache.poi.hssf.record.RecordInputStream;
  21. import org.apache.poi.ss.util.CellRangeAddress;
  22. import org.apache.poi.util.GenericRecordJsonWriter;
  23. import org.apache.poi.util.GenericRecordUtil;
  24. import org.apache.poi.util.LittleEndianOutput;
  25. /**
  26. * Title: FtrHeader (Future Record Header) common record part
  27. * <P>
  28. * This record part specifies a header for a Ftr (Future)
  29. * style record, which includes extra attributes above and
  30. * beyond those of a traditional record.
  31. */
  32. public final class FtrHeader implements Duplicatable, GenericRecord {
  33. /** This MUST match the type on the containing record */
  34. private short recordType;
  35. /** This is a FrtFlags */
  36. private short grbitFrt;
  37. /** The range of cells the parent record applies to, or 0 if N/A */
  38. private CellRangeAddress associatedRange;
  39. public FtrHeader() {
  40. associatedRange = new CellRangeAddress(0, 0, 0, 0);
  41. }
  42. public FtrHeader(FtrHeader other) {
  43. recordType = other.recordType;
  44. grbitFrt = other.grbitFrt;
  45. associatedRange = other.associatedRange.copy();
  46. }
  47. public FtrHeader(RecordInputStream in) {
  48. recordType = in.readShort();
  49. grbitFrt = in.readShort();
  50. associatedRange = new CellRangeAddress(in);
  51. }
  52. public String toString() {
  53. return GenericRecordJsonWriter.marshal(this);
  54. }
  55. public void serialize(LittleEndianOutput out) {
  56. out.writeShort(recordType);
  57. out.writeShort(grbitFrt);
  58. associatedRange.serialize(out);
  59. }
  60. public static int getDataSize() {
  61. return 12;
  62. }
  63. public short getRecordType() {
  64. return recordType;
  65. }
  66. public void setRecordType(short recordType) {
  67. this.recordType = recordType;
  68. }
  69. public short getGrbitFrt() {
  70. return grbitFrt;
  71. }
  72. public void setGrbitFrt(short grbitFrt) {
  73. this.grbitFrt = grbitFrt;
  74. }
  75. public CellRangeAddress getAssociatedRange() {
  76. return associatedRange;
  77. }
  78. public void setAssociatedRange(CellRangeAddress associatedRange) {
  79. this.associatedRange = associatedRange;
  80. }
  81. public FtrHeader copy() {
  82. return new FtrHeader(this);
  83. }
  84. @Override
  85. public Map<String, Supplier<?>> getGenericProperties() {
  86. return GenericRecordUtil.getGenericProperties(
  87. "recordType", this::getRecordType,
  88. "grbitFrt", this::getGrbitFrt,
  89. "associatedRange", this::getAssociatedRange
  90. );
  91. }
  92. }