本文整理汇总了Java中java.util.Properties.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.keySet方法的具体用法?Java Properties.keySet怎么用?Java Properties.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Properties
的用法示例。
在下文中一共展示了Properties.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readProperties
import java.util.Properties; //导入方法依赖的package包/类
private Properties readProperties(Vector <? extends Property> antProperties) throws IOException {
Properties props = new Properties();
for(Property prop : antProperties) {
if(prop.getName()!=null) {
if(prop.getValue()!=null) {
props.setProperty(prop.getName(), prop.getValue());
} else if(prop.getLocation()!=null) {
props.setProperty(prop.getName(),
new File(prop.getLocation().getFileName()).getAbsolutePath());
}
} else if(prop.getFile()!=null || prop.getUrl()!=null) {
InputStream is = null;
try {
is = (prop.getFile()!=null) ?
new FileInputStream(prop.getFile()) :
prop.getUrl().openStream();
Properties loadedProps = new Properties();
loadedProps.load(is);
is.close();
if ( prop.getPrefix() != null ) {
for(Object p : loadedProps.keySet()) {
props.setProperty(prop.getPrefix() + p,
loadedProps.getProperty(p.toString()));
}
} else {
props.putAll(loadedProps);
}
} finally {
if (is != null) {
is.close();
}
}
}
}
return props;
}
示例2: loadConnectionProps
import java.util.Properties; //导入方法依赖的package包/类
private void loadConnectionProps(Properties props) {
if (props != null) {
for (Object key : props.keySet()) {
String propsKey = (String) key;
if (components.containsKey(propsKey)) {
JComponent component = components.get(propsKey);
String value = props.getProperty(propsKey);
if (component instanceof JTextField) {
((JTextField) component).setText(value);
} else if (component instanceof JComboBox) {
((JComboBox) component).setSelectedItem(value);
}
}
}
}
}
示例3: expectBindingFailure
import java.util.Properties; //导入方法依赖的package包/类
public void expectBindingFailure(URI fsURI, Configuration config) {
try {
Properties binding = RestClientBindings.bind(fsURI, config);
//if we get here, binding didn't fail- there is something else.
//list the properties but not the values.
StringBuilder details = new StringBuilder() ;
for (Object key: binding.keySet()) {
details.append(key.toString()).append(" ");
}
fail("Expected a failure, got the binding [ "+ details+"]");
} catch (SwiftConfigurationException expected) {
}
}
示例4: readMapColors
import java.util.Properties; //导入方法依赖的package包/类
private static int[] readMapColors(Properties p_readMapColors_0_, String p_readMapColors_1_, String p_readMapColors_2_, String p_readMapColors_3_)
{
int[] aint = new int[MapColor.COLORS.length];
Arrays.fill((int[])aint, (int) - 1);
int i = 0;
for (Object s0 : p_readMapColors_0_.keySet())
{
String s = (String) s0;
String s1 = p_readMapColors_0_.getProperty(s);
if (s.startsWith(p_readMapColors_2_))
{
String s2 = StrUtils.removePrefix(s, p_readMapColors_2_);
int j = getMapColorIndex(s2);
int k = parseColor(s1);
if (j >= 0 && j < aint.length && k >= 0)
{
aint[j] = k;
++i;
}
else
{
warn("Invalid color: " + s + " = " + s1);
}
}
}
if (i <= 0)
{
return null;
}
else
{
dbg(p_readMapColors_3_ + " colors: " + i);
return aint;
}
}
示例5: retrieveStandAloneEnvProperties
import java.util.Properties; //导入方法依赖的package包/类
/**
* This method retrieves all properties from the StandAloneEnvProperties
* file
**/
protected static void retrieveStandAloneEnvProperties() {
configPath = "./src/test/resources/configuration/config.properties";
Properties prop = FileUtilityManager.getProperties(configPath);
Set<Object> set = prop.keySet();
Iterator<Object> it = set.iterator();
for (int i = 0; i < set.size(); i++) {
String key = (String) it.next();
if (key.equalsIgnoreCase("desktopUrl")) {
desktopUrl = prop.getProperty(key);
} else if (key.equalsIgnoreCase("deviceUrl")) {
deviceUrl = prop.getProperty(key);
} else if (key.equalsIgnoreCase("platformName")) {
platformName = prop.getProperty(key);
} else if (key.equalsIgnoreCase("platformVersion")) {
platformVersion = prop.getProperty(key);
} else if (key.equalsIgnoreCase("automationName")) {
automationName = prop.getProperty(key);
} else if (key.equalsIgnoreCase("deviceName")) {
deviceName = prop.getProperty(key);
} else if (key.equalsIgnoreCase("noReset")) {
noReset = prop.getProperty(key);
} else if (key.equalsIgnoreCase("fullReset")) {
fullReset = prop.getProperty(key);
} else if (key.equalsIgnoreCase("app")) {
app = prop.getProperty(key);
} else if (key.equalsIgnoreCase("device")) {
device = prop.getProperty(key);
} else
continue;
}
}
示例6: readPotionColors
import java.util.Properties; //导入方法依赖的package包/类
private static int[] readPotionColors(Properties p_readPotionColors_0_, String p_readPotionColors_1_, String p_readPotionColors_2_, String p_readPotionColors_3_)
{
int[] aint = new int[Potion.potionTypes.length];
Arrays.fill((int[])aint, (int) - 1);
int i = 0;
for (Object s : p_readPotionColors_0_.keySet())
{
String s1 = p_readPotionColors_0_.getProperty((String) s);
if (((String) s).startsWith(p_readPotionColors_2_))
{
int j = getPotionId((String) s);
int k = parseColor(s1);
if (j >= 0 && j < aint.length && k >= 0)
{
aint[j] = k;
++i;
}
else
{
warn("Invalid color: " + s + " = " + s1);
}
}
}
if (i <= 0)
{
return null;
}
else
{
dbg(p_readPotionColors_3_ + " colors: " + i);
return aint;
}
}
示例7: mergeIfExist
import java.util.Properties; //导入方法依赖的package包/类
private void mergeIfExist(Properties from, Properties to) {
for (Object key : from.keySet()) {
if (!to.containsKey(key)) {
continue;
}
Object fromObj = from.get(key), toObj = to.get(key);
if (toObj != null && !toObj.equals(fromObj)) {
log.info("Replace, key: {}, value: {} -> {}", key, toObj, fromObj);
}
to.put(key, fromObj);
}
}
示例8: getPropertyAndPropOderControl
import java.util.Properties; //导入方法依赖的package包/类
private static void getPropertyAndPropOderControl(Properties properties, Set<String> propNames, Set<String> propOrderControl)
{
for (Object propKeyObj : properties.keySet())
{
String propKey = (String) propKeyObj;
// Find end of property control (default/custom) flag
int propOrderControlEndDot = propKey.indexOf('.');
if (propOrderControlEndDot < 1)
{
logger.debug("Ignoring property: " + propKey);
continue;
}
int propKeyLength = propKey.length();
int propNameLength = (propKeyLength - propOrderControlEndDot) -1; // Length of characters between dots
if (propNameLength < 1)
{
logger.debug("Ignoring property: " + propKey);
continue;
}
String orderControl = propKey.substring(0, propOrderControlEndDot);
String propName = propKey.substring((propOrderControlEndDot + 1));
// Add them
propOrderControl.add(orderControl);
propNames.add(propName);
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("All property order controls: " + propOrderControl);
logger.debug("All properties: " + propNames);
}
}
示例9: checkAreAllItemsTranslated
import java.util.Properties; //导入方法依赖的package包/类
/**
* check the imported properties are all translated
*
* @param propertiesMap
* map contains default language properties and imported language
* properties
* @param defaultLanguageCode
* language code of default language
* @param importLanguageCode
* language code of imported language
* @return
* @throws PropertiesImportException
* - exception while import properties
* @throws ObjectNotFoundException
* - exception if there is no default language in system
*/
@RolesAllowed({ "PLATFORM_OPERATOR" })
public String checkAreAllItemsTranslated(
List<Map<String, Properties>> propertiesMaps,
String importLanguageCode) throws PropertiesImportException,
ObjectNotFoundException {
String defaultLanguageCode = getDefaultLanguage()
+ StandardLanguage.COLUMN_HEADING_SUFFIX;
for (Map<String, Properties> propertiesMap : propertiesMaps) {
Properties defaultLanguageProperties = propertiesMap
.get(defaultLanguageCode);
Properties importLanguageProperties = propertiesMap
.get(importLanguageCode);
Set<Object> keys = defaultLanguageProperties.keySet();
for (Object key : keys) {
String defaultPropertyValue = defaultLanguageProperties
.get(key.toString()).toString().trim();
if (defaultPropertyValue.length() == 0) {
continue;
}
if (importLanguageProperties.containsKey(key)) {
Object importPropertyValue = importLanguageProperties
.get(key.toString());
if (importPropertyValue != null
&& importPropertyValue.toString().length() > 0) {
continue;
}
}
PropertiesImportException propertiesImportException = new PropertiesImportException(
PropertiesImportException.Reason.TRANSLATIONS_MISSING);
logger.logWarn(
Log4jLogger.SYSTEM_LOG,
propertiesImportException,
LogMessageIdentifier.WARN_TRANSLATIONS_MISSING_FOR_IMPORT_PROPERTIES);
return propertiesImportException.getMessageKey();
}
}
return null;
}
示例10: addTestsFromStream
import java.util.Properties; //导入方法依赖的package包/类
public static void addTestsFromStream(InputStream in, List<String> list)
throws IOException {
Properties props = new Properties();
props.load(in);
for (Object obj: props.keySet()) {
list.add(obj.toString());
}
}
示例11: processProperties
import java.util.Properties; //导入方法依赖的package包/类
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
throws BeansException {
super.processProperties(beanFactoryToProcess, props);
for (Object key : props.keySet()) {
String keyStr = key.toString();
String value = props.getProperty(keyStr);
propertyMap.put(keyStr, value);
}
}
示例12: insertNameForComponent
import java.util.Properties; //导入方法依赖的package包/类
public OMapComponent insertNameForComponent(String name, Properties urp, Properties properties) {
OMapComponent omapComponent = new OMapComponent(this);
omapComponent.setName(name);
omapComponent.setCreated(Calendar.getInstance().getTime().getTime());
List<OMapRecognitionProperty> omapRProps = new ArrayList<OMapRecognitionProperty>();
for (Object rprop : urp.keySet()) {
OMapRecognitionProperty rproperty = new OMapRecognitionProperty();
rproperty.setName(rprop.toString());
rproperty.setMethod(IPropertyAccessor.METHOD_EQUALS);
rproperty.setValue(urp.getProperty(rprop.toString()));
omapRProps.add(rproperty);
}
omapComponent.setComponentRecognitionProperties(omapRProps);
List<OMapProperty> others = new ArrayList<OMapProperty>();
for (Object otherProp : properties.keySet()) {
String v = properties.getProperty(otherProp.toString());
if (v != null && !"".equals(v)) {
OMapProperty p = new OMapProperty();
p.setName(otherProp.toString());
p.setValue(v);
others.add(p);
}
}
omapComponent.setGeneralProperties(others);
OMapComponent existing = nameComponentMap.get(name);
if (existing == null) {
components.add(omapComponent);
nameComponentMap.put(name, omapComponent);
} else {
components.remove(existing);
components.add(omapComponent);
nameComponentMap.put(name, omapComponent);
}
return omapComponent;
}
示例13: logProperties
import java.util.Properties; //导入方法依赖的package包/类
public static void logProperties(Properties properties) {
System.out
.println("Starting WebService test with the following properties:");
for (Object key : properties.keySet()) {
System.out.println("\t" + key + "="
+ properties.getProperty((String) key));
}
System.out.println();
System.out
.println("If the environment specific properties are wrong, especially bes.https.url and glassfish.bes.domain");
System.out
.println("\tplease override them in oscm-devruntime/javares/local/<hostname>/test.properties !");
System.out.println();
}
示例14: loadPropertiesInTable
import java.util.Properties; //导入方法依赖的package包/类
public static void loadPropertiesInTable(Properties x, JTable table, String exculdeKey) {
((DefaultTableModel) table.getModel()).setRowCount(0);
if (x != null) {
for (Object key : x.keySet()) {
if (!exculdeKey.equals(key)) {
addValueinTable(table, key, (String) x.get(key.toString()));
}
}
}
}
示例15: readPotionColors
import java.util.Properties; //导入方法依赖的package包/类
private static int[] readPotionColors(Properties p_readPotionColors_0_, String p_readPotionColors_1_, String p_readPotionColors_2_, String p_readPotionColors_3_)
{
int[] aint = new int[getMaxPotionId()];
Arrays.fill((int[])aint, (int) - 1);
int i = 0;
for (Object s0 : p_readPotionColors_0_.keySet())
{
String s = (String) s0;
String s1 = p_readPotionColors_0_.getProperty(s);
if (s.startsWith(p_readPotionColors_2_))
{
int j = getPotionId(s);
int k = parseColor(s1);
if (j >= 0 && j < aint.length && k >= 0)
{
aint[j] = k;
++i;
}
else
{
warn("Invalid color: " + s + " = " + s1);
}
}
}
if (i <= 0)
{
return null;
}
else
{
dbg(p_readPotionColors_3_ + " colors: " + i);
return aint;
}
}