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.

DirectoryEntry.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.filesystem;
  16. import java.io.FileNotFoundException;
  17. import java.io.IOException;
  18. import java.io.InputStream;
  19. import java.util.Iterator;
  20. import java.util.Set;
  21. import org.apache.poi.hpsf.ClassID;
  22. /**
  23. * This interface defines methods specific to Directory objects
  24. * managed by a Filesystem instance.
  25. */
  26. public interface DirectoryEntry extends Entry, Iterable<Entry> {
  27. /**
  28. * get an iterator of the Entry instances contained directly in
  29. * this instance (in other words, children only; no grandchildren
  30. * etc.)
  31. *
  32. * @return iterator; never null, but hasNext() may return false
  33. * immediately (i.e., this DirectoryEntry is empty). All
  34. * objects retrieved by next() are guaranteed to be
  35. * implementations of Entry.
  36. */
  37. Iterator<Entry> getEntries();
  38. /**
  39. * get the names of all the Entries contained directly in this
  40. * instance (in other words, names of children only; no grandchildren
  41. * etc).
  42. *
  43. * @return the names of all the entries that may be retrieved with
  44. * getEntry(String), which may be empty (if this
  45. * DirectoryEntry is empty)
  46. */
  47. Set<String> getEntryNames();
  48. /**
  49. * is this DirectoryEntry empty?
  50. *
  51. * @return true if this instance contains no Entry instances
  52. */
  53. boolean isEmpty();
  54. /**
  55. * find out how many Entry instances are contained directly within
  56. * this DirectoryEntry
  57. *
  58. * @return number of immediately (no grandchildren etc.) contained
  59. * Entry instances
  60. */
  61. int getEntryCount();
  62. /**
  63. * Checks if entry with specified name present
  64. */
  65. boolean hasEntry( final String name );
  66. /**
  67. * get a specified Entry by name
  68. *
  69. * @param name the name of the Entry to obtain.
  70. *
  71. * @return the specified Entry, if it is directly contained in
  72. * this DirectoryEntry
  73. *
  74. * @throws FileNotFoundException if no Entry with the specified
  75. * name exists in this DirectoryEntry
  76. */
  77. Entry getEntry(final String name) throws FileNotFoundException;
  78. /**
  79. * create a new DocumentEntry
  80. *
  81. * @param name the name of the new DocumentEntry
  82. * @param stream the InputStream from which to create the new
  83. * DocumentEntry
  84. *
  85. * @return the new DocumentEntry
  86. */
  87. DocumentEntry createDocument(final String name, final InputStream stream)
  88. throws IOException;
  89. /**
  90. * create a new DocumentEntry; the data will be provided later
  91. *
  92. * @param name the name of the new DocumentEntry
  93. * @param size the size of the new DocumentEntry
  94. * @param writer the writer of the new DocumentEntry
  95. *
  96. * @return the new DocumentEntry
  97. */
  98. DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer)
  99. throws IOException;
  100. /**
  101. * create a new DirectoryEntry
  102. *
  103. * @param name the name of the new DirectoryEntry
  104. *
  105. * @return the new DirectoryEntry
  106. */
  107. DirectoryEntry createDirectory(final String name) throws IOException;
  108. /**
  109. * Gets the storage clsid of the directory entry
  110. *
  111. * @return storage Class ID
  112. */
  113. ClassID getStorageClsid();
  114. /**
  115. * Sets the storage clsid for the directory entry
  116. *
  117. * @param clsidStorage storage Class ID
  118. */
  119. void setStorageClsid(ClassID clsidStorage);
  120. }