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


Java PropertiesConfiguration.setProperty方法代码示例

本文整理汇总了Java中org.apache.commons.configuration.PropertiesConfiguration.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConfiguration.setProperty方法的具体用法?Java PropertiesConfiguration.setProperty怎么用?Java PropertiesConfiguration.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration.PropertiesConfiguration的用法示例。


在下文中一共展示了PropertiesConfiguration.setProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDefault

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public void createDefault() throws Exception {
	if (file.exists()) {
		file.renameTo(new File(Enterence.propFileName + ".bak"));
	}
	file.createNewFile();
	PropertiesConfiguration config = new PropertiesConfiguration(
			Enterence.propFileName);
	config.setProperty("sudoers", Configs.sudoers);
	config.setProperty("sudoPwd", Configs.sudoPwd);
	config.setProperty("server", Configs.server);
	config.setProperty("name", Configs.name);
	config.setProperty("pwd", Configs.pwd);
	config.setProperty("channels", Configs.channels);
	config.setProperty("preffix", Configs.preffix);
	config.setProperty("sudoers", Configs.sudoers);
	config.setProperty("recordFileName", Configs.recordFileName);
	config.setProperty("useProxy", Configs.useProxy);
	config.setProperty("Proxy", Configs.Proxy);
	config.save();
}
 
开发者ID:D0048,项目名称:irc-helper,代码行数:21,代码来源:MyConfig.java

示例2: normalizeCommands

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
/**
 * Normalize all guild commands
 * @param collection All commands
 * @throws ConfigurationException If apache config throws an exception
 */
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
	Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
			TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
	found.add(new File("resources/guilds/template.properties"));
	for (File f : found) {
		if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
			PropertiesConfiguration config = new PropertiesConfiguration(f);
			List<String> enabledCommands = config.getList("EnabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			List<String> disabledCommands = config.getList("DisabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			for (Command c : collection) {
				if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
					enabledCommands.add(c.toString());
				}
			}
			config.setProperty("EnabledCommands", enabledCommands);
			config.save();
		}
	}
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:29,代码来源:CommandHandler.java

示例3: save

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public String save() {

        // 设定文件初期读入
        try {
            PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                    .getContextClassLoader().getResource("language/package.properties"));

            languageConf.setProperty(YiDuConfig.TITLE, Utils.escapePropterties(title));
            languageConf.setProperty(YiDuConfig.SITEKEYWORDS, Utils.escapePropterties(siteKeywords));
            languageConf.setProperty(YiDuConfig.SITEDESCRIPTION, Utils.escapePropterties(siteDescription));
            languageConf.setProperty(YiDuConfig.NAME, Utils.escapePropterties(name));
            languageConf.setProperty(YiDuConfig.URL, Utils.escapePropterties(url));
            languageConf.setProperty(YiDuConfig.COPYRIGHT, Utils.escapePropterties(copyright));
            languageConf.setProperty(YiDuConfig.BEIANNO, Utils.escapePropterties(beianNo));
            languageConf.setProperty(YiDuConfig.ANALYTICSCODE, Utils.escapePropterties(analyticscode));
            languageConf.setProperty(YiDuConfig.CATEGORY, Utils.escapePropterties(category));

            File languageFile = new File(languageConf.getPath());
            OutputStream out = new FileOutputStream(languageFile);
            languageConf.save(out);

        } catch (Exception e) {
            addActionError(e.getMessage());
            logger.error(e);
            return ADMIN_ERROR;
        }
        loadData();
        addActionMessage(getText("messages.save.success"));
        return INPUT;

    }
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:32,代码来源:LanguageEditAction.java

示例4: updateMandatoryProperties

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
private void updateMandatoryProperties(final UpgradeResult result, File configDir) throws ConfigurationException,
	IOException
{
	PropertyFileModifier propMod = new PropertyFileModifier(new File(configDir,
		PropertyFileModifier.MANDATORY_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			// Add Tomcat ports
			String url = (String) props.getProperty("admin.url");
			String port = getPort(url);
			String tomcatComment = System.lineSeparator()
				+ "# Tomcat ports. Specify the ports Tomcat should create connectors for";
			PropertiesConfigurationLayout layout = props.getLayout();
			layout.setLineSeparator(System.lineSeparator());
			if( url.contains("https") )
			{
				String httpsProp = "https.port";
				props.setProperty(httpsProp, port);
				layout.setComment(httpsProp, tomcatComment);
				props.setProperty("#http.port", "");
			}
			else
			{
				String httpProp = "http.port";
				props.setProperty(httpProp, port);
				layout.setComment(httpProp, tomcatComment);
				props.setProperty("#https.port", "");
			}
			props.setProperty("#ajp.port", "8009");

			// Remove Tomcat location
			props.clearProperty("tomcat.location");

			return true;
		}
	};
	propMod.updateProperties();
}
 
开发者ID:equella,项目名称:Equella,代码行数:41,代码来源:UpgradeToEmbeddedTomcat.java

