本文整理汇总了Java中org.ini4j.Profile类的典型用法代码示例。如果您正苦于以下问题:Java Profile类的具体用法?Java Profile怎么用?Java Profile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Profile类属于org.ini4j包,在下文中一共展示了Profile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDwarf
import org.ini4j.Profile; //导入依赖的package包/类
public static Profile.Section addDwarf(Profile prof, DwarfData dwarf)
{
Profile.Section s = prof.add(dwarf.name);
inject(s, dwarf, "");
if (dwarf.name.equals(Dwarfs.PROP_DOPEY))
{
s.put(Dwarf.PROP_WEIGHT, DwarfsData.INI_DOPEY_WEIGHT, 0);
s.put(Dwarf.PROP_HEIGHT, DwarfsData.INI_DOPEY_HEIGHT, 0);
}
else if (dwarf.name.equals(Dwarfs.PROP_GRUMPY))
{
s.put(Dwarf.PROP_HEIGHT, DwarfsData.INI_GRUMPY_HEIGHT, 0);
}
else if (dwarf.name.equals(Dwarfs.PROP_SLEEPY))
{
s.put(Dwarf.PROP_HEIGHT, DwarfsData.INI_SLEEPY_HEIGHT, 0);
}
else if (dwarf.name.equals(Dwarfs.PROP_SNEEZY))
{
s.put(Dwarf.PROP_HOME_PAGE, DwarfsData.INI_SNEEZY_HOME_PAGE, 0);
}
return s;
}
示例2: load
import org.ini4j.Profile; //导入依赖的package包/类
@Override
protected void load(Profile.Section sec) throws Exception {
afkChannelId = sec.get("afk_channel_id", int.class);
channels = EasyMethods.convertArrayToList(sec.getAll("channels", int[].class));
excludeMode = sec.get("exclude_mode", boolean.class);
whitelistGroup = PermissionGroup.getPermissionGroupByName(sec.get("whitelist_group"));
afkTime = sec.get("max_afk_time", int.class) * 1000;
if (sec.get("condition_away", boolean.class))
afkConditions.add("away");
if (sec.get("condition_mic_muted", boolean.class))
afkConditions.add("mic_muted");
if (sec.get("condition_mic_disabled", boolean.class))
afkConditions.add("mic_disabled");
if (sec.get("condition_speaker_muted", boolean.class))
afkConditions.add("speaker_muted");
if (sec.get("condition_speaker_disabled", boolean.class))
afkConditions.add("speaker_disabled");
afkConditionsMinimumMet = sec.get("condition_min", int.class);
}
示例3: getDefaultIni
import org.ini4j.Profile; //导入依赖的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;
}
示例4: compare
import org.ini4j.Profile; //导入依赖的package包/类
public Config compare() throws IOException {
if (defaultIni == null) {
throw new NullPointerException("Default Config not defined");
}
for (Profile.Section section : defaultIni.values()) {
if (!ini.containsKey(section.getName())) {
ini.put(section.getName(), section);
ini.putComment(section.getName(), defaultIni.getComment(section.getName()));
changed = true;
} else {
for (String key : section.keySet()) {
Profile.Section realSection = ini.get(section.getName());
if (!realSection.containsKey(key)) {
realSection.put(key, section.get(key));
realSection.putComment(key, section.getComment(key));
changed = true;
}
}
}
}
if (wasChanged())
ini.store();
return this;
}
示例5: getPartitions
import org.ini4j.Profile; //导入依赖的package包/类
public List<Partition> getPartitions() {
ArrayList<Partition> partitions = new ArrayList<>();
if (mCreationMode) {
partitions.addAll(mPartitions);
return partitions;
}
Profile.Section list = mIni.get("partitions");
if (list != null) {
for (Map.Entry<String, String> entry : new TreeMap<>(list).entrySet()) {
Partition partition = new Partition(entry.getKey(), entry.getValue());
try {
if (partition.getType() != Partition.TYPE_BIND)
partition.setSize(RootToolsEx.getFileSize(getDirectory() + "/" + partition.toIniPath()));
} catch (Exception e) {
}
partitions.add(partition);
}
}
return partitions;
}
示例6: parseRemotes
import org.ini4j.Profile; //导入依赖的package包/类
@NotNull
private static Pair<Collection<Remote>, Collection<Url>> parseRemotes(@NotNull Ini ini, @NotNull ClassLoader classLoader) {
Collection<Remote> remotes = new ArrayList<Remote>();
Collection<Url> urls = new ArrayList<Url>();
for (Map.Entry<String, Profile.Section> stringSectionEntry : ini.entrySet()) {
String sectionName = stringSectionEntry.getKey();
Profile.Section section = stringSectionEntry.getValue();
Remote remote = parseRemoteSection(sectionName, section, classLoader);
if (remote != null) {
remotes.add(remote);
}
else {
Url url = parseUrlSection(sectionName, section, classLoader);
if (url != null) {
urls.add(url);
}
}
}
return Pair.create(remotes, urls);
}
示例7: WifImporter
import org.ini4j.Profile; //导入依赖的package包/类
public WifImporter(BitmessageContext ctx, InputStream in, Pubkey.Feature... features) throws IOException {
this.ctx = ctx;
Ini ini = new Ini();
ini.load(in);
for (Entry<String, Profile.Section> entry : ini.entrySet()) {
if (!entry.getKey().startsWith("BM-"))
continue;
Profile.Section section = entry.getValue();
BitmessageAddress address = Factory.createIdentityFromPrivateKey(
entry.getKey(),
getSecret(section.get("privsigningkey")),
getSecret(section.get("privencryptionkey")),
Long.parseLong(section.get("noncetrialsperbyte")),
Long.parseLong(section.get("payloadlengthextrabytes")),
Pubkey.Feature.bitfield(features)
);
if (section.containsKey("chan")) {
address.setChan(Boolean.parseBoolean(section.get("chan")));
}
address.setAlias(section.get("label"));
identities.add(address);
}
}
示例8: loadEntity
import org.ini4j.Profile; //导入依赖的package包/类
private SubTask loadEntity(Properties properties, Profile.Section currentChild) {
SubTask instance = loadInstance(properties, currentChild);
if (instance == null) throw new NullPointerException("Instance is null");
//If there are specific properties for a type of a tester in the configuration file (.ini)
instance.setProjectId(projectId);
instance.setRequestor(requestor);
instance.configureSubTask(currentChild);
instance.setMaxIntegrationTestTime(maxIntegrationTestTime);
instance.setMaxConcurrentSuccessors(maxConcurrentSuccessors);
String successorRemover = getSuccessorRemover(currentChild);
for (String subChild : currentChild.childrenNames()) {
int numInstances =
Integer.parseInt(currentChild.getChild(subChild).get("num_instances", "1"));
if (!successorRemover.equals("false") && successorRemover.equals(subChild)) {
instance.setSuccessorRemover(loadEntity(properties, currentChild.getChild(subChild)));
} else {
for (int i = 0; i < numInstances; i++)
instance.addSuccessor(loadEntity(properties, currentChild.getChild(subChild)));
}
}
return instance;
}
示例9: configureSubTask
import org.ini4j.Profile; //导入依赖的package包/类
@Override
public void configureSubTask(Profile.Section currentSection) {
this.setTimeout(Integer.parseInt(currentSection.get("timeout", "5")));
String action = currentSection.get("action");
if (action == null || action.isEmpty()) {
try {
throw new IntegrationTestException("action for VirtualNetworkFunctionRecordWait not set");
} catch (IntegrationTestException e) {
e.printStackTrace();
log.error(e.getMessage());
System.exit(42);
}
}
this.setAction(Action.valueOf(action));
}
示例10: configureSubTask
import org.ini4j.Profile; //导入依赖的package包/类
@Override
public void configureSubTask(Profile.Section currentSection) {
this.setTimeout(Integer.parseInt(currentSection.get("timeout", "5")));
String action = currentSection.get("action");
if (action == null) {
try {
throw new IntegrationTestException("action for NetworkServiceRecordWait not set");
} catch (IntegrationTestException e) {
e.printStackTrace();
log.error(e.getMessage());
System.exit(42);
}
}
this.setAction(Action.valueOf(action));
}
示例11: configureSubTask
import org.ini4j.Profile; //导入依赖的package包/类
@Override
public void configureSubTask(Profile.Section currentSection) {
String vnfrType = currentSection.get("vnf-type");
String virtualLink = currentSection.get("virtual-link");
String floatingIp = currentSection.get("floating-ip");
if (vnfrType != null) {
this.setVnfrType(vnfrType);
}
if (virtualLink != null) {
this.setVirtualLink(virtualLink);
}
if (floatingIp != null) {
this.setFloatingIp(floatingIp);
}
}
示例12: parseRemotes
import org.ini4j.Profile; //导入依赖的package包/类
@NotNull
private static Pair<Collection<Remote>, Collection<Url>> parseRemotes(@NotNull Ini ini, @Nullable ClassLoader classLoader) {
Collection<Remote> remotes = new ArrayList<Remote>();
Collection<Url> urls = new ArrayList<Url>();
for (Map.Entry<String, Profile.Section> stringSectionEntry : ini.entrySet()) {
String sectionName = stringSectionEntry.getKey();
Profile.Section section = stringSectionEntry.getValue();
if (sectionName.startsWith("remote") || sectionName.startsWith("svn-remote")) {
Remote remote = parseRemoteSection(sectionName, section, classLoader);
if (remote != null) {
remotes.add(remote);
}
}
else if (sectionName.startsWith("url")) {
Url url = parseUrlSection(sectionName, section, classLoader);
if (url != null) {
urls.add(url);
}
}
}
return Pair.create(remotes, urls);
}
示例13: validate
import org.ini4j.Profile; //导入依赖的package包/类
@Override public void validate(ConfigSchema schema, Ini config) throws ValidationException {
Map<String, ConstraintValidator> validators = collectValidators();
for (Map.Entry<String, Profile.Section> entry : config.entrySet()) {
String groupName = entry.getKey();
Profile.Section section = entry.getValue();
for (String name : section.keySet()) {
SchemaItem item = schema.get(groupName, name);
if (item == null) {
// should not happen
LOGGER.warn("Found configuration item [" + groupName + "] " + name + " without corresponding schema item");
continue;
}
validateItemValues(validators, item, section.getAll(name));
}
}
}
示例14: parseConfig
import org.ini4j.Profile; //导入依赖的package包/类
@NotNull
private Map<String, String> parseConfig(@NotNull String content) throws IOException {
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
final Ini ini = new Ini(new StringReader(content));
final Map<String, String> result = new HashMap<>();
for (Map.Entry<String, Profile.Section> sectionEntry : ini.entrySet()) {
for (Map.Entry<String, String> configEntry : sectionEntry.getValue().entrySet()) {
String value = configEntry.getValue();
if (value.startsWith("\"") && value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
}
result.put(sectionEntry.getKey() + ":" + configEntry.getKey(), value);
}
}
return result;
}
示例15: getCfgValue
import org.ini4j.Profile; //导入依赖的package包/类
public String getCfgValue(String section, String key) throws NulsException {
Profile.Section ps = ini.get(section);
if (null == ps) {
throw new NulsException(ErrorCode.CONFIGURATION_ITEM_DOES_NOT_EXIST);
}
String value = ps.get(key);
if (StringUtils.isBlank(value)) {
throw new NulsException(ErrorCode.CONFIGURATION_ITEM_DOES_NOT_EXIST);
}
return value;
}