• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConfigOrigin类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.typesafe.config.ConfigOrigin的典型用法代码示例。如果您正苦于以下问题:Java ConfigOrigin类的具体用法?Java ConfigOrigin怎么用?Java ConfigOrigin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ConfigOrigin类属于com.typesafe.config包,在下文中一共展示了ConfigOrigin类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkValue

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:18,代码来源:ConfigPropertyType.java


示例2: build

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
/**
 * Loads, parses, binds, and validates a configuration object.
 *
 * @param provider the provider to to use for reading configuration files
 * @param path     the path of the configuration file
 * @return a validated configuration object
 * @throws IOException            if there is an error reading the file
 * @throws ConfigurationException if there is an error parsing or validating the file
 */
public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException {
    try (InputStream input = provider.open(checkNotNull(path))) {
        final JsonNode node = mapper.readTree(hoconFactory.createParser(input));
        return build(node, path);
    } catch (ConfigException e) {
        ConfigurationParsingException.Builder builder = ConfigurationParsingException
                .builder("Malformed HOCON")
                .setCause(e)
                .setDetail(e.getMessage());
        
        ConfigOrigin origin = e.origin();
        if (origin != null) {
            builder.setLocation(origin.lineNumber(), 0);
        }
        throw builder.build(path);
    }
}
 
开发者ID:jclawson,项目名称:dropwizardry,代码行数:27,代码来源:HoconConfigurationFactory.java


示例3: setStringToConfig

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
/**
 * Sets the String value for current configuration's variable to config.
 *
 * @param key
 *            The name of settings section.
 * @param subKey
 *            The name of needed variable.
 * @param value
 *            The value to set.
 */
private static void setStringToConfig(String key, String subKey, String newValue,
		boolean hideValue) {
	String fullPath = MAINKEY + "." + key + "." + subKey;
	if (getString(key, subKey).equals(newValue)) {
		String messageToLog = hideValue
				? String.format("Setting secret configuration value. Key: %s.%s", key, subKey)
				: String.format("Configuration value unchanged. Key: %s.%s Value: %s", key,
						subKey, newValue);
		logger.info(messageToLog);
		return;
	}
	String processedNewValue = ConfigUtil.quoteString(newValue);
	// Lets make new Config object with just a single variable.
	// Also lets preserve the comments from the original Config.
	ConfigOrigin or = conf.getValue(fullPath).origin();
	StringBuilder toParse = new StringBuilder();
	for (String comment : or.comments()) {
		toParse.append("#").append(comment).append("\n");
	}
	toParse.append(fullPath).append("=").append(processedNewValue);
	Config newLittleConfig = ConfigFactory.parseString(toParse.toString());
	// Now we have our little Config with the single variable and old comments.
	// Let's merge it with the old Config.
	conf = newLittleConfig.withFallback(conf);
	if (!hideValue) {
		logger.info(String.format("Configuration update in RAM. Key: %s.%s Value: %s", key, subKey, newValue));
	}
	needsSave = true;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:40,代码来源:CuteConfig.java


示例4: getTokenLocation

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@Override
public JsonLocation getTokenLocation() {
    ConfigValue current = currentConfig();
    if (current == null) {
        return JsonLocation.NA;
    }
    ConfigOrigin nodeOrigin = current.origin();
    return new JsonLocation(current, -1, nodeOrigin.lineNumber(), -1);
}
 
开发者ID:addthis,项目名称:codec,代码行数:10,代码来源:ConfigTraversingParser.java


示例5: origin

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@Override
public ConfigOrigin origin() {
  return c.origin();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:NestedConfig.java


示例6: origin

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@Override
public ConfigOrigin origin() {
  return config.origin();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:NestedConfig.java


示例7: ValueLocationPair

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
public ValueLocationPair(Object value, ConfigOrigin loc) {
    this.value = value;
    this.loc = loc;
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:5,代码来源:SwiftConfig.java


示例8: location

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
public static String location(ConfigOrigin loc) {
    return loc.filename() + ":" + loc.lineNumber();
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:4,代码来源:SwiftConfig.java


示例9: check

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object check(String propName, Object value, ConfigOrigin loc) {
    return checkValue(propName, (T) value, loc);
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:5,代码来源:ConfigPropertyType.java


示例10: cannotConvert

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
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);
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:5,代码来源:ConfigPropertyType.java


示例11: SwiftConfigSchema

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
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;
        }
    }
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:61,代码来源:SwiftConfigSchema.java


示例12: loc

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
private String loc(ConfigOrigin o) {
    return o.filename() + ":" + o.lineNumber();
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:4,代码来源:SwiftConfigSchema.java


示例13: SwiftConfigException

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
public SwiftConfigException(ConfigOrigin loc, String message) {
    super((loc.filename() == null ? loc.description() : loc.filename() + ":" + loc.lineNumber()) + " " + message);
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:4,代码来源:SwiftConfigException.java


示例14: location

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
protected static String location(Config config, String key) {
  ConfigOrigin origin = config.getValue(key).origin();
  return origin.description() + ":" + origin.lineNumber();
}
 
开发者ID:xjdr,项目名称:xio,代码行数:5,代码来源:RouteConfig.java


示例15: fromConfigValue

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
public static JsonLocation fromConfigValue(ConfigValue configValue) {
    ConfigOrigin configOrigin = configValue.origin();
    return new JsonLocation(configValue, -1, configOrigin.lineNumber(), -1);
}
 
开发者ID:addthis,项目名称:codec,代码行数:5,代码来源:Jackson.java


示例16: HoconJsonLocation

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
public HoconJsonLocation(final ConfigOrigin origin) {
    super(origin.description(), -1L, origin.lineNumber(), -1);
    this.origin = origin;
}
 
开发者ID:jclawson,项目名称:jackson-dataformat-hocon,代码行数:5,代码来源:HoconJsonLocation.java


示例17: withComments

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@Override
public ConfigOrigin withComments(List<String> comments) {
    return origin.withComments(comments);
}
 
开发者ID:jclawson,项目名称:jackson-dataformat-hocon,代码行数:5,代码来源:HoconJsonLocation.java


示例18: withLineNumber

import com.typesafe.config.ConfigOrigin; //导入依赖的package包/类
@Override
public ConfigOrigin withLineNumber(int i) {
    return origin.withLineNumber(i);
}
 
开发者ID:jclawson,项目名称:jackson-dataformat-hocon,代码行数:5,代码来源:HoconJsonLocation.java



注:本文中的com.typesafe.config.ConfigOrigin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileSystemRegistry类代码示例发布时间:2022-05-22
下一篇:
Java MapType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap