/de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/difftool/data/archive/ArchiveManager.java

http://jwpl.googlecode.com/ · Java · 95 lines · 33 code · 13 blank · 49 comment · 1 complexity · 86f3dcb54903b10d08129fc3b5cd680e MD5 · raw file

  1. /*******************************************************************************
  2. * Copyright (c) 2011 Ubiquitous Knowledge Processing Lab
  3. *
  4. * All rights reserved. This program and the accompanying materials
  5. * are made available under the terms of the GNU Lesser Public License v3
  6. * which accompanies this distribution, and is available at
  7. * http://www.gnu.org/licenses/lgpl.html
  8. *
  9. * Project Website:
  10. * http://jwpl.googlecode.com
  11. *
  12. * Contributors:
  13. * Torsten Zesch
  14. * Simon Kulessa
  15. * Oliver Ferschke
  16. ******************************************************************************/
  17. package de.tudarmstadt.ukp.wikipedia.revisionmachine.difftool.data.archive;
  18. import java.util.List;
  19. import de.tudarmstadt.ukp.wikipedia.revisionmachine.common.exceptions.ConfigurationException;
  20. import de.tudarmstadt.ukp.wikipedia.revisionmachine.difftool.config.ConfigurationManager;
  21. /**
  22. * DiffManager Manages the data contained by the ArchiveProducer
  23. *
  24. * @author Simon Kulessa
  25. * @version 0.5.0
  26. */
  27. public class ArchiveManager
  28. {
  29. /** List of available archives */
  30. private List<ArchiveDescription> archives;
  31. /**
  32. * (Constructor) Creates the ArchiveManager.
  33. *
  34. * @throws ConfigurationException
  35. * if an error occurs while accessing the configuration
  36. */
  37. public ArchiveManager()
  38. throws ConfigurationException
  39. {
  40. ConfigurationManager config = ConfigurationManager.getInstance();
  41. this.archives = config.getArchiveList();
  42. }
  43. /**
  44. * Returns whether an archive is available or not.
  45. *
  46. * @return TRUE | FALSE
  47. */
  48. public boolean hasArchive()
  49. {
  50. return !this.archives.isEmpty();
  51. }
  52. /**
  53. * Returns an archive.
  54. *
  55. * @return ArchiveDescription or NULL if no archive is available
  56. */
  57. public synchronized ArchiveDescription getArchive()
  58. {
  59. if (!this.archives.isEmpty()) {
  60. return this.archives.remove(0);
  61. }
  62. return null;
  63. }
  64. /**
  65. * Returns the number of remaining archives.
  66. *
  67. * @return number of available archives
  68. */
  69. public int size()
  70. {
  71. return this.archives.size();
  72. }
  73. /**
  74. * Returns the string representation of the ArchiveManager's content.
  75. *
  76. * @return [ number of archives ]
  77. */
  78. public String toString()
  79. {
  80. return "ArchiveManager:\t[" + this.size() + "]";
  81. }
  82. }