示例5: upgrade

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@Override
public void upgrade(UpgradeResult result, File tleInstallDir) throws Exception
{
	PropertyFileModifier modifier = new PropertyFileModifier(new File(new File(tleInstallDir, CONFIG_FOLDER),
		PropertyFileModifier.HIBERNATE_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			String dialect = props.getString(HIBERNATE_DIALECT);
			String newdialect = null;
			if( dialect.equals("org.hibernate.dialect.PostgreSQLDialect") )
			{
				newdialect = "com.tle.hibernate.dialect.ExtendedPostgresDialect";
			}
			else if( dialect.equals("org.hibernate.dialect.Oracle10gDialect") )
			{
				newdialect = "com.tle.hibernate.dialect.ExtendedOracle10gDialect";
			}
			else if( dialect.equals("org.hibernate.dialect.Oracle9iDialect")
				|| dialect.equals("org.hibernate.dialect.Oracle9Dialect") )
			{
				newdialect = "com.tle.hibernate.dialect.ExtendedOracle9iDialect";
			}
			if( newdialect != null )
			{
				props.setProperty(HIBERNATE_DIALECT, newdialect);
				return true;
			}
			return false;
		}
	};
	modifier.updateProperties();
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:UpdateHibernateProperties.java

示例6: checkPropertyException

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
/**
 * Helper to check for the correct exception and message
 *
 * @param key
 */
private void checkPropertyException(final String key) {
    PropertiesConfiguration props = loadProperties();
    try {
        props.setProperty(key, null);
        new AdapterConfig(props);
        Assert.fail("Expected an IllegalArgumentException");
    } catch (AdapterConfigException ex) {
        Assert.assertEquals(key + " is missing in file filePath", ex.getMessage());
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:16,代码来源:AdapterConfigTest.java

示例7: setUserValues

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
private void setUserValues(String propName, String propValue){
    try {
        PropertiesConfiguration config = new PropertiesConfiguration(extFolder+propFileName);
        config.setProperty(propName, propValue);
        config.save();
        //logger.info(config.getPath());
    } catch (Exception e) {
        logger(logger,"error", e.getMessage());
    }
}
 
开发者ID:symphonicon,项目名称:Fav-Track,代码行数:11,代码来源:GetPropetries.java

示例8: loadData

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
@Override
protected void loadData() {

    if (StringUtils.isEmpty(uv)) {
        addActionError(getText("errors.not.exsits.upgradeVersion"));
        return;
    }
    // step1下载安装包并解压缩
    logger.info("going to download upgrade file : " + uv + ".zip");
    ZIP_FILE_URL = SITE_URL + uv + ".zip";

    String currentPath = UpgradeAction.class.getClassLoader().getResource("").getPath();
    File f = new File(currentPath).getParentFile().getParentFile();
    INPUT_ZIP_FILE = f.getAbsolutePath() + File.separator + "tmp" + File.separator + uv + ".zip";
    OUTPUT_FOLDER = f.getAbsolutePath() + File.separator + "tmp" + File.separator + uv + File.separator;

    BASE_FOLDER = f.getAbsolutePath() + File.separator;

    downloadFile();
    if (this.hasErrors()) {
        return;
    }
    logger.info("going to unzip upgrade file : " + uv + ".zip");
    unZipFile();
    if (this.hasErrors()) {
        return;
    }

    // 读取rules文件
    String content = readFileByLines(OUTPUT_FOLDER + "rule");

    Gson g = new Gson();
    List<UpgradeBean> upgradeList = g.fromJson(content, new TypeToken<List<UpgradeBean>>() {
    }.getType());

    for (UpgradeBean rb : upgradeList) {
        switch (rb.getType()) {
        case FileType.STATIC:
        case FileType.CLASS:
        case FileType.FTL:
        case FileType.JSP:
        case FileType.XML:
            // 替换或添加静态文件,class文件,ftl,jsp
            // 直接覆盖
            File srcFile = new File(OUTPUT_FOLDER + rb.getPath());
            File destFile = new File(BASE_FOLDER + rb.getPath());
            try {
                FileUtils.copyFile(srcFile, destFile);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                logger.error(e1.getMessage(), e1);
                addActionError(e1.getMessage());
                return;
            }

            break;
        case FileType.PROPERTIES:
            // 修改properties文件
            try {
                PropertiesConfiguration propertiesFile = new PropertiesConfiguration(Thread.currentThread().getContextClassLoader()
                        .getResource(rb.getFileName()));
                propertiesFile.setProperty(rb.getKey(), rb.getContent());
                File jdbcFile = new File(propertiesFile.getPath());
                OutputStream out = new FileOutputStream(jdbcFile);
                propertiesFile.save(out);
            } catch (Exception e) {
                addActionError(e.getMessage());
                logger.error(e);
            }
            break;
        case FileType.SQL:
            // 执行文件
            upgradeService.excuteUpgradeSql(rb.getSql());
            break;
        default:
            break;
        }
    }
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:80,代码来源:UpgradeAction.java

示例9: changeKey

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
private boolean changeKey(PropertiesConfiguration props, String suffix, boolean clearOnly)
{
	String eventServiceVal = props.getString(EVENT_SERVICE_PREFIX + suffix);
	String sessionServiceVal = props.getString(USER_SESSION_SERVICE_PREFIX + suffix);

	String useVal = (eventServiceVal == null ? sessionServiceVal : eventServiceVal);
	if( useVal != null )
	{
		if( !clearOnly )
		{
			props.setProperty(CHANNEL_SERVICE_PREFIX + suffix, useVal);
		}
		props.clearProperty(EVENT_SERVICE_PREFIX + suffix);
		props.clearProperty(USER_SESSION_SERVICE_PREFIX + suffix);
		return true;
	}
	return false;
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:UpdateClusterConfig.java


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