class AbstractConfig implements Config {

  @Override
  public void setAttribute(String name, String value, ConfigSource source) {
    Object attObjectValue;
    Class valueType = getAttributeType(name);
    try {
      if (valueType.equals(String.class)) {
        attObjectValue = value;
      } else if (valueType.equals(String[].class)) {
        // this would avoid converting empty string value to an array of size 1.
        if (StringUtils.isBlank(value)) {
          attObjectValue = new String[0];
        } else {
          attObjectValue = value.split(",");
        }
      } else if (valueType.equals(Integer.class)) {
        attObjectValue = Integer.valueOf(value);
      } else if (valueType.equals(Long.class)) {
        attObjectValue = Long.valueOf(value);
      } else if (valueType.equals(Boolean.class)) {
        attObjectValue = Boolean.valueOf(value);
      } else if (valueType.equals(File.class)) {
        attObjectValue = new File(value);
      } else if (valueType.equals(int[].class)) {
        int minus = value.indexOf('-');
        if (minus <= 0) {
          throw new IllegalArgumentException(
              "expected a setting in the form X-Y but found no dash for attribute " + name);
        }
        int[] tempValue = new int[2];
        tempValue[0] = Integer.valueOf(value.substring(0, minus));
        tempValue[1] = Integer.valueOf(value.substring(minus + 1));
        attObjectValue = tempValue;
      } else if (valueType.equals(InetAddress.class)) {
        try {
          attObjectValue = InetAddress.getByName(value);
        } catch (UnknownHostException ex) {
          throw new IllegalArgumentException(
              String.format("%s value %s must be a valid host name. %s",
                  name, value, ex.toString()));
        }
      } else if (valueType.equals(FlowControlParams.class)) {
        String[] values = value.split(",");
        if (values.length != 3) {
          throw new IllegalArgumentException(
              String.format("%s value %s must have three elements separated by commas",
                  name, value));
        }
        int allowance;
        float threshold;
        int waitTime;
        try {
          allowance = Integer.parseInt(values[0].trim());
          threshold = Float.valueOf(values[1].trim());
          waitTime = Integer.parseInt(values[2].trim());
        } catch (NumberFormatException e) {
          throw new IllegalArgumentException(
              String.format("%s value %s must be composed of an integer, a float, and an integer",
                  name, value));
        }
        attObjectValue = new FlowControlParams(allowance, threshold, waitTime);
      } else if (valueType.isArray()
          && SecurableCommunicationChannel.class.equals(valueType.getComponentType())) {
        attObjectValue = commaDelimitedStringToSecurableCommunicationChannels(value);
      } else {
        throw new InternalGemFireException(
            String.format("unhandled attribute type %s for %s.",
                valueType, name));
      }
    } catch (NumberFormatException ex) {
      throw new IllegalArgumentException(String.format("%s value %s must be a number.",
          name, value));
    }

    setAttributeObject(name, attObjectValue, source);
  }

}