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.

FilesystemContainer.java 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.itmill.toolkit.data.util;
  5. import java.io.File;
  6. import java.io.FilenameFilter;
  7. import java.io.IOException;
  8. import java.lang.reflect.Method;
  9. import java.util.ArrayList;
  10. import java.util.Arrays;
  11. import java.util.Collection;
  12. import java.util.Collections;
  13. import java.util.Date;
  14. import java.util.Iterator;
  15. import java.util.LinkedList;
  16. import java.util.List;
  17. import com.itmill.toolkit.data.Container;
  18. import com.itmill.toolkit.data.Item;
  19. import com.itmill.toolkit.data.Property;
  20. import com.itmill.toolkit.service.FileTypeResolver;
  21. import com.itmill.toolkit.terminal.Resource;
  22. /**
  23. * A hierarchical container wrapper for a filesystem.
  24. *
  25. * @author IT Mill Ltd.
  26. * @version
  27. * @VERSION@
  28. * @since 3.0
  29. */
  30. public class FilesystemContainer implements Container.Hierarchical {
  31. /**
  32. * String identifier of a file's "name" property.
  33. */
  34. public static String PROPERTY_NAME = "Name";
  35. /**
  36. * String identifier of a file's "size" property.
  37. */
  38. public static String PROPERTY_SIZE = "Size";
  39. /**
  40. * String identifier of a file's "icon" property.
  41. */
  42. public static String PROPERTY_ICON = "Icon";
  43. /**
  44. * String identifier of a file's "last modified" property.
  45. */
  46. public static String PROPERTY_LASTMODIFIED = "Last Modified";
  47. /**
  48. * List of the string identifiers for the available properties.
  49. */
  50. public static Collection FILE_PROPERTIES;
  51. private static Method FILEITEM_LASTMODIFIED;
  52. private static Method FILEITEM_NAME;
  53. private static Method FILEITEM_ICON;
  54. private static Method FILEITEM_SIZE;
  55. static {
  56. FILE_PROPERTIES = new ArrayList();
  57. FILE_PROPERTIES.add(PROPERTY_NAME);
  58. FILE_PROPERTIES.add(PROPERTY_ICON);
  59. FILE_PROPERTIES.add(PROPERTY_SIZE);
  60. FILE_PROPERTIES.add(PROPERTY_LASTMODIFIED);
  61. FILE_PROPERTIES = Collections.unmodifiableCollection(FILE_PROPERTIES);
  62. try {
  63. FILEITEM_LASTMODIFIED = FileItem.class.getMethod("lastModified",
  64. new Class[] {});
  65. FILEITEM_NAME = FileItem.class.getMethod("getName", new Class[] {});
  66. FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {});
  67. FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {});
  68. } catch (final NoSuchMethodException e) {
  69. }
  70. }
  71. private File[] roots = new File[] {};
  72. private FilenameFilter filter = null;
  73. private boolean recursive = true;
  74. /**
  75. * Constructs a new <code>FileSystemContainer</code> with the specified
  76. * file as the root of the filesystem. The files are included recursively.
  77. *
  78. * @param root
  79. * the root file for the new file-system container. Null
  80. * values are ignored.
  81. */
  82. public FilesystemContainer(File root) {
  83. if (root != null) {
  84. roots = new File[] { root };
  85. }
  86. }
  87. /**
  88. * Constructs a new <code>FileSystemContainer</code> with the specified
  89. * file as the root of the filesystem. The files are included recursively.
  90. *
  91. * @param root
  92. * the root file for the new file-system container.
  93. * @param recursive
  94. * should the container recursively contain subdirectories.
  95. */
  96. public FilesystemContainer(File root, boolean recursive) {
  97. this(root);
  98. setRecursive(recursive);
  99. }
  100. /**
  101. * Constructs a new <code>FileSystemContainer</code> with the specified
  102. * file as the root of the filesystem.
  103. *
  104. * @param root
  105. * the root file for the new file-system container.
  106. * @param extension
  107. * the Filename extension (w/o separator) to limit the files
  108. * in container.
  109. * @param recursive
  110. * should the container recursively contain subdirectories.
  111. */
  112. public FilesystemContainer(File root, String extension, boolean recursive) {
  113. this(root);
  114. this.setFilter(extension);
  115. setRecursive(recursive);
  116. }
  117. /**
  118. * Constructs a new <code>FileSystemContainer</code> with the specified
  119. * root and recursivity status.
  120. *
  121. * @param root
  122. * the root file for the new file-system container.
  123. * @param filter
  124. * the Filename filter to limit the files in container.
  125. * @param recursive
  126. * should the container recursively contain subdirectories.
  127. */
  128. public FilesystemContainer(File root, FilenameFilter filter,
  129. boolean recursive) {
  130. this(root);
  131. this.setFilter(filter);
  132. setRecursive(recursive);
  133. }
  134. /**
  135. * Adds new root file directory. Adds a file to be included as root file
  136. * directory in the <code>FilesystemContainer</code>.
  137. *
  138. * @param root
  139. * the File to be added as root directory. Null values are
  140. * ignored.
  141. */
  142. public void addRoot(File root) {
  143. if (root != null) {
  144. final File[] newRoots = new File[roots.length + 1];
  145. for (int i = 0; i < roots.length; i++) {
  146. newRoots[i] = roots[i];
  147. }
  148. newRoots[roots.length] = root;
  149. roots = newRoots;
  150. }
  151. }
  152. /**
  153. * Tests if the specified Item in the container may have children. Since a
  154. * <code>FileSystemContainer</code> contains files and directories, this
  155. * method returns <code>true</code> for directory Items only.
  156. *
  157. * @param itemId
  158. * the id of the item.
  159. * @return <code>true</code> if the specified Item is a directory,
  160. * <code>false</code> otherwise.
  161. */
  162. public boolean areChildrenAllowed(Object itemId) {
  163. return itemId instanceof File && ((File) itemId).canRead()
  164. && ((File) itemId).isDirectory();
  165. }
  166. /*
  167. * Gets the ID's of all Items who are children of the specified Item. Don't
  168. * add a JavaDoc comment here, we use the default documentation from
  169. * implemented interface.
  170. */
  171. public Collection getChildren(Object itemId) {
  172. if (!(itemId instanceof File)) {
  173. return Collections.unmodifiableCollection(new LinkedList());
  174. }
  175. File[] f;
  176. if (filter != null) {
  177. f = ((File) itemId).listFiles(filter);
  178. } else {
  179. f = ((File) itemId).listFiles();
  180. }
  181. if (f == null) {
  182. return Collections.unmodifiableCollection(new LinkedList());
  183. }
  184. final List l = Arrays.asList(f);
  185. Collections.sort(l);
  186. return Collections.unmodifiableCollection(l);
  187. }
  188. /*
  189. * Gets the parent item of the specified Item. Don't add a JavaDoc comment
  190. * here, we use the default documentation from implemented interface.
  191. */
  192. public Object getParent(Object itemId) {
  193. if (!(itemId instanceof File)) {
  194. return null;
  195. }
  196. return ((File) itemId).getParentFile();
  197. }
  198. /*
  199. * Tests if the specified Item has any children. Don't add a JavaDoc comment
  200. * here, we use the default documentation from implemented interface.
  201. */
  202. public boolean hasChildren(Object itemId) {
  203. if (!(itemId instanceof File)) {
  204. return false;
  205. }
  206. String[] l;
  207. if (filter != null) {
  208. l = ((File) itemId).list(filter);
  209. } else {
  210. l = ((File) itemId).list();
  211. }
  212. return (l != null) && (l.length > 0);
  213. }
  214. /*
  215. * Tests if the specified Item is the root of the filesystem. Don't add a
  216. * JavaDoc comment here, we use the default documentation from implemented
  217. * interface.
  218. */
  219. public boolean isRoot(Object itemId) {
  220. if (!(itemId instanceof File)) {
  221. return false;
  222. }
  223. for (int i = 0; i < roots.length; i++) {
  224. if (roots[i].equals(itemId)) {
  225. return true;
  226. }
  227. }
  228. return false;
  229. }
  230. /*
  231. * Gets the ID's of all root Items in the container. Don't add a JavaDoc
  232. * comment here, we use the default documentation from implemented
  233. * interface.
  234. */
  235. public Collection rootItemIds() {
  236. File[] f;
  237. // in single root case we use children
  238. if (roots.length == 1) {
  239. if (filter != null) {
  240. f = roots[0].listFiles(filter);
  241. } else {
  242. f = roots[0].listFiles();
  243. }
  244. } else {
  245. f = roots;
  246. }
  247. if (f == null) {
  248. return Collections.unmodifiableCollection(new LinkedList());
  249. }
  250. final List l = Arrays.asList(f);
  251. Collections.sort(l);
  252. return Collections.unmodifiableCollection(l);
  253. }
  254. /**
  255. * Returns <code>false</code> when conversion from files to directories is
  256. * not supported.
  257. *
  258. * @param itemId
  259. * the ID of the item.
  260. * @param areChildrenAllowed
  261. * the boolean value specifying if the Item can have children
  262. * or not.
  263. * @return <code>true</code> if the operaton is successful otherwise
  264. * <code>false</code>.
  265. * @throws UnsupportedOperationException
  266. * if the setChildrenAllowed is not supported.
  267. */
  268. public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
  269. throws UnsupportedOperationException {
  270. throw new UnsupportedOperationException(
  271. "Conversion file to/from directory is not supported");
  272. }
  273. /**
  274. * Returns <code>false</code> when moving files around in the filesystem
  275. * is not supported.
  276. *
  277. * @param itemId
  278. * the ID of the item.
  279. * @param newParentId
  280. * the ID of the Item that's to be the new parent of the Item
  281. * identified with itemId.
  282. * @return <code>true</code> if the operation is successful otherwise
  283. * <code>false</code>.
  284. * @throws UnsupportedOperationException
  285. * if the setParent is not supported.
  286. */
  287. public boolean setParent(Object itemId, Object newParentId)
  288. throws UnsupportedOperationException {
  289. throw new UnsupportedOperationException("File moving is not supported");
  290. }
  291. /*
  292. * Tests if the filesystem contains the specified Item. Don't add a JavaDoc
  293. * comment here, we use the default documentation from implemented
  294. * interface.
  295. */
  296. public boolean containsId(Object itemId) {
  297. if (!(itemId instanceof File)) {
  298. return false;
  299. }
  300. boolean val = false;
  301. // Try to match all roots
  302. for (int i = 0; i < roots.length; i++) {
  303. try {
  304. val |= ((File) itemId).getCanonicalPath().startsWith(
  305. roots[i].getCanonicalPath());
  306. } catch (final IOException e) {
  307. // Exception ignored
  308. }
  309. }
  310. if (val && filter != null) {
  311. val &= filter.accept(((File) itemId).getParentFile(),
  312. ((File) itemId).getName());
  313. }
  314. return val;
  315. }
  316. /*
  317. * Gets the specified Item from the filesystem. Don't add a JavaDoc comment
  318. * here, we use the default documentation from implemented interface.
  319. */
  320. public Item getItem(Object itemId) {
  321. if (!(itemId instanceof File)) {
  322. return null;
  323. }
  324. return new FileItem((File) itemId);
  325. }
  326. /**
  327. * Internal recursive method to add the files under the specified directory
  328. * to the collection.
  329. *
  330. * @param col
  331. * the collection where the found items are added
  332. * @param f
  333. * the root file where to start adding files
  334. */
  335. private void addItemIds(Collection col, File f) {
  336. File[] l;
  337. if (filter != null) {
  338. l = f.listFiles(filter);
  339. } else {
  340. l = f.listFiles();
  341. }
  342. final List ll = Arrays.asList(l);
  343. Collections.sort(ll);
  344. for (final Iterator i = ll.iterator(); i.hasNext();) {
  345. final File lf = (File) i.next();
  346. if (lf.isDirectory()) {
  347. addItemIds(col, lf);
  348. } else {
  349. col.add(lf);
  350. }
  351. }
  352. }
  353. /*
  354. * Gets the IDs of Items in the filesystem. Don't add a JavaDoc comment
  355. * here, we use the default documentation from implemented interface.
  356. */
  357. public Collection getItemIds() {
  358. if (recursive) {
  359. final Collection col = new ArrayList();
  360. for (int i = 0; i < roots.length; i++) {
  361. addItemIds(col, roots[i]);
  362. }
  363. return Collections.unmodifiableCollection(col);
  364. } else {
  365. File[] f;
  366. if (roots.length == 1) {
  367. if (filter != null) {
  368. f = roots[0].listFiles(filter);
  369. } else {
  370. f = roots[0].listFiles();
  371. }
  372. } else {
  373. f = roots;
  374. }
  375. if (f == null) {
  376. return Collections.unmodifiableCollection(new LinkedList());
  377. }
  378. final List l = Arrays.asList(f);
  379. Collections.sort(l);
  380. return Collections.unmodifiableCollection(l);
  381. }
  382. }
  383. /**
  384. * Gets the specified property of the specified file Item. The available
  385. * file properties are "Name", "Size" and "Last Modified". If propertyId is
  386. * not one of those, <code>null</code> is returned.
  387. *
  388. * @param itemId
  389. * the ID of the file whose property is requested.
  390. * @param propertyId
  391. * the property's ID.
  392. * @return the requested property's value, or <code>null</code>
  393. */
  394. public Property getContainerProperty(Object itemId, Object propertyId) {
  395. if (!(itemId instanceof File)) {
  396. return null;
  397. }
  398. if (propertyId.equals(PROPERTY_NAME)) {
  399. return new MethodProperty(getType(propertyId), new FileItem(
  400. (File) itemId), FILEITEM_NAME, null);
  401. }
  402. if (propertyId.equals(PROPERTY_ICON)) {
  403. return new MethodProperty(getType(propertyId), new FileItem(
  404. (File) itemId), FILEITEM_ICON, null);
  405. }
  406. if (propertyId.equals(PROPERTY_SIZE)) {
  407. return new MethodProperty(getType(propertyId), new FileItem(
  408. (File) itemId), FILEITEM_SIZE, null);
  409. }
  410. if (propertyId.equals(PROPERTY_LASTMODIFIED)) {
  411. return new MethodProperty(getType(propertyId), new FileItem(
  412. (File) itemId), FILEITEM_LASTMODIFIED, null);
  413. }
  414. return null;
  415. }
  416. /**
  417. * Gets the collection of available file properties.
  418. *
  419. * @return Unmodifiable collection containing all available file properties.
  420. */
  421. public Collection getContainerPropertyIds() {
  422. return FILE_PROPERTIES;
  423. }
  424. /**
  425. * Gets the specified property's data type. "Name" is a <code>String</code>,
  426. * "Size" is a <code>Long</code>, "Last Modified" is a <code>Date</code>.
  427. * If propertyId is not one of those, <code>null</code> is returned.
  428. *
  429. * @param propertyId
  430. * the ID of the property whose type is requested.
  431. * @return data type of the requested property, or <code>null</code>
  432. */
  433. public Class getType(Object propertyId) {
  434. if (propertyId.equals(PROPERTY_NAME)) {
  435. return String.class;
  436. }
  437. if (propertyId.equals(PROPERTY_ICON)) {
  438. return Resource.class;
  439. }
  440. if (propertyId.equals(PROPERTY_SIZE)) {
  441. return Long.class;
  442. }
  443. if (propertyId.equals(PROPERTY_LASTMODIFIED)) {
  444. return Date.class;
  445. }
  446. return null;
  447. }
  448. /**
  449. * Internal method to recursively calculate the number of files under a root
  450. * directory.
  451. *
  452. * @param f
  453. * the root to start counting from.
  454. */
  455. private int getFileCounts(File f) {
  456. File[] l;
  457. if (filter != null) {
  458. l = f.listFiles(filter);
  459. } else {
  460. l = f.listFiles();
  461. }
  462. if (l == null) {
  463. return 0;
  464. }
  465. int ret = l.length;
  466. for (int i = 0; i < l.length; i++) {
  467. if (l[i].isDirectory()) {
  468. ret += getFileCounts(l[i]);
  469. }
  470. }
  471. return ret;
  472. }
  473. /**
  474. * Gets the number of Items in the container. In effect, this is the
  475. * combined amount of files and directories.
  476. *
  477. * @return Number of Items in the container.
  478. */
  479. public int size() {
  480. if (recursive) {
  481. int counts = 0;
  482. for (int i = 0; i < roots.length; i++) {
  483. counts += getFileCounts(roots[i]);
  484. }
  485. return counts;
  486. } else {
  487. File[] f;
  488. if (roots.length == 1) {
  489. if (filter != null) {
  490. f = roots[0].listFiles(filter);
  491. } else {
  492. f = roots[0].listFiles();
  493. }
  494. } else {
  495. f = roots;
  496. }
  497. if (f == null) {
  498. return 0;
  499. }
  500. return f.length;
  501. }
  502. }
  503. /**
  504. * A Item wrapper for files in a filesystem.
  505. *
  506. * @author IT Mill Ltd.
  507. * @version
  508. * @VERSION@
  509. * @since 3.0
  510. */
  511. public class FileItem implements Item {
  512. /**
  513. * The wrapped file.
  514. */
  515. private final File file;
  516. /**
  517. * Constructs a FileItem from a existing file.
  518. */
  519. private FileItem(File file) {
  520. this.file = file;
  521. }
  522. /*
  523. * Gets the specified property of this file. Don't add a JavaDoc comment
  524. * here, we use the default documentation from implemented interface.
  525. */
  526. public Property getItemProperty(Object id) {
  527. return getContainerProperty(file, id);
  528. }
  529. /*
  530. * Gets the IDs of all properties available for this item Don't add a
  531. * JavaDoc comment here, we use the default documentation from
  532. * implemented interface.
  533. */
  534. public Collection getItemPropertyIds() {
  535. return getContainerPropertyIds();
  536. }
  537. /**
  538. * Calculates a integer hash-code for the Property that's unique inside
  539. * the Item containing the Property. Two different Properties inside the
  540. * same Item contained in the same list always have different
  541. * hash-codes, though Properties in different Items may have identical
  542. * hash-codes.
  543. *
  544. * @return A locally unique hash-code as integer
  545. */
  546. public int hashCode() {
  547. return file.hashCode() ^ FilesystemContainer.this.hashCode();
  548. }
  549. /**
  550. * Tests if the given object is the same as the this object. Two
  551. * Properties got from an Item with the same ID are equal.
  552. *
  553. * @param obj
  554. * an object to compare with this object.
  555. * @return <code>true</code> if the given object is the same as this
  556. * object, <code>false</code> if not
  557. */
  558. public boolean equals(Object obj) {
  559. if (obj == null || !(obj instanceof FileItem)) {
  560. return false;
  561. }
  562. final FileItem fi = (FileItem) obj;
  563. return fi.getHost() == getHost() && fi.file.equals(file);
  564. }
  565. /**
  566. * Gets the host of this file.
  567. */
  568. private FilesystemContainer getHost() {
  569. return FilesystemContainer.this;
  570. }
  571. /**
  572. * Gets the last modified date of this file.
  573. *
  574. * @return Date
  575. */
  576. public Date lastModified() {
  577. return new Date(file.lastModified());
  578. }
  579. /**
  580. * Gets the name of this file.
  581. *
  582. * @return file name of this file.
  583. */
  584. public String getName() {
  585. return file.getName();
  586. }
  587. /**
  588. * Gets the icon of this file.
  589. *
  590. * @return the icon of this file.
  591. */
  592. public Resource getIcon() {
  593. return FileTypeResolver.getIcon(file);
  594. }
  595. /**
  596. * Gets the size of this file.
  597. *
  598. * @return size
  599. */
  600. public long getSize() {
  601. if (file.isDirectory()) {
  602. return 0;
  603. }
  604. return file.length();
  605. }
  606. /**
  607. * @see java.lang.Object#toString()
  608. */
  609. public String toString() {
  610. if ("".equals(file.getName())) {
  611. return file.getAbsolutePath();
  612. }
  613. return file.getName();
  614. }
  615. /**
  616. * Filesystem container does not support adding new properties.
  617. *
  618. * @see com.itmill.toolkit.data.Item#addItemProperty(Object, Property)
  619. */
  620. public boolean addItemProperty(Object id, Property property)
  621. throws UnsupportedOperationException {
  622. throw new UnsupportedOperationException("Filesystem container "
  623. + "does not support adding new properties");
  624. }
  625. /**
  626. * Filesystem container does not support removing properties.
  627. *
  628. * @see com.itmill.toolkit.data.Item#removeItemProperty(Object)
  629. */
  630. public boolean removeItemProperty(Object id)
  631. throws UnsupportedOperationException {
  632. throw new UnsupportedOperationException(
  633. "Filesystem container does not support property removal");
  634. }
  635. }
  636. /**
  637. * Generic file extension filter for displaying only files having certain
  638. * extension.
  639. *
  640. * @author IT Mill Ltd.
  641. * @version
  642. * @VERSION@
  643. * @since 3.0
  644. */
  645. public class FileExtensionFilter implements FilenameFilter {
  646. private final String filter;
  647. /**
  648. * Constructs a new FileExtensionFilter using given extension.
  649. *
  650. * @param fileExtension
  651. * the File extension without the separator (dot).
  652. */
  653. public FileExtensionFilter(String fileExtension) {
  654. filter = "." + fileExtension;
  655. }
  656. /**
  657. * Allows only files with the extension and directories.
  658. *
  659. * @see java.io.FilenameFilter#accept(File, String)
  660. */
  661. public boolean accept(File dir, String name) {
  662. if (name.endsWith(filter)) {
  663. return true;
  664. }
  665. return new File(dir, name).isDirectory();
  666. }
  667. }
  668. /**
  669. * Returns the file filter used to limit the files in this container.
  670. *
  671. * @return Used filter instance or null if no filter is assigned.
  672. */
  673. public FilenameFilter getFilter() {
  674. return filter;
  675. }
  676. /**
  677. * Sets the file filter used to limit the files in this container.
  678. *
  679. * @param filter
  680. * The filter to set. <code>null</code> disables filtering.
  681. */
  682. public void setFilter(FilenameFilter filter) {
  683. this.filter = filter;
  684. }
  685. /**
  686. * Sets the file filter used to limit the files in this container.
  687. *
  688. * @param extension
  689. * the Filename extension (w/o separator) to limit the files
  690. * in container.
  691. */
  692. public void setFilter(String extension) {
  693. filter = new FileExtensionFilter(extension);
  694. }
  695. /**
  696. * Is this container recursive filesystem.
  697. *
  698. * @return <code>true</code> if container is recursive, <code>false</code>
  699. * otherwise.
  700. */
  701. public boolean isRecursive() {
  702. return recursive;
  703. }
  704. /**
  705. * Sets the container recursive property. Set this to false to limit the
  706. * files directly under the root file.
  707. * <p>
  708. * Note : This is meaningful only if the root really is a directory.
  709. * </p>
  710. *
  711. * @param recursive
  712. * the New value for recursive property.
  713. */
  714. public void setRecursive(boolean recursive) {
  715. this.recursive = recursive;
  716. }
  717. /**
  718. * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
  719. * Class, Object)
  720. */
  721. public boolean addContainerProperty(Object propertyId, Class type,
  722. Object defaultValue) throws UnsupportedOperationException {
  723. throw new UnsupportedOperationException(
  724. "File system container does not support this operation");
  725. }
  726. /**
  727. * @see com.itmill.toolkit.data.Container#addItem()
  728. */
  729. public Object addItem() throws UnsupportedOperationException {
  730. throw new UnsupportedOperationException(
  731. "File system container does not support this operation");
  732. }
  733. /**
  734. * @see com.itmill.toolkit.data.Container#addItem(Object)
  735. */
  736. public Item addItem(Object itemId) throws UnsupportedOperationException {
  737. throw new UnsupportedOperationException(
  738. "File system container does not support this operation");
  739. }
  740. /**
  741. * @see com.itmill.toolkit.data.Container#removeAllItems()
  742. */
  743. public boolean removeAllItems() throws UnsupportedOperationException {
  744. throw new UnsupportedOperationException(
  745. "File system container does not support this operation");
  746. }
  747. /**
  748. * @see com.itmill.toolkit.data.Container#removeItem(Object)
  749. */
  750. public boolean removeItem(Object itemId)
  751. throws UnsupportedOperationException {
  752. throw new UnsupportedOperationException(
  753. "File system container does not support this operation");
  754. }
  755. /**
  756. * @see com.itmill.toolkit.data.Container#removeContainerProperty(Object)
  757. */
  758. public boolean removeContainerProperty(Object propertyId)
  759. throws UnsupportedOperationException {
  760. throw new UnsupportedOperationException(
  761. "File system container does not support this operation");
  762. }
  763. }