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.

StoredConfig.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2010, Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.lib;
  11. import java.io.IOException;
  12. import org.eclipse.jgit.errors.ConfigInvalidException;
  13. /**
  14. * Persistent configuration that can be stored and loaded from a location.
  15. */
  16. public abstract class StoredConfig extends Config {
  17. /**
  18. * Create a configuration with no default fallback.
  19. */
  20. public StoredConfig() {
  21. super();
  22. }
  23. /**
  24. * Create an empty configuration with a fallback for missing keys.
  25. *
  26. * @param defaultConfig
  27. * the base configuration to be consulted when a key is missing
  28. * from this configuration instance.
  29. */
  30. public StoredConfig(Config defaultConfig) {
  31. super(defaultConfig);
  32. }
  33. /**
  34. * Load the configuration from the persistent store.
  35. * <p>
  36. * If the configuration does not exist, this configuration is cleared, and
  37. * thus behaves the same as though the backing store exists, but is empty.
  38. *
  39. * @throws java.io.IOException
  40. * the configuration could not be read (but does exist).
  41. * @throws org.eclipse.jgit.errors.ConfigInvalidException
  42. * the configuration is not properly formatted.
  43. */
  44. public abstract void load() throws IOException, ConfigInvalidException;
  45. /**
  46. * Save the configuration to the persistent store.
  47. *
  48. * @throws java.io.IOException
  49. * the configuration could not be written.
  50. */
  51. public abstract void save() throws IOException;
  52. /** {@inheritDoc} */
  53. @Override
  54. public void clear() {
  55. super.clear();
  56. }
  57. }