Esempio n. 1
0
  protected Object getDefault(String path) {
    if (path == null) {
      throw new IllegalArgumentException("Path cannot be null");
    }

    Configuration defaults = root.getDefaults();
    return (defaults == null) ? null : defaults.get(createPath(this, path));
  }
Esempio n. 2
0
  public ConfigurationSection getDefaultSection() {
    if (getRoot() == null) {
      return null;
    }

    Configuration defaults = getRoot().getDefaults();

    if (defaults != null) {
      if (defaults.isConfigurationSection(getCurrentPath())) {
        return defaults.getConfigurationSection(getCurrentPath());
      }
    }

    return null;
  }
Esempio n. 3
0
  public void addDefault(String path, Object value) {
    if (path == null) {
      throw new IllegalArgumentException("Path cannot be null");
    }

    if (root == null) {
      throw new IllegalStateException("Cannot set default on orphaned section");
    } else {
      root.addDefault(createPath(this, path), value);
    }
  }
Esempio n. 4
0
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();

    builder.append(getClass().getSimpleName());
    builder.append("[path='");
    builder.append(getCurrentPath());
    builder.append("', root='");
    builder.append(root.getClass().getSimpleName());
    builder.append("']");

    return builder.toString();
  }