Home
Categories
Dictionary
Download
Project Details
Changes Log
Tutorials
FAQ
License

AbstractConfiguration2 class



The AbstractConfiguration2 class is a default implementation of the Configuration2 interface which stores the properties in a Map. This class is abstract but it has no abstract methods. The following protected methods can be used to define the supported properties:

Example

Basic example

  public class ConcreteConfiguration extends AbstractConfiguration2 {
    private static ConcreteConfiguration conf = null;

    protected ConcreteConfiguration2Impl() {
      addProperty("propBool", Boolean.TYPE, false);
      addProperty("propInt", Integer.class, 1);
      addProperty("propFile", File.class, null);
    }
      
    public static ConcreteConfiguration getInstance() {
      if (conf == null) {
        conf = new ConcreteConfiguration();      
    }      
      return conf;
    } 
  }

Example with custom property setters

  public class ConcreteConfiguration extends AbstractConfiguration2 {
    private static ConcreteConfiguration conf = null;

    protected ConcreteConfiguration2Impl() {
      addProperty("propBool", Boolean.TYPE, false);
      addProperty("propInt", Integer.class, 1);
      addProperty("propList", List.class, null, true);
    }
      
    protected void setCustomPropertyValue(String key, Object value) {
      if (key.equals("propList")) {
        propertiesValues.get("propList").setValue(value);
      }
    }

    protected Object getCustomPropertyValue(String key) {
      if (key.equals("propList")) {
        return propertiesValues.get("propList").getValue();
      } else {
        return null;
      }
    }      
      
    public static ConcreteConfiguration getInstance() {
      if (conf == null) {
        conf = new ConcreteConfiguration();      
      }      
      return conf;
    } 
  }

See also


Categories: conf | javafx | swing

Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences