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.

MemFuncPtg.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.ss.formula.ptg;
  16. import java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.util.GenericRecordUtil;
  19. import org.apache.poi.util.LittleEndianInput;
  20. import org.apache.poi.util.LittleEndianOutput;
  21. public final class MemFuncPtg extends OperandPtg {
  22. public static final byte sid = 0x29;
  23. private final int field_1_len_ref_subexpression;
  24. /**
  25. * Creates new function pointer from a byte array usually called while
  26. * reading an excel file.
  27. */
  28. public MemFuncPtg(LittleEndianInput in) {
  29. this(in.readUShort());
  30. }
  31. public MemFuncPtg(int subExprLen) {
  32. field_1_len_ref_subexpression = subExprLen;
  33. }
  34. @Override
  35. public byte getSid() {
  36. return sid;
  37. }
  38. public int getSize() {
  39. return 3;
  40. }
  41. public void write(LittleEndianOutput out) {
  42. out.writeByte(sid + getPtgClass());
  43. out.writeShort(field_1_len_ref_subexpression);
  44. }
  45. public String toFormulaString() {
  46. return "";
  47. }
  48. public byte getDefaultOperandClass() {
  49. return Ptg.CLASS_REF;
  50. }
  51. public int getNumberOfOperands() {
  52. return field_1_len_ref_subexpression;
  53. }
  54. public int getLenRefSubexpression() {
  55. return field_1_len_ref_subexpression;
  56. }
  57. @Override
  58. public MemFuncPtg copy() {
  59. // immutable
  60. return this;
  61. }
  62. @Override
  63. public Map<String, Supplier<?>> getGenericProperties() {
  64. return GenericRecordUtil.getGenericProperties("lenRefSubexpression", this::getLenRefSubexpression);
  65. }
  66. }