当前位置: 首页>>代码示例>>Java>>正文


Java Toml类代码示例

本文整理汇总了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;
}
 
开发者ID:wenweihu86,项目名称:distmq,代码行数:18,代码来源:GlobalConf.java

示例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);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:8,代码来源:CommandAdapter.java

示例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);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:24,代码来源:TalonProvisioner.java

示例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;
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:23,代码来源:Sandbox.java

示例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);
	}
}
 
开发者ID:gustavkarlsson,项目名称:rocketchat-jira-trigger,代码行数:20,代码来源:MessageConfiguration.java

示例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;
        }
    }
 
开发者ID:pawandubey,项目名称:griffin,代码行数:27,代码来源:Configurator.java

示例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;
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:27,代码来源:Configuration.java

示例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();
}
 
开发者ID:wenweihu86,项目名称:distmq,代码行数:14,代码来源:GlobalConf.java

示例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;
}
 
开发者ID:wenweihu86,项目名称:distmq,代码行数:13,代码来源:GlobalConf.java

示例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;
}
 
开发者ID:wenweihu86,项目名称:distmq,代码行数:12,代码来源:GlobalConf.java

示例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);
	}
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:11,代码来源:TOMLSettings.java

示例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();
            }
        }
    }
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:33,代码来源:BotSettingsManager.java

示例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);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:14,代码来源:TalonProvisioner.java

示例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;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:35,代码来源:TalonConfigurationBuilder.java

示例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);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:8,代码来源:TalonConfigurationBuilder.java


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