Package org.scf4j

Examples of org.scf4j.ConfigurationException


  public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
    logger.debug(Messages.getString("try.to.coerce.pstr.to.pcls"), value, to.getCanonicalName());
    TypeCoercer coercer = subs.get(to);
    if (coercer == null) {
      logger.error(Messages.getString("did.not.find.a.handler.for.class.pcls"), to.getCanonicalName());
      throw new ConfigurationException(Messages.getString("type.0.not.supported", to.getCanonicalName()));
    }
    logger.debug(Messages.getString("found.handler.pobj.for.class.pcls"), coercer, to.getCanonicalName());
    return coercer.coerce(value, to);
  }
View Full Code Here


    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      if (value.length() > 1) {
        value = value.trim();
      }
      if (value.length() > 1) {
        throw new ConfigurationException(Messages.getString("too.many.characters.0", value));
      }
      if (value.length() == 0) {
        throw new ConfigurationException(Messages.getString("empty.value"));
      }
      return (T)Character.valueOf(value.charAt(0));
    }
View Full Code Here

    @Override
    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      try {
        return (T)Integer.valueOf(value.trim());
      } catch (NumberFormatException nfe) {
        throw new ConfigurationException(Messages.getString("not.an.integer.value.0", value), nfe);
      }
    }
View Full Code Here

    @Override
    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      try {
        return (T)Long.valueOf(value.trim());
      } catch (NumberFormatException nfe) {
        throw new ConfigurationException(Messages.getString("not.a.long.value.0", value), nfe);
      }
    }
View Full Code Here

    @Override
    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      try {
        return (T)Short.valueOf(value.trim());
      } catch (NumberFormatException nfe) {
        throw new ConfigurationException(Messages.getString("not.a.short.value.0", value), nfe);
      }
    }
View Full Code Here

    @Override
    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      try {
        return (T)Byte.valueOf(value);
      } catch (NumberFormatException nfe) {
        throw new ConfigurationException(Messages.getString("not.a.byte.value.0", value), nfe);
      }
    }
View Full Code Here

    @Override
    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      try {
        return (T)Float.valueOf(value);
      } catch (NumberFormatException nfe) {
        throw new ConfigurationException(Messages.getString("not.a.float.value.0", value), nfe);
      }
    }
View Full Code Here

    @Override
    public <T> T coerce(String value, Class<T> to) throws ConfigurationException {
      try {
        return (T)Double.valueOf(value);
      } catch (NumberFormatException nfe) {
        throw new ConfigurationException(Messages.getString("not.a.float.value.01", value), nfe);
      }
    }
View Full Code Here

      Properties properties = new Properties();
      properties.load(in);
      return properties;
    } catch (Exception e) {
      logger.error(Messages.getString("could.not.load.the.configuration"), e);
      throw new ConfigurationException(Messages.getString("could.not.load.the.configuration"), e);
    } finally {
      if (in != null) {
        try { in.close(); } catch (IOException e) { /* ignore */}
      }
    }
 
View Full Code Here

    } else  if (value != null) {
      propertyMapping.put(method, getCoercer().coerce(value, method.getReturnType()));
    } else if (property.optional()) {
      propertyMapping.put(method, getCoercer().coerce(property.value(), method.getReturnType()));
    } else {
      throw new ConfigurationException(Messages.getString("required.property.0.is.missing", propertyPath));
    }
  }
View Full Code Here

TOP

Related Classes of org.scf4j.ConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.