本文整理汇总了Java中com.moandjiezana.toml.Toml类的典型用法代码示例。如果您正苦于以下问题:Java Toml类的具体用法?Java Toml怎么用?Java Toml使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Toml类属于com.moandjiezana.toml包,在下文中一共展示了Toml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readServers
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
private List<RaftMessage.Server> readServers() {
List<RaftMessage.Server> servers = new ArrayList<>();
List<Toml> serverConfList = toml.getTables("servers");
for (Toml serverConf : serverConfList) {
RaftMessage.EndPoint endPoint = RaftMessage.EndPoint.newBuilder()
.setHost(serverConf.getString("ip"))
.setPort(serverConf.getLong("port").intValue())
.build();
RaftMessage.Server server = RaftMessage.Server.newBuilder()
.setEndPoint(endPoint)
.setServerId(serverConf.getLong("id").intValue())
.build();
LOG.info("read conf server={}", BrokerUtils.protoToJson(server));
servers.add(server);
}
return servers;
}
示例2: loadMenuOrder
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
@SuppressWarnings("unchecked")
void loadMenuOrder(String name) {
Toml toml = new Toml();
toml.read(this.getClass().getResourceAsStream("menu.toml"));
Map<String, Object> map = toml.toMap();
menuOrder = (List<String>) map.get(name);
}
示例3: addConfigurations
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
/**
* Register a new configuration file containing Talon parameters. These parameter objects will be
* merged with existing parameter objects. If a new parameter object has the same name as an
* existing object, the old object will be overwritten.
*
* @param configs a parsed config collection
*/
public void addConfigurations(Toml configs) {
List<Toml> configList = configs.getTables(TALON_TABLE);
if (configList == null) {
logger.error("no " + TALON_TABLE + " tables in config");
return;
}
for (Toml config : configList) {
String name = config.getString(TalonConfigurationBuilder.NAME);
if (name == null) {
throw new IllegalArgumentException(TALON_TABLE + " configuration name parameter missing");
}
settings.put(name, TalonConfigurationBuilder.create(config));
logger.info("added configuration: {}", name);
}
}
示例4: fromFile
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
public static Sandbox fromFile(File file) {
Log.info("Look for sandbox.toml for file {0}", file.getAbsolutePath());
if (!file.isFile()) {
return null;
}
Log.info("Loadding sandbox.toml for file {0}", file.getAbsolutePath());
Toml boxToml = new Toml().read(file);
Sandbox box = boxToml.to(Sandbox.class);
Toml users = boxToml.getTable("users");
if (emptyInstance(users)) {
box.setUsers(new Users());
} else {
box.setUsers(users.to(Users.class));
}
Toml whitelist = boxToml.getTable("whitelist");
if (emptyInstance(whitelist)) {
box.setWhitelist(new Whitelist());
} else {
box.setWhitelist(whitelist.to(Whitelist.class));
}
return box;
}
示例5: MessageConfiguration
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
MessageConfiguration(Toml toml, Toml defaults) throws ValidationException {
super(toml, defaults);
try {
username = getString(KEY_PREFIX + USERNAME_KEY);
useRealNames = getBoolean(KEY_PREFIX + USE_REAL_NAMES_KEY);
iconUrl = getString(KEY_PREFIX + ICON_URL_KEY);
dateFormatter = DateTimeFormat
.forPattern(getString(KEY_PREFIX + DATE_PATTERN_KEY))
.withLocale(Locale.forLanguageTag(getString(KEY_PREFIX + DATE_LOCALE_KEY)));
priorityColors = getBoolean(KEY_PREFIX + PRIORITY_COLORS_KEY);
defaultColor = getString(KEY_PREFIX + DEFAULT_COLOR_KEY);
defaultFields = getList(KEY_PREFIX + DEFAULT_FIELDS_KEY);
extendedFields = getList(KEY_PREFIX + EXTENDED_FIELDS_KEY);
whitelistedJiraKeyPrefixes = charSet(getString(KEY_PREFIX + WHITELISTED_KEY_PREFIXES_KEY));
whitelistedJiraKeySuffixes = charSet(getString(KEY_PREFIX + WHITELISTED_KEY_SUFFIXES_KEY));
} catch (Exception e) {
throw new ValidationException(e);
}
}
示例6: Configurator
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
public Configurator() {
if (Files.exists(Paths.get(CONFIG_FILE))) {
Toml toml = new Toml();
toml.parse(new File(CONFIG_FILE));
siteName = toml.getString(SITE_NAME.key);
siteTagline = toml.getString(SITE_TAGLINE.key);
siteAuthor = toml.getString(SITE_AUTHOR.key);
siteBaseUrl = toml.getString(SITE_BASE_URL.key);
sourceDir = toml.getString(SOURCE_DIR.key);
outputDir = toml.getString(OUTPUT_DIR.key);
excludeDirs = toml.getList(EXCLUDE.key);
inputDateFormat = toml.getString(IN_DATE_FORMAT.key);
outputDateFormat = toml.getString(OUT_DATE_FORMAT.key);
theme = toml.getString(THEME.key);
indexPosts = Integer.valueOf(toml.getLong(INDEX_POSTS.key).toString());
port = Integer.valueOf(toml.getLong(PORT.key).toString());
Map<String, Object> socialLinks = toml.getTable(SOCIAL.key).to(Map.class);
social = new Social(socialLinks);
renderTags = toml.getBoolean(RENDER_TAGS.key);
headerImage = toml.getString(IMAGE.key);
}
if (this.siteBaseUrl != null && this.siteBaseUrl.contains("localhost")) {
this.siteBaseUrl = "http://localhost:" + port;
}
}
示例7: load
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Configuration load(Toml toml) {
Configuration configuration = toml.to(Configuration.class);
configuration.globalOptions = toml.getTable("options").to(GlobalOptions.class);
Map<String, List<String>> map = toml.to(Map.class);
map.entrySet().stream()
.filter(e -> !e.getKey().toString().equals("options"))
.filter(e -> !e.getKey().toString().equals("bundle"))
.map(e -> {
String key = e.getKey().toString().substring(1, e.getKey().toString().length() -1);
Bundle bundle;
if (e.getValue() instanceof List) {
bundle = new Bundle(key, (List<String>) e.getValue());
} else {
List<String> assets = (List<String>) ((Map<String, Object>) e.getValue()).get("assets");
bundle = new Bundle(key, assets);
}
return bundle;
})
.forEach(configuration.bundle::add);
configuration.bundle.forEach(Bundle::normaliseAssets);
return configuration;
}
示例8: GlobalConf
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
public GlobalConf() {
String fileName = "/broker.toml";
File file = new File(getClass().getResource(fileName).getFile());
toml = new Toml().read(file);
localServer = readLocalServer();
servers = readServers();
dataDir = toml.getString("data_dir");
maxSegmentSize = toml.getLong("max_segment_size").intValue();
shardingId = toml.getLong("sharding_id").intValue();
expiredLogCheckInterval = toml.getLong("expired_log_check_interval").intValue();
expiredLogDuration = toml.getLong("expired_log_duration").intValue();
zkConf = readZKConf();
}
示例9: readLocalServer
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
private RaftMessage.Server readLocalServer() {
RaftMessage.Server.Builder serverBuilder = RaftMessage.Server.newBuilder();
RaftMessage.EndPoint.Builder endPointBuilder = RaftMessage.EndPoint.newBuilder();
Toml localServerConf = toml.getTable("local_server");
endPointBuilder.setHost(localServerConf.getString("ip"));
endPointBuilder.setPort(localServerConf.getLong("port").intValue());
serverBuilder.setEndPoint(endPointBuilder);
serverBuilder.setServerId(localServerConf.getLong("id").intValue());
RaftMessage.Server localServer = serverBuilder.build();
LOG.info("read local_server conf={}", BrokerUtils.protoToJson(localServer));
return localServer;
}
示例10: readZKConf
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
private ZKConf readZKConf() {
Toml zookeeperToml = toml.getTable("zookeeper");
zkConf = new ZKConf();
zkConf.setZKServers(zookeeperToml.getString("servers"));
zkConf.setZKConnectTimeoutMs(zookeeperToml.getLong("connect_timeout_ms").intValue());
zkConf.setZKSessionTimeoutMs(zookeeperToml.getLong("session_timeout_ms").intValue());
zkConf.setZKRetryCount(zookeeperToml.getLong("retry_count").intValue());
zkConf.setZKRetryIntervalMs(zookeeperToml.getLong("retry_interval_ms").intValue());
zkConf.setZKBasePath(zookeeperToml.getString("base_path"));
return zkConf;
}
示例11: load
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
private SettingsData load(File settingsFile) {
// Make sure settingsFile is set before loading settings
if (settingsFile == null) {
System.out.printf("Could not access settings file, defaults will be loaded.\n");
return new SettingsData();
} else {
System.out.printf("Reading settings from: %s\n", settingsFile);
return new Toml().read(settingsFile).to(SettingsData.class);
}
}
示例12: BotSettingsManager
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
/**
* attempts to read the settings file,
* on failure, generate a new default file
*/
public BotSettingsManager()
{
InputStream input = null;
try
{
input = new FileInputStream("./" + FILENAME);
settings = (new Toml()).read(input).to(BotSettings.class);
}
catch (IOException ex)
{
this.generateFile();
settings = null;
}
finally
{
if (input != null)
{
try
{
input.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
示例13: TalonProvisioner
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
/**
* Construct the TalonProvisioner with base talon configurations that include swerve drive motors.
*
* @param file base configuration that should include swerve azimuth and drive configs
* @throws IllegalStateException if file contains invalid TOML
*/
@Inject
public TalonProvisioner(File file) {
checkFileExists(file);
Toml toml = new Toml().read(file);
logger.info("adding configurations from {}", file);
addConfigurations(toml);
}
示例14: create
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
/**
* Create a {@link TalonConfiguration} based on supplied config.
*
* @param config the configuration
* @return the TalonConfiguration
* @throws IllegalArgumentException if mode is missing from config
* @throws UnsupportedOperationException if mode not implemented yet
*/
@NotNull
public static TalonConfiguration create(Toml config) {
TalonConfiguration talonConfiguration = null;
CANTalon.TalonControlMode mode = getMode(config);
switch (mode) {
case Voltage:
talonConfiguration = config.to(VoltageTalonConfiguration.class);
break;
case Position:
talonConfiguration = config.to(PositionTalonConfiguration.class);
break;
case Speed:
talonConfiguration = config.to(SpeedTalonConfiguration.class);
break;
case MotionMagic:
talonConfiguration = config.to(MotionMagicTalonConfiguration.class);
break;
case PercentVbus:
case Current:
case Follower:
case MotionProfile:
case Disabled:
throw new UnsupportedOperationException(mode.name());
}
return talonConfiguration;
}
示例15: getMode
import com.moandjiezana.toml.Toml; //导入依赖的package包/类
static CANTalon.TalonControlMode getMode(Toml config) {
String mode = config.getString(MODE);
if (mode == null) {
throw new IllegalArgumentException("mode missing from configuration");
}
return CANTalon.TalonControlMode.valueOf(mode);
}