类com.typesafe.config.ConfigOrigin源码实例Demo

下面列出了怎么用com.typesafe.config.ConfigOrigin的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    if (value instanceof String) {
        try {
            return Integer.parseInt((String) value);
        }
        catch (NumberFormatException e) {
            throw cannotConvert(loc, propName, value, "integer");
        }
    }
    else if (value instanceof Integer) {
        return value;
    }
    else {
        throw cannotConvert(loc, propName, value, "integer");
    }
}
 
源代码2 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    if ("off".equals(value)) {
        return Integer.MAX_VALUE;
    }
    else if (value instanceof String) {
        try {
            return Integer.parseInt((String) value);
        }
        catch (NumberFormatException e) {
            throw cannotConvert(loc, propName, value, "integer");
        }
    }
    else if (value instanceof Integer) {
        Integer i = (Integer) value;
        if (i > 0) {
            return i;
        }
    }
    throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
        propName + "'. Must be an " + toString());
}
 
源代码3 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    if (value instanceof String) {
        try {
            return Double.parseDouble((String) value);
        }
        catch (NumberFormatException e) {
            throw cannotConvert(loc, propName, value, "number");
        }
    }
    else if (value instanceof Double) {
        return value;
    }
    else {
        throw cannotConvert(loc, propName, value, "number");
    }
}
 
源代码4 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    if (value instanceof List) {
        List<?> l = (List<?>) value;
        boolean allStrings = true;
        for (Object o : l) {
            if (!(o instanceof String)) {
                allStrings = false;
            }
        }
        if (allStrings) {
            return value;
        }
    }
    else if (value instanceof String) {
        // also allow comma separated strings in a string
        return Arrays.asList(((String) value).split(",\\s*"));
    }
    throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
            propName + "'. Must be a " + toString());
}
 
源代码5 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, String value, ConfigOrigin loc) {
    if (!choices.contains(value)) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
            propName + "'. Valid values are: " + pp(choices));
    }
    return value;
}
 
源代码6 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, String value, ConfigOrigin loc) {
    try {
        URI u = new URI(value);
        return value;
    }
    catch (Exception e) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
            propName + "'");
    }
}
 
源代码7 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    if (value instanceof String) {
        return Boolean.valueOf((String) value);
    }
    else if (value instanceof Boolean) {
        return value;
    }
    else {
        throw cannotConvert(loc, propName, value, "boolean");
    }
}
 
源代码8 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    Integer ivalue = (Integer) super.checkValue(propName, value, loc);
    if (ivalue <= 0) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
        propName + "'. Must be a " + toString());
    }
    return ivalue;
}
 
源代码9 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    Integer ivalue = (Integer) super.checkValue(propName, value, loc);
    if (ivalue < 0) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
        propName + "'. Must be a " + toString());
    }
    return ivalue;
}
 
源代码10 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    Double dvalue = (Double) super.checkValue(propName, value, loc);
    if (dvalue < 0) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
        propName + "'. Must be a " + toString());
    }
    return dvalue;
}
 
源代码11 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    Double dvalue = (Double) super.checkValue(propName, value, loc);
    if (dvalue < l || dvalue > h) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
            propName + "'. Must be a " + toString());
    }
    return dvalue;
}
 
源代码12 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, String value, ConfigOrigin loc) {
    try {
        WallTime.timeToSeconds(value);
    }
    catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid time value '" + value + "' for property '" + 
            propName + "'. Mist be a " + toString());
    }
    return value;
}
 
源代码13 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, String value, ConfigOrigin loc) {
    String[] els = value.split(",\\s*");
    if (els.length == 2) {
        try {
            Integer.parseInt(els[0]);
            Integer.parseInt(els[1]);
            return value;
        }
        catch (NumberFormatException e) {
        }
    }
    throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
            propName + "'. Must be a " + toString());
}
 
源代码14 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, String value, ConfigOrigin loc) {
    File f = new File(value);
    if (!f.exists()) {
        throw new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tInvalid value '" + value + "' for property '" + 
            propName + "'. File does not exist.");
    }
    return value;
}
 
源代码15 项目: Bats   文件: NestedConfig.java
@Override
public ConfigOrigin origin() {
  return c.origin();
}
 
源代码16 项目: ditto   文件: DittoServiceConfig.java
@Override
public ConfigOrigin origin() {
    return serviceScopedConfig.origin();
}
 
源代码17 项目: ditto   文件: DefaultScopedConfig.java
@Override
public ConfigOrigin origin() {
    return config.origin();
}
 
源代码18 项目: ditto   文件: ConfigWithFallback.java
@Override
public ConfigOrigin origin() {
    return baseConfig.origin();
}
 
源代码19 项目: dremio-oss   文件: NestedConfig.java
@Override
public ConfigOrigin origin() {
  return config.origin();
}
 
源代码20 项目: swift-k   文件: SwiftConfig.java
public ValueLocationPair(Object value, ConfigOrigin loc) {
    this.value = value;
    this.loc = loc;
}
 
源代码21 项目: swift-k   文件: SwiftConfig.java
public static String location(ConfigOrigin loc) {
    return loc.filename() + ":" + loc.lineNumber();
}
 
源代码22 项目: swift-k   文件: ConfigPropertyType.java
@SuppressWarnings("unchecked")
public Object check(String propName, Object value, ConfigOrigin loc) {
    return checkValue(propName, (T) value, loc);
}
 
源代码23 项目: swift-k   文件: ConfigPropertyType.java
protected RuntimeException cannotConvert(ConfigOrigin loc, String propName, Object value, String toWhat) {
    return new IllegalArgumentException(SwiftConfig.location(loc) + ":\n\tCannot convert value '" + value + "' for property '" + 
            propName + "' to " + toWhat);
}
 
源代码24 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, String value, ConfigOrigin loc) {
    // all values accepted
    return value;
}
 
源代码25 项目: swift-k   文件: ConfigPropertyType.java
@Override
public Object checkValue(String propName, Object value, ConfigOrigin loc) {
    return value;
}
 
源代码26 项目: swift-k   文件: SwiftConfigSchema.java
public SwiftConfigSchema() {
    validNames = new HashSet<String>();
    schema = ConfigFactory.parseResources("swift.conf.schema");
    schema = schema.resolve();
    if (schema.isEmpty()) {
        throw new RuntimeException("Could not find swift.conf.schema");
    }
    info = new ConfigTree<Info>();
    for (Map.Entry<String, ConfigValue> e : schema.entrySet()) {
        String k = e.getKey();
        String nk = k.replace("\"*\"", "*");
        String type = null;
        Object defaultValue = null;
        String doc = null;
        ConfigOrigin loc = null;
        if (k.endsWith(".\"_type\"")) {
            type = schema.getString(k);
            nk = nk.substring(0, nk.lastIndexOf('.'));
            loc = e.getValue().origin();
        }
        else if (k.indexOf(".\"_") == -1){
            type = schema.getString(k);
            loc = e.getValue().origin();
        }
        else if (k.endsWith(".\"_default\"")){
            defaultValue = e.getValue().unwrapped();
            nk = nk.substring(0, nk.lastIndexOf('.'));
        }
        else if (k.endsWith(".\"_doc\"")){
            doc = stripDoc((String) e.getValue().unwrapped());
            nk = nk.substring(0, nk.lastIndexOf('.'));
        }
        else if (k.indexOf(".\"_") != -1) {
            continue;
        }
        Info i = info.get(nk);
        if (i == null) {
            i = new Info();
            info.put(nk, i);
            setValid(nk);
        }
        if (type != null) {
            if (type.startsWith("?")) {
                i.optional = true;
                type = type.substring(1);
            }
            i.type = getTypeInstance(type, e.getValue());
            i.typeSpec = type;
        }
        if (defaultValue != null) {
            i.value = defaultValue;
        }
        if (doc != null) {
            i.doc = doc;
        }
        if (loc != null) {
            i.loc = loc;
        }
    }
}
 
源代码27 项目: swift-k   文件: SwiftConfigSchema.java
private String loc(ConfigOrigin o) {
    return o.filename() + ":" + o.lineNumber();
}
 
源代码28 项目: swift-k   文件: SwiftConfigException.java
public SwiftConfigException(ConfigOrigin loc, String message) {
    super((loc.filename() == null ? loc.description() : loc.filename() + ":" + loc.lineNumber()) + " " + message);
}
 
源代码29 项目: xio   文件: RouteConfig.java
protected static String location(Config config, String key) {
  ConfigOrigin origin = config.getValue(key).origin();
  return origin.description() + ":" + origin.lineNumber();
}
 
public HoconJsonLocation(final ConfigOrigin origin) {
    super(origin.description(), -1L, origin.lineNumber(), -1);
    this.origin = origin;
}