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.

VariantBool.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.hpsf;
  16. import org.apache.logging.log4j.LogManager;
  17. import org.apache.logging.log4j.Logger;
  18. import org.apache.poi.util.Internal;
  19. import org.apache.poi.util.LittleEndianByteArrayInputStream;
  20. import static org.apache.logging.log4j.util.Unbox.box;
  21. @Internal
  22. public class VariantBool {
  23. private static final Logger LOG = LogManager.getLogger(VariantBool.class);
  24. static final int SIZE = 2;
  25. private boolean _value;
  26. public void read( LittleEndianByteArrayInputStream lei ) {
  27. short value = lei.readShort();
  28. switch (value) {
  29. case 0:
  30. _value = false;
  31. break;
  32. case -1:
  33. _value = true;
  34. break;
  35. default:
  36. LOG.atWarn().log("VARIANT_BOOL value '{}' is incorrect", box(value));
  37. _value = true;
  38. break;
  39. }
  40. }
  41. public boolean getValue() {
  42. return _value;
  43. }
  44. public void setValue( boolean value ) {
  45. this._value = value;
  46. }
  47. }