本文整理汇总了Java中org.ini4j.Ini.put方法的典型用法代码示例。如果您正苦于以下问题:Java Ini.put方法的具体用法?Java Ini.put怎么用?Java Ini.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ini4j.Ini
的用法示例。
在下文中一共展示了Ini.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInvalidMin
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test(expected = ValidationException.class)
public void testInvalidMin() throws Exception {
ConfigSchema schema = new ConfigSchema();
Constraint constraint = new Constraint();
constraint.setType("int");
constraint.addParam("min", "3");
String group = "group";
String name = "name";
addSchemaItem(schema, group, name, true, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "2");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例2: testValidMin
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test
public void testValidMin() throws Exception {
ConfigSchema schema = new ConfigSchema();
Constraint constraint = new Constraint();
constraint.setType("int");
constraint.addParam("min", "3");
String group = "group";
String name = "name";
addSchemaItem(schema, group, name, 3, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "3");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例3: testValidMax
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test
public void testValidMax() 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, 3, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "3");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例4: testInvalidMax
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test(expected = ValidationException.class)
public void testInvalidMax() 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.put(group, name, "5");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例5: overrideBuckconfig
import org.ini4j.Ini; //导入方法依赖的package包/类
public static void overrideBuckconfig(
ProjectWorkspace projectWorkspace,
Map<String, ? extends Map<String, String>> buckconfigOverrides)
throws IOException {
String config = projectWorkspace.getFileContents(".buckconfig");
Ini ini = new Ini(new StringReader(config));
for (Map.Entry<String, ? extends Map<String, String>> section :
buckconfigOverrides.entrySet()) {
for (Map.Entry<String, String> entry : section.getValue().entrySet()) {
ini.put(section.getKey(), entry.getKey(), entry.getValue());
}
}
StringWriter writer = new StringWriter();
ini.store(writer);
Files.write(projectWorkspace.getPath(".buckconfig"), writer.toString().getBytes(UTF_8));
}
示例6: storeSession
import org.ini4j.Ini; //导入方法依赖的package包/类
/**Stores a session with all back end modules and the Splitter's configuration**/
public void storeSession(int sessionNumber){
try{
String dbPath = System.getProperty("user.home")+"/.nubisave/nubisavemount/data/.nubisave_database"+sessionNumber;
//store the back end modules:
File dir = new File(dataDir+"/.nubisave_session_"+sessionNumber);
dir.mkdirs();
Nubisave.services.storeToDatabase(dataDir+"/.nubisave_session_"+sessionNumber);
FileUtil.copy(new File(new PropertiesUtil("nubi.properties").getProperty("splitter_database_location")+".db"), new File(dbPath));
Ini splitterConfig = new Ini(new File(configurationFilePath));
splitterConfig.put("splitter", "save", sessionNumber);
System.out.println( "gui db path: "+"/.nubisave_database"+sessionNumber);
splitterConfig.put("database", "path", "/.nubisave_database"+sessionNumber);
splitterConfig.store();
} catch(Exception e){
System.err.println("Splitter.storeSession(int sessionNumber): Failed to configure Splitter "+" - "+e.getMessage()==null?e.getMessage():"");
}
}
示例7: testValidBool
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test
public void testValidBool() throws Exception {
ConfigSchema schema = new ConfigSchema();
Constraint constraint = new Constraint();
constraint.setType("bool");
String group = "group";
String name = "name";
addSchemaItem(schema, group, name, true, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "true");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例8: testInvalidBool
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test(expected = ValidationException.class)
public void testInvalidBool() throws Exception {
ConfigSchema schema = new ConfigSchema();
Constraint constraint = new Constraint();
constraint.setType("bool");
String group = "group";
String name = "name";
addSchemaItem(schema, group, name, true, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "asdf");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例9: testValidInt
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test
public void testValidInt() throws Exception {
ConfigSchema schema = new ConfigSchema();
Constraint constraint = new Constraint();
constraint.setType("int");
String group = "group";
String name = "name";
addSchemaItem(schema, group, name, 3, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "3");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例10: testInvalidInt
import org.ini4j.Ini; //导入方法依赖的package包/类
@Test(expected = ValidationException.class)
public void testInvalidInt() throws Exception {
ConfigSchema schema = new ConfigSchema();
Constraint constraint = new Constraint();
constraint.setType("int");
String group = "group";
String name = "name";
addSchemaItem(schema, group, name, true, "desc", Arrays.asList(constraint));
Ini ini = new Ini();
ini.put(group, name, "asdf");
DefaultSchemaConstraintValidator validator = new DefaultSchemaConstraintValidator();
validator.validate(schema, ini);
}
示例11: setServicesMapping
import org.ini4j.Ini; //导入方法依赖的package包/类
/**
* Sets the mapping of current to previous service names in the splitter's configuration file
* The section name is MapOfCurrentToPreviousServices and the parameter names are the current services' names
* with the corresponding previous services' names as values. The services need to be renamed in order to access the files
* from the previous session, after the database has been reloaded.
*/
private void setServicesMapping(Ini config) {String sessionNumber = config.fetch("splitter", "load", String.class);
Map<String,String> newToPreviousServiceNames = storageServiceMgr.getServices().getServiceNameMapping(".nubisave_service_name.session"+sessionNumber);
for(Entry<String, String> newToPreviousServiceName: newToPreviousServiceNames.entrySet()){
config.put("MapOfCurrentToPreviousServices", newToPreviousServiceName.getKey(), newToPreviousServiceName.getValue());
}
vtSplitterConfig.setText(IniUtil.getString(config)); //TODO: synchronize
}
示例12: saveDatabase
import org.ini4j.Ini; //导入方法依赖的package包/类
private void saveDatabase(Ini config) throws IOException {
String dbPath = config.fetch("database", "path", String.class);
FilePartFragmentMetaDataStore filePartFragmentDataStore = (FilePartFragmentMetaDataStore)fileStore.fileFragmentMetaDataStore;
long size = fileStore.getSize(dbPath);
log.debug("database dbPath: "+dbPath);
log.debug("database size: "+size);
config.put("database", "size", size);
List<String> fragments;
List<byte[]> checksums;
String sectionName;
int databasePartNr = 0;
for(String dbPartPath: filePartFragmentDataStore.getFilePartPaths(dbPath)){
sectionName = "databasePartNr_"+databasePartNr;
fragments = getFragments(dbPartPath);
checksums = ((FileFragmentMetaDataStore)fileStore.fileFragmentMetaDataStore).getFragmentsChecksums(dbPartPath);
config.put(sectionName, "name", dbPartPath);
config.put(sectionName, "nrOfFileFragmentsRequired", filePartFragmentDataStore.getNrOfRequiredFragments(dbPartPath));
config.put(sectionName, "nrOfFileFragments", filePartFragmentDataStore.getNrOfFragments(dbPartPath));
for(int i=0; i<fragments.size();i++){
log.debug("fragment name "+i+": "+fragments.get(i));
config.put(sectionName, "fileFragmentName_"+i, fragments.get(i));
log.debug("checksums.get(i)="+checksums.size());
config.put(sectionName, "fileFragmentNameChecksum_"+i, new String(Hex.encode(checksums.get(i))) );
databasePartNr++;
}
}
}
示例13: setRedundancy
import org.ini4j.Ini; //导入方法依赖的package包/类
public void setRedundancy(int redundancy){
/**Sets the redundancy level for Splitter module**/
try{
Ini splitterConfig = new Ini(new File(configurationFilePath));
splitterConfig.put("splitter", "redundancy", redundancy);
splitterConfig.store();
} catch(Exception e){
System.err.println("Splitter.setRedundancy(int redundancy): Failed to configure Splitter "+" - "+e.getMessage()==null?e.getMessage():"");
}
}
示例14: setStorageStrategy
import org.ini4j.Ini; //导入方法依赖的package包/类
/**Sets the storage strategy for Splitter module**/
public void setStorageStrategy(String storageStrategy) {
try{
Ini splitterConfig = new Ini(new File(configurationFilePath));
splitterConfig.put("splitter", "storagestrategy", storageStrategy);
splitterConfig.store();
} catch(Exception e){
System.err.println("Splitter.setStorageStrategy(String storageStrategy): Failed to configure Splitter "+" - "+e.getMessage()==null?e.getMessage():"");
}
}
示例15: addIniItem
import org.ini4j.Ini; //导入方法依赖的package包/类
static void addIniItem(Ini ini, String group, String name, String value, String comment) {
ini.put(group, name, value);
if (comment != null) {
ini.get(group).putComment(name, comment);
}
}