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.4KB

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