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.

PrecisionRecord.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 org.apache.poi.util.LittleEndianOutput;
  17. /**
  18. * Title: Precision Record<P>
  19. * Description: defines whether to store with full precision or what's displayed by the gui
  20. * (meaning have really screwed up and skewed figures or only think you do!)<P>
  21. * REFERENCE: PG 372 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
  22. * @author Andrew C. Oliver (acoliver at apache dot org)
  23. * @version 2.0-pre
  24. */
  25. public final class PrecisionRecord
  26. extends StandardRecord
  27. {
  28. public final static short sid = 0xE;
  29. public short field_1_precision;
  30. public PrecisionRecord()
  31. {
  32. }
  33. public PrecisionRecord(RecordInputStream in)
  34. {
  35. field_1_precision = in.readShort();
  36. }
  37. /**
  38. * set whether to use full precision or just skew all you figures all to hell.
  39. *
  40. * @param fullprecision - or not
  41. */
  42. public void setFullPrecision(boolean fullprecision)
  43. {
  44. if (fullprecision == true)
  45. {
  46. field_1_precision = 1;
  47. }
  48. else
  49. {
  50. field_1_precision = 0;
  51. }
  52. }
  53. /**
  54. * get whether to use full precision or just skew all you figures all to hell.
  55. *
  56. * @return fullprecision - or not
  57. */
  58. public boolean getFullPrecision()
  59. {
  60. return (field_1_precision == 1);
  61. }
  62. public String toString()
  63. {
  64. StringBuffer buffer = new StringBuffer();
  65. buffer.append("[PRECISION]\n");
  66. buffer.append(" .precision = ").append(getFullPrecision())
  67. .append("\n");
  68. buffer.append("[/PRECISION]\n");
  69. return buffer.toString();
  70. }
  71. public void serialize(LittleEndianOutput out) {
  72. out.writeShort(field_1_precision);
  73. }
  74. protected int getDataSize() {
  75. return 2;
  76. }
  77. public short getSid()
  78. {
  79. return sid;
  80. }
  81. }