예제 #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));
  }
예제 #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;
  }
예제 #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);
    }
  }
예제 #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();
  }