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.

DateWindow1904Record.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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;
  16. import java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.util.GenericRecordUtil;
  19. import org.apache.poi.util.LittleEndianOutput;
  20. /**
  21. * Flag specifying whether 1904 date windowing is used.
  22. *
  23. * @version 2.0-pre
  24. */
  25. public final class DateWindow1904Record extends StandardRecord {
  26. public static final short sid = 0x22;
  27. private short field_1_window;
  28. public DateWindow1904Record() {}
  29. public DateWindow1904Record(DateWindow1904Record other) {
  30. super(other);
  31. field_1_window = other.field_1_window;
  32. }
  33. public DateWindow1904Record(RecordInputStream in) {
  34. field_1_window = in.readShort();
  35. }
  36. /**
  37. * sets whether or not to use 1904 date windowing (which means you'll be screwed in 2004)
  38. * @param window flag - 0/1 (false,true)
  39. */
  40. public void setWindowing(short window)
  41. { // I hate using numbers in method names so I wont!
  42. field_1_window = window;
  43. }
  44. /**
  45. * gets whether or not to use 1904 date windowing (which means you'll be screwed in 2004)
  46. * @return window flag - 0/1 (false,true)
  47. */
  48. public short getWindowing()
  49. {
  50. return field_1_window;
  51. }
  52. public void serialize(LittleEndianOutput out) {
  53. out.writeShort(getWindowing());
  54. }
  55. protected int getDataSize() {
  56. return 2;
  57. }
  58. public short getSid()
  59. {
  60. return sid;
  61. }
  62. @Override
  63. public DateWindow1904Record copy() {
  64. return new DateWindow1904Record(this);
  65. }
  66. @Override
  67. public HSSFRecordTypes getGenericRecordType() {
  68. return HSSFRecordTypes.DATE_WINDOW_1904;
  69. }
  70. @Override
  71. public Map<String, Supplier<?>> getGenericProperties() {
  72. return GenericRecordUtil.getGenericProperties("is1904", this::getWindowing);
  73. }
  74. }