本文整理汇总了Java中org.ini4j.Profile.Section类的典型用法代码示例。如果您正苦于以下问题:Java Section类的具体用法?Java Section怎么用?Java Section使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Section类属于org.ini4j.Profile包,在下文中一共展示了Section类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSubsetOf
import org.ini4j.Profile.Section; //导入依赖的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));
}
}
}
示例2: write
import org.ini4j.Profile.Section; //导入依赖的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: readFromIni
import org.ini4j.Profile.Section; //导入依赖的package包/类
/**
* Read the configuration from a Reader.
*
* @param section
* Ini section to read from.
* @return BUilder
*/
FieldEncryptorConfigBuilder readFromIni(Section section) {
ValueEncryptor valueEncryptor = ValueEncryptor.fromString(section.get("cipher"));
setValueEncryptor(valueEncryptor);
setProvider(section.get("provider"));
setEncryptUsingVisibility(section.containsKey("useVisibility") ? Boolean.parseBoolean(section.get("useVisibility")) : false);
setKeyId(section.getOrDefault("keyId", valueEncryptor.toString()));
setKeyLength(section.containsKey("keyLength") ? Integer.parseInt(section.get("keyLength")) : valueEncryptor.getDefaultKeyLength());
setDestination(EntryField.fromString(section.getName()));
if (!section.containsKey("sources")) {
addSource(EntryField.fromString(section.getName()));
} else {
for (String source : StringUtils.split(section.get("sources"), ',')) {
addSource(EntryField.fromString(source.trim()));
}
}
return this;
}
示例4: setupLanguage
import org.ini4j.Profile.Section; //导入依赖的package包/类
static void setupLanguage(String id, boolean silent) throws IOException {
File f = new File("messages.ini");
Config conf = new Config(f).setDefaultConfig(getDefaultIni()).compare();
if (conf.wasChanged() && !silent)
System.out.println("[Config] " + f.getName() + " has been updated.");
final Ini ini = conf.getIni();
if (!ini.containsKey(id))
Exceptions.handle(new Exception("Language code " + id + " is not valid!"), "Language code " + id + " is not valid!", true);
Section section = ini.get(id);
for (String key : section.keySet()) {
msg.put(key, section.get(key));
}
msg.put("help-dialog",
"[URL=https://sprum.ml]Sprummlbot[/URL] v" + Vars.VERSION + " by Scrumplex.");
}
示例5: parseKey
import org.ini4j.Profile.Section; //导入依赖的package包/类
private static Object parseKey(Ini ini, Object value)
throws UnsupportedEncodingException {
if (value.getClass() == String.class) {
if (((String) value).startsWith("array_")) {
Section arrSection = ini.get(value);
if (arrSection != null && !arrSection.isEmpty()) {
int arrSectionSize = arrSection.size();
byte[] arr = new byte[arrSectionSize];
Iterator<String> it = arrSection.keySet().iterator();
while (it.hasNext()) {
String v = it.next();
String elIdS = v.substring(2, v.length());
int arrElemInd = Integer.parseInt(elIdS);
arr[arrElemInd] = Byte.parseByte(arrSection.get(v));
}
return arr;
}
return null;
} else if (Boolean.parseBoolean((String) value)) {
return Boolean.parseBoolean((String) value);
} else {
return value;
}
}
return value;
}
示例6: parseInibinKeys
import org.ini4j.Profile.Section; //导入依赖的package包/类
private static Map<Integer, String> parseInibinKeys(Ini.Section section) {
Map<Integer, String> outMap = new HashMap<>();
if(section == null) {
return outMap;
}
for(final String s : section.keySet()) {
int key;
try {
key = Integer.parseInt(section.get(s));
} catch(NumberFormatException e) {
// Invalid key, skip.
continue;
}
outMap.put(key, s);
}
return outMap;
}
示例7: getConfigurationByHost
import org.ini4j.Profile.Section; //导入依赖的package包/类
private Section getConfigurationByHost(String host) {
boolean found = false;
Iterator<String> keyIt = ini.keySet().iterator();
Section section = null;
while (!found && keyIt.hasNext()) {
section = ini.get(keyIt.next());
if (!"main".equals(section.getName())) {
List<String> excludeRegexp = section.getAll("excludeRegexp");
if (excludeRegexp == null || excludeRegexp.isEmpty()) {
List<String> exclude = section.getAll("exclude");
if (exclude == null || exclude.isEmpty()) {
// Just to avoid useless re-execution
section.put("excludeRegexp", "doesnotmatchathing");
excludeRegexp = section.getAll("excludeRegexp");
} else {
excludeRegexp = exclude.stream().map(t -> createRegexpFromWildcard(t))
.collect(Collectors.toList());
section.putAll("excludeRegexp", excludeRegexp);
}
}
boolean excluded = excludeRegexp.stream().anyMatch(t -> host.matches(t));
found = !excluded;
}
}
return found ? section : null;
}
示例8: readConfigFile
import org.ini4j.Profile.Section; //导入依赖的package包/类
/**
*
* Reads the properties defined in a configuration file. Returns a set of
* configuration property blocks stored in {@link DumpProcessingAction}
* objects and call
* {@link ClientConfiguration#handleGlobalArguments(CommandLine)} to
* interpreted the properties from the general section. The first element of
* the list contains general information (about all dumps).
*
* @param path
* filename and path of the configuration file
* @return the list with configurations for all output dumps
* @throws IOException
*/
private List<DumpProcessingAction> readConfigFile(String path)
throws IOException {
List<DumpProcessingAction> result = new ArrayList<>();
FileReader reader = new FileReader(path);
Ini ini = new Ini(reader);
for (Section section : ini.values()) {
if (section.getName().toLowerCase().equals("general")) {
handleGlobalArguments(section);
} else {
DumpProcessingAction action = handleActionArguments(section);
if (action != null) {
action.setActionName(section.getName());
result.add(action);
}
}
}
return result;
}
示例9: handleActionArguments
import org.ini4j.Profile.Section; //导入依赖的package包/类
/**
* Analyses the content of a section of an ini configuration file (not the
* "general" section) and fills out the class arguments of an new
* {@link DumpProcessingAction} with this data.
*
* @param section
* {@link Section} with name "general"
* @return {@link DumpProcessingAction} containing the output parameters
*/
private DumpProcessingAction handleActionArguments(Section section) {
DumpProcessingAction result = makeDumpProcessingAction(section.get(
OPTION_ACTION).toLowerCase());
if (result == null) {
return null;
}
for (String key : section.keySet()) {
if (!result.setOption(key.toLowerCase(), section.get(key))
&& !OPTION_ACTION.equals(key.toLowerCase())) {
logger.warn("Unrecognized option: " + key);
}
}
checkDuplicateStdOutOutput(result);
return result;
}
示例10: createHandleManagerDeployCfg
import org.ini4j.Profile.Section; //导入依赖的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;
}
示例11: createHandleServiceDeployCfg
import org.ini4j.Profile.Section; //导入依赖的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;
}
示例12: getDataSource
import org.ini4j.Profile.Section; //导入依赖的package包/类
/**
* Construct {@link DataSource}
*
* @param name
* key of the INI section to load the data source from
* @return {@link DataSource} with data from the file
* @throws InvalidDataSourceException
* if <code>name</code> could not be found in any data source config file
*/
public DataSource getDataSource(String name) throws InvalidDataSourceException {
for (Ini ini : inis) {
if (!ini.keySet().contains(name))
continue; // not found in data source
Section section = ini.get(name);
String type = section.fetch("type");
if (type == null)
throw new InvalidDataSourceException("Data source config does not have \"type\" key.");
else if (type.equals("ucsc"))
return new UCSCDataSource(options, section);
else if (type.equals("ensembl"))
return new EnsemblDataSource(options, section);
else if (type.equals("refseq"))
return new RefSeqDataSource(options, section);
else if (type.equals("flat_bed"))
return new FlatBEDDataSource(options, section);
else
throw new InvalidDataSourceException("Data source config has invalid \"type\" key: " + type);
}
throw new InvalidDataSourceException("Could not find data source " + name + " in any data source file.");
}
示例13: store
import org.ini4j.Profile.Section; //导入依赖的package包/类
@Override void store(IniHandler formatter, Section section, String option)
{
store(formatter, section.getComment(option));
Type type = ((Key) section).getType(option, Type.REG_SZ);
String rawName = option.equals(Key.DEFAULT_NAME) ? option : RegEscapeTool.getInstance().quote(option);
String[] values = new String[section.length(option)];
for (int i = 0; i < values.length; i++)
{
values[i] = section.get(option, i);
}
String rawValue = RegEscapeTool.getInstance().encode(new TypeValuesPair(type, values));
formatter.handleOption(rawName, rawValue);
}
示例14: getSection
import org.ini4j.Profile.Section; //导入依赖的package包/类
private Section getSection(File serversFile) throws FileNotFoundException, IOException {
FileInputStream is = new FileInputStream(serversFile);
Ini ini = new Ini();
try {
ini.load(is);
} finally {
is.close();
}
return ini.get("global");
}
示例15: readFromFile
import org.ini4j.Profile.Section; //导入依赖的package包/类
/**
* Read the configuration from a Reader.
*
* @param in
* Stream to read from.
* @return builder.
*/
public SignatureConfigBuilder readFromFile(Reader in) throws IOException {
Ini configIni = new Ini(in);
Section section = configIni.get(SignatureConfig.SECTION_NAME);
setSigner(ValueSigner.fromString(section.get("algorithm")));
setDestination(section.containsKey("destination") ? Destination.fromString(section.get("destination")) : Destination.VALUE);
setProvider(section.get("provider")).setDestinationTable(section.get("table"));
setDefaultVisibility(section.containsKey("defaultVisibility") ? section.get("defaultVisibility").getBytes(VISIBILITY_CHARSET) : null);
return this;
}