本文整理汇总了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));
}
}
}
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
示例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;
}
示例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;
}
示例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, ','));
}
示例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);
}