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.

ConfigProvider.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.config.provider;
  18. import com.dmdirc.util.io.InvalidConfigFileException;
  19. import java.io.IOException;
  20. import java.util.List;
  21. import java.util.Set;
  22. /**
  23. * Provides methods to read and write from a single configuration source, such as a file on disk.
  24. */
  25. public interface ConfigProvider extends ReadOnlyConfigProvider {
  26. /**
  27. * Adds a new config change listener for this identity.
  28. *
  29. * @param listener The listener to be added
  30. */
  31. void addListener(ConfigChangeListener listener);
  32. /**
  33. * Deletes this identity from disk.
  34. *
  35. * @throws IOException if the file fails to delete
  36. */
  37. void delete() throws IOException;
  38. /**
  39. * Returns the set of domains available in this identity.
  40. *
  41. * @since 0.6
  42. * @return The set of domains used by this identity
  43. */
  44. Set<String> getDomains();
  45. /**
  46. * Returns the name of this identity.
  47. *
  48. * @return The name of this identity
  49. */
  50. String getName();
  51. /**
  52. * Attempts to reload this identity from disk. If this identity has been modified (i.e.,
  53. * {@code needSave} is true), then this method silently returns straight away. All relevant
  54. * ConfigChangeListeners are fired for new, altered and deleted properties. The target of the
  55. * identity will not be changed by this method, even if it has changed on disk.
  56. *
  57. * @throws java.io.IOException On I/O exception when reading the identity
  58. * @throws InvalidConfigFileException if the config file is no longer valid
  59. */
  60. void reload() throws IOException, InvalidConfigFileException;
  61. /**
  62. * Removes the specific config change listener from this identity.
  63. *
  64. * @param listener The listener to be removed
  65. */
  66. void removeListener(ConfigChangeListener listener);
  67. /**
  68. * Saves this identity to disk if it has been updated.
  69. */
  70. void save();
  71. /**
  72. * Sets the specified option in this identity to the specified value.
  73. *
  74. * @param domain The domain of the option
  75. * @param option The name of the option
  76. * @param value The new value for the option
  77. */
  78. void setOption(String domain, String option, String value);
  79. /**
  80. * Sets the specified option in this identity to the specified value.
  81. *
  82. * @param domain The domain of the option
  83. * @param option The name of the option
  84. * @param value The new value for the option
  85. */
  86. void setOption(String domain, String option, int value);
  87. /**
  88. * Sets the specified option in this identity to the specified value.
  89. *
  90. * @param domain The domain of the option
  91. * @param option The name of the option
  92. * @param value The new value for the option
  93. */
  94. void setOption(String domain, String option, boolean value);
  95. /**
  96. * Sets the specified option in this identity to the specified value.
  97. *
  98. * @param domain The domain of the option
  99. * @param option The name of the option
  100. * @param value The new value for the option
  101. */
  102. void setOption(String domain, String option, List<String> value);
  103. /**
  104. * Unsets a specified option.
  105. *
  106. * @param domain domain of the option
  107. * @param option name of the option
  108. */
  109. void unsetOption(String domain, String option);
  110. }