本文整理汇总了Java中org.ini4j.Ini类的典型用法代码示例。如果您正苦于以下问题:Java Ini类的具体用法?Java Ini怎么用?Java Ini使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ini类属于org.ini4j包,在下文中一共展示了Ini类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getServerGroup
import org.ini4j.Ini; //导入依赖的package包/类
/**
* Returns the section from the <b>servers</b> config file used by the Subversion module which
* is holding the proxy settings for the given host
*
* @param host the host
* @return the section holding the proxy settings for the given host
*/
private Ini.Section getServerGroup(String host) {
if(host == null || host.equals("")) { // NOI18N
return null;
}
Ini.Section groups = svnServers.get(GROUPS_SECTION);
if(groups != null) {
for (Iterator<String> it = groups.keySet().iterator(); it.hasNext();) {
String key = it.next();
String value = groups.get(key);
if(value != null) {
value = value.trim();
if(value != null && match(value, host)) {
return svnServers.get(key);
}
}
}
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SvnConfigFiles.java
示例2: setSSLCert
import org.ini4j.Ini; //导入依赖的package包/类
private boolean setSSLCert(RepositoryConnection rc, Ini.Section nbGlobalSection) {
if(rc == null) {
return false;
}
String certFile = rc.getCertFile();
if(certFile == null || certFile.equals("")) {
return false;
}
char[] certPasswordChars = rc.getCertPassword();
String certPassword = certPasswordChars == null ? "" : new String(certPasswordChars); //NOI18N
if(certPassword.equals("")) { // NOI18N
return false;
}
nbGlobalSection.put("ssl-client-cert-file", certFile);
if (!DO_NOT_SAVE_PASSPHRASE) {
nbGlobalSection.put("ssl-client-cert-password", certPassword);
return true;
}
return false;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SvnConfigFiles.java
示例3: 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
示例4: isSubsetOf
import org.ini4j.Ini; //导入依赖的package包/类
private void isSubsetOf(String sourceIniPath, String expectedIniPath) throws IOException {
Ini goldenIni = new Ini(new FileInputStream(expectedIniPath));
Ini sourceIni = new Ini(new FileInputStream(sourceIniPath));
for(String key : goldenIni.keySet()) {
if(!sourceIni.containsKey(key) && goldenIni.get(key).size() > 0) {
fail("missing section " + key + " in file " + sourceIniPath);
}
Section goldenSection = goldenIni.get(key);
Section sourceSection = sourceIni.get(key);
for(String name : goldenSection.childrenNames()) {
if(!sourceSection.containsKey(name)) {
fail("missing name " + name + " in file " + sourceIniPath + " section [" + name + "]");
}
assertEquals(goldenSection.get(name), sourceSection.get(name));
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SvnConfigFilesTest.java
示例5: storeIni
import org.ini4j.Ini; //导入依赖的package包/类
private void storeIni(Ini ini, String iniFile) {
assert initException == null;
BufferedOutputStream bos = null;
try {
String filePath;
if (dir != null) {
filePath = dir.getAbsolutePath() + File.separator + HG_REPO_DIR + File.separator + iniFile; // NOI18N
} else {
filePath = getUserConfigPath() + iniFile;
}
File file = FileUtil.normalizeFile(new File(filePath));
file.getParentFile().mkdirs();
ini.store(bos = new BufferedOutputStream(new FileOutputStream(file)));
} catch (IOException ex) {
Mercurial.LOG.log(Level.INFO, null, ex);
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException ex) {
Mercurial.LOG.log(Level.INFO, null, ex);
}
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:HgConfigFiles.java
示例6: getPicUrl
import org.ini4j.Ini; //导入依赖的package包/类
private String getPicUrl(String filename)
{
String url = null;
Ini ini = new Ini();
String filepath = configData.coolqDir + "/data/image/" + filename + ".cqimg";
try
{
ini.load(new FileReader(filepath));
} catch (IOException e)
{
e.printStackTrace();
}
Ini.Section section = ini.get("image");
url = section.get("url");
return url;
}
开发者ID:XiLingHost,项目名称:tg-qq-trans,代码行数:17,代码来源:GetQQPic.java
示例7: init
import org.ini4j.Ini; //导入依赖的package包/类
public static void init(String configFile) {
try {
Ini ini = new Ini(new File(configFile));
serverPort = Integer.parseInt(ini.get("global", "serverPort"));
prefixModeOnly = Boolean.parseBoolean(ini.get("index", "prefixModeOnly"));
indexFolderName = Boolean.parseBoolean(ini.get("index", "indexFolderName"));
useParallelPicturesGeneration = Boolean.parseBoolean(ini.get("thumbnail", "useParallelPicturesGeneration"));
forceExifToolsDownload = Boolean.parseBoolean(ini.get("global", "forceExifToolsDownload"));
forceExifToolsDownload = Boolean.parseBoolean(ini.get("global", "forceExifToolsDownload"));
addressElementsCount = Integer.parseInt(ini.get("global", "addressElementsCount"));
fullScreenPictureQuality = Integer.parseInt(ini.get("fullscreen", "fullScreenPictureQuality"));
maxFullScreenPictureWitdh = Integer.parseInt(ini.get("fullscreen", "maxFullScreenPictureWitdh"));
maxFullScreenPictureHeight = Integer.parseInt(ini.get("fullscreen", "maxFullScreenPictureHeight"));
thumbnailHeight = Integer.parseInt(ini.get("thumbnail", "thumbnailHeight"));
thumbnailQuality = Integer.parseInt(ini.get("thumbnail", "thumbnailQuality"));
} catch (Exception ex) {
throw new IllegalArgumentException("Incorrect config file : " + configFile + " - " + ex);
}
}
开发者ID:trebonius0,项目名称:Photato,代码行数:22,代码来源:PhotatoConfig.java
示例8: 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
示例9: 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
示例10: 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
示例11: test
import org.ini4j.Ini; //导入依赖的package包/类
private void test(String filename, String defaultEncoding) throws Exception
{
Charset charset = (defaultEncoding == null) ? Config.DEFAULT_FILE_ENCODING : Charset.forName(defaultEncoding);
UnicodeInputStreamReader reader = new UnicodeInputStreamReader(getClass().getResourceAsStream(filename), charset);
Ini ini = new Ini();
ini.setConfig(Config.getGlobal().clone());
ini.getConfig().setFileEncoding(charset);
ini.load(reader);
Ini.Section sec = ini.get("section");
if (sec == null)
{
throw new IllegalStateException("Missing section: section");
}
if (!"value".equals(sec.get("option")))
{
throw new IllegalStateException("Missing option: option");
}
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:22,代码来源:UnicodeInputStreamReaderTest.java
示例12: sample01
import org.ini4j.Ini; //导入依赖的package包/类
void sample01(Ini ini)
{
Ini.Section section = ini.get("happy");
//
// read some values
//
String age = section.get("age");
String weight = section.get("weight");
String homeDir = section.get("homeDir");
//
// .. or just use java.util.Map interface...
//
Map<String, String> map = ini.get("happy");
age = map.get("age");
weight = map.get("weight");
homeDir = map.get("homeDir");
// get all section names
Set<String> sectionNames = ini.keySet();
//}
Helper.assertEquals(DwarfsData.happy, section.as(Dwarf.class));
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:27,代码来源:IniTutorial.java
示例13: sample04
import org.ini4j.Ini; //导入依赖的package包/类
void sample04(Ini ini)
{
Ini.Section sneezy = ini.get("sneezy");
String n1 = sneezy.get("fortuneNumber", 0); // = 11
String n2 = sneezy.get("fortuneNumber", 1); // = 22
String n3 = sneezy.get("fortuneNumber", 2); // = 33
String n4 = sneezy.get("fortuneNumber", 3); // = 44
// ok, lets do in it easier...
int[] n = sneezy.getAll("fortuneNumber", int[].class);
//}
// #2817399
assertEquals("11", n1);
assertEquals("22", n2);
assertEquals("33", n3);
assertEquals("44", n4);
assertEquals(4, n.length);
assertEquals(11, n[0]);
assertEquals(22, n[1]);
assertEquals(33, n[2]);
assertEquals(44, n[3]);
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:24,代码来源:IniTutorial.java
示例14: sample01
import org.ini4j.Ini; //导入依赖的package包/类
void sample01(Ini.Section section)
{
//
// read some values
//
String age = section.get("age");
String weight = section.get("weight");
String homeDir = section.get("homeDir");
// get all option names
Set<String> optionNames = section.keySet();
//}
assertEquals(String.valueOf(DwarfsData.happy.age), age);
assertEquals(String.valueOf(DwarfsData.happy.weight), weight);
assertEquals(String.valueOf(DwarfsData.happy.homeDir), homeDir);
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:OptionMapTutorial.java
示例15: run
import org.ini4j.Ini; //导入依赖的package包/类
@Override protected void run(File arg) throws Exception
{
Ini ini = new Ini(arg.toURI().toURL());
sample01(ini);
sample02(ini);
sample03(ini);
sample04(arg.toURI().toURL());
Options opts = new Options();
opts.putAll(ini.get(Dwarfs.PROP_BASHFUL));
sample05(opts);
//
File optFile = new File(arg.getParentFile(), OptTutorial.FILENAME);
sample06(optFile.toURI().toURL());
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:BeanTutorial.java
示例16: sample01
import org.ini4j.Ini; //导入依赖的package包/类
void sample01(Ini ini)
{
Ini.Section sec = ini.get("happy");
Dwarf happy = sec.as(Dwarf.class);
int age = happy.getAge();
URI homePage = happy.getHomePage();
happy.setWeight(45.55);
//}
//|
//| The <<<happy instanceof Dwarf>>> relation is of course fulfilled in the
//| example above.
//|
assertEquals(DwarfsData.happy.homePage.toString(), homePage.toString());
assertEquals(DwarfsData.happy.age, age);
assertEquals(45.55, happy.getWeight(), 0.01);
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:BeanTutorial.java
示例17: main
import org.ini4j.Ini; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
String filename = (args.length > 0) ? args[0] : FILENAME;
Ini ini = new Ini(new FileReader(filename));
for (Ini.Section section : ini.values())
{
System.out.println("[" + section.getName() + "]");
for (String option : section.keySet())
{
System.out.println(option + " = " + section.fetch(option));
}
System.out.println();
}
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:17,代码来源:DumpSample.java
示例18: main
import org.ini4j.Ini; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
String filename = (args.length > 0) ? args[0] : FILENAME;
Ini ini = new Ini(new FileInputStream(filename));
Dwarf sneezy = ini.get("sneezy").as(Dwarf.class);
sneezy.addPropertyChangeListener("age", new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent event)
{
System.out.println("property " + event.getPropertyName() + " change");
System.out.println(event.getOldValue() + " -> " + event.getNewValue());
}
});
System.out.println("Sneezy's age: " + sneezy.getAge());
sneezy.setAge(44);
System.out.println("Sneezy's age: " + sneezy.getAge());
}
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:BeanEventSample.java
示例19: 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
示例20: 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
注:本文中的org.ini4j.Ini类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论