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.

RootProperty.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.poifs.property;
  16. import org.apache.poi.poifs.common.POIFSConstants;
  17. /**
  18. * Root property
  19. */
  20. public final class RootProperty extends DirectoryProperty {
  21. private static final String NAME = "Root Entry";
  22. RootProperty()
  23. {
  24. super(NAME);
  25. // overrides
  26. setNodeColor(_NODE_BLACK);
  27. setPropertyType(PropertyConstants.ROOT_TYPE);
  28. setStartBlock(POIFSConstants.END_OF_CHAIN);
  29. }
  30. /**
  31. * reader constructor
  32. *
  33. * @param index index number
  34. * @param array byte data
  35. * @param offset offset into byte data
  36. */
  37. RootProperty(final int index, final byte [] array, final int offset) {
  38. super(index, array, offset);
  39. }
  40. /**
  41. * set size
  42. *
  43. * @param size size in terms of small blocks
  44. */
  45. public void setSize(int size)
  46. {
  47. final int BLOCK_SHIFT = 6;
  48. final int _block_size = 1 << BLOCK_SHIFT;
  49. super.setSize(Math.multiplyExact(size, _block_size));
  50. }
  51. /**
  52. * Returns the fixed name "Root Entry", as the
  53. * raw property doesn't have a real name set
  54. */
  55. @Override
  56. public String getName() {
  57. return NAME;
  58. }
  59. }