當前位置: 首頁>>代碼示例>>Java>>正文


Java Ini.add方法代碼示例

本文整理匯總了Java中org.ini4j.Ini.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Ini.add方法的具體用法?Java Ini.add怎麽用?Java Ini.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.ini4j.Ini的用法示例。


在下文中一共展示了Ini.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: merge

import org.ini4j.Ini; //導入方法依賴的package包/類
/**
 * Merges only sections/keys/values into target which are not already present in source
 * 
 * @param source the source ini file
 * @param target the target ini file in which the values from the source file are going to be merged
 */
private void merge(Ini source, Ini target) {
    for (Iterator<String> itSections = source.keySet().iterator(); itSections.hasNext();) {
        String sectionName = itSections.next();
        Ini.Section sourceSection = source.get( sectionName );
        Ini.Section targetSection = target.get( sectionName );

        if(targetSection == null) {
            targetSection = target.add(sectionName);
        }

        for (Iterator<String> itVariables = sourceSection.keySet().iterator(); itVariables.hasNext();) {
            String key = itVariables.next();

            if(!targetSection.containsKey(key)) {
                targetSection.put(key, sourceSection.get(key));
            }
        }            
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:SvnConfigFiles.java

示例2: write

import org.ini4j.Ini; //導入方法依賴的package包/類
/**
 * Write the object to a Writer.
 *
 * @param out
 *          Stream to write object out to.
 */
public void write(Writer out) throws IOException {
  Ini configIni = new Ini();
  Section section = configIni.add(SECTION_NAME);

  section.put("algorithm", algorithm.toString());
  section.put("provider", provider);
  section.put("destination", destination.toString());
  if (destinationTable != null) {
    section.put("table", destinationTable);
  }
  if (defaultVisibility != null) {
    section.put("defaultVisibility", new String(defaultVisibility, VISIBILITY_CHARSET));
  }

  configIni.store(out);
}
 
開發者ID:mit-ll,項目名稱:PACE,代碼行數:23,代碼來源:SignatureConfig.java

示例3: testWithEmptyOption

import org.ini4j.Ini; //導入方法依賴的package包/類
@Test public void testWithEmptyOption() throws Exception
{
    Config cfg = new Config();

    cfg.setEmptyOption(true);
    Ini ini = new Ini();
    Ini.Section sec = ini.add(Dwarfs.PROP_BASHFUL);

    sec.put(Dwarf.PROP_FORTUNE_NUMBER, null);
    ini.setConfig(cfg);
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(Dwarfs.PROP_BASHFUL);
    handler.handleOption(Dwarf.PROP_FORTUNE_NUMBER, "");
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    verify(ini, handler);
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:21,代碼來源:IniFormatterTest.java

示例4: testWithStrictOperator

import org.ini4j.Ini; //導入方法依賴的package包/類
@Test public void testWithStrictOperator() throws Exception
{
    Config cfg = new Config();

    cfg.setStrictOperator(true);
    Ini ini = new Ini();
    Ini.Section sec = ini.add(Dwarfs.PROP_BASHFUL);

    sec.put(Dwarf.PROP_AGE, DwarfsData.bashful.age);
    ini.setConfig(cfg);
    StringWriter writer = new StringWriter();

    ini.store(writer);
    StringBuilder exp = new StringBuilder();

    exp.append(IniParser.SECTION_BEGIN);
    exp.append(Dwarfs.PROP_BASHFUL);
    exp.append(IniParser.SECTION_END);
    exp.append(NL);
    exp.append(Dwarf.PROP_AGE);
    exp.append('=');
    exp.append(DwarfsData.bashful.age);
    exp.append(NL);
    exp.append(NL);
    assertEquals(exp.toString(), writer.toString());
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:27,代碼來源:IniFormatterTest.java

示例5: newTaleIni

import org.ini4j.Ini; //導入方法依賴的package包/類
public static Ini newTaleIni()
{
    Ini ini = new Ini();

    ini.setComment(HEADER_COMMENT);
    ini.add(TaleData.PROP_DWARFS);
    addDwarf(ini, TaleData.bashful);
    addDwarf(ini, TaleData.doc);
    addDwarf(ini, TaleData.dopey);
    addDwarf(ini, TaleData.grumpy);
    addDwarf(ini, TaleData.happy);
    addDwarf(ini, TaleData.sleepy);
    addDwarf(ini, TaleData.sneezy);

    return ini;
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:17,代碼來源:Helper.java

示例6: getDefaultIni

import org.ini4j.Ini; //導入方法依賴的package包/類
private static Ini getDefaultIni() {
    Ini ini = new Ini();
    Profile.Section defaultSec = ini.add("Admins");
    defaultSec.add("uid", "uid1");
    defaultSec.add("group", 6);

    defaultSec = ini.add("Supporters");
    defaultSec.add("uid", "uid2");
    defaultSec.add("group", 6);
    defaultSec.add("inherit", "Admins");

    defaultSec = ini.add("VIPs");
    defaultSec.add("uid", "uid3");
    defaultSec.add("uid", "uid4");
    defaultSec.add("group", 6);
    defaultSec.add("inherit", "Supporters");
    return ini;
}
 
開發者ID:Scrumplex,項目名稱:Sprummlbot,代碼行數:19,代碼來源:Permissions.java

示例7: createCaConfFile

import org.ini4j.Ini; //導入方法依賴的package包/類
@Override
protected void createCaConfFile(Ca rootCa, Ca ca, String crlURI,
		String cpsURI, String subject) throws Exception {
	
	super.createCaConfFile(rootCa, ca, crlURI, cpsURI, subject);
	File f = new File(ca.getConfFileName());
	Ini confFile = new Ini(f);
	Ini.Section sect;
	sect = confFile.get("v3_req");
		sect.put("certificatePolicies", "@polsection1, @polsection2");
	sect = confFile.get("v3_ca");
		sect.put("authorityKeyIdentifier", "keyid,issuer:always");
		sect.put("certificatePolicies", "@polsection1, @polsection2");
	sect = confFile.add("polsection1"); 
		sect.put("policyIdentifier", cpsCaA1);
		sect.put("CPS.1", "\"" + cpsURI + "\"");
	sect = confFile.add("polsection2"); 
		sect.put("policyIdentifier", cpsCaA3);
		sect.put("CPS.1", "\"" + cpsURI + "\"");
	confFile.store();
}
 
開發者ID:robsonsmartins,項目名稱:fiap-mba-java-projects,代碼行數:22,代碼來源:CaDAO.java

示例8: createHandleManagerDeployCfg

import org.ini4j.Ini; //導入方法依賴的package包/類
private File createHandleManagerDeployCfg(
		final AuthToken shockAdminToken,
		final String allowedUser,
		final URL authServiceURL)
		throws IOException {
	final File iniFile = tempDir.resolve("handleManager.cfg").toFile();
	if (iniFile.exists()) {
		iniFile.delete();
	}
	
	final Ini ini = new Ini();
	final Section hm = ini.add("HandleMngr");
	hm.add("handle-service-url", "http://localhost:" + handleServicePort);
	hm.add("service-host", "localhost");
	hm.add("service-port", "" + handleManagerPort);
	hm.add("auth-service-url", authServiceURL.toString());
	hm.add("admin-token", shockAdminToken.getToken());
	hm.add("allowed-users", allowedUser);
	
	ini.store(iniFile);
	return iniFile;
}
 
開發者ID:kbase,項目名稱:workspace_deluxe,代碼行數:23,代碼來源:HandleServiceController.java

示例9: createHandleServiceDeployCfg

import org.ini4j.Ini; //導入方法依賴的package包/類
private File createHandleServiceDeployCfg(
		final MySQLController mysql,
		final String shockHost,
		final URL authServiceURL) throws IOException {
	final File iniFile = tempDir.resolve("handleService.cfg").toFile();
	if (iniFile.exists()) {
		iniFile.delete();
	}
	
	final Ini ini = new Ini();
	final Section hs = ini.add(HANDLE_SERVICE_NAME);
	hs.add("self-url", "http://localhost:" + handleServicePort);
	hs.add("service-port", "" + handleServicePort);
	hs.add("service-host", "localhost");
	hs.add("auth-service-url", authServiceURL.toString());
	hs.add("default-shock-server", shockHost);
	
	hs.add("mysql-host", "127.0.0.1");
	hs.add("mysql-port", "" + mysql.getServerPort());
	hs.add("mysql-user", USER);
	hs.add("mysql-pass", PWD);
	hs.add("data-source", "dbi:mysql:" + DB);
	
	ini.store(iniFile);
	return iniFile;
}
 
開發者ID:kbase,項目名稱:workspace_deluxe,代碼行數:27,代碼來源:HandleServiceController.java

示例10: testValidateMultiValuedMax

import org.ini4j.Ini; //導入方法依賴的package包/類
@Test(expected = ValidationException.class)
public void testValidateMultiValuedMax() throws Exception {
	ConfigSchema schema = new ConfigSchema();
	Constraint constraint = new Constraint();
	constraint.setType("int");
	constraint.addParam("max", "3");
	String group = "group";
	String name = "name";
	addSchemaItem(schema, group, name, true, "desc", Arrays.asList(constraint));

	Ini ini = new Ini();
	ini.add(group, name, "3");
	ini.add(group, name, "5");

	DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
	validator.validate(schema, ini);
}
 
開發者ID:Skrethel,項目名稱:simple-config-retrofit,代碼行數:18,代碼來源:DefaultSchemaConstraintValidatorTest.java

示例11: patch

import org.ini4j.Ini; //導入方法依賴的package包/類
@Override
public void patch(Ini file) {
    // patch store-auth-creds to "no"
    Ini.Section auth = (Ini.Section) file.get("auth");                  // NOI18N
    if(auth == null) {
        auth = file.add("auth");                                        // NOI18N
    }
    auth.put("store-auth-creds", "yes");                                // NOI18N
    auth.put("store-passwords", "no");                                  // NOI18N
    auth.put("password-stores", "");                                    // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:SvnConfigFiles.java

示例12: getSection

import org.ini4j.Ini; //導入方法依賴的package包/類
private Ini.Section getSection(Ini ini, String key, boolean create) {
    Ini.Section section = ini.get(key);
    if(section == null) {
        return ini.add(key);
    }
    return section;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:SvnConfigFiles.java

示例13: getSection

import org.ini4j.Ini; //導入方法依賴的package包/類
private Ini.Section getSection(Ini ini, String key, boolean create) {
    Ini.Section section = ini.get(key);
    if(section == null && create) {
        return ini.add(key);
    }
    return section;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:HgConfigFiles.java

示例14: write

import org.ini4j.Ini; //導入方法依賴的package包/類
/**
 * Write's this FieldEncryptorBase configuration to the given INI.
 *
 * @param configIni
 *          INI to write to.
 */
void write(Ini configIni) {
  Section section = configIni.add(destination.toString());

  section.put("cipher", valueEncryptor.toString());
  section.put("provider", provider);
  section.put("useVisibility", encryptUsingVisibility);
  section.put("keyId", keyId);
  section.put("keyLength", Integer.toString(keyLength));
  section.put("sources", StringUtils.join(sources, ','));
}
 
開發者ID:mit-ll,項目名稱:PACE,代碼行數:17,代碼來源:FieldEncryptorConfig.java

示例15: testWithoutConfig

import org.ini4j.Ini; //導入方法依賴的package包/類
@Test public void testWithoutConfig() throws Exception
{
    Ini ini = new Ini();
    Ini.Section sec = ini.add(Dwarfs.PROP_BASHFUL);

    sec.put(Dwarf.PROP_FORTUNE_NUMBER, null);
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(Dwarfs.PROP_BASHFUL);
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    verify(ini, handler);
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:16,代碼來源:IniFormatterTest.java


注:本文中的org.ini4j.Ini.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。