Java Code Examples for java.util.Properties.keySet()

The following are Jave code examples for showing how to use keySet() of the java.util.Properties class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: CreateBundle.java   View Source Code Vote up 6 votes
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;
}
 
Example 2
Project: fuck_zookeeper   File: ZooInspectorConnectionPropertiesDialog.java   View Source Code Vote up 6 votes
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);
                }
            }
        }
    }
}
 
Example 3
Project: hadoop   File: TestRestClientBindings.java   View Source Code Vote up 5 votes
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) {

  }
}
 
Example 4
Project: Backmemed   File: CustomColors.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 5
Project: Actitime-Framework   File: DriverManager.java   View Source Code Vote up 5 votes
/**
 * 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;
	}
}
 
Example 6
Project: BaseClient   File: CustomColors.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 7
Project: rmq4note   File: Configuration.java   View Source Code Vote up 5 votes
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);
    }
}
 
Example 8
Project: alfresco-repository   File: SolrFacetConfig.java   View Source Code Vote up 5 votes
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);
    }
}
 
Example 9
Project: oscm   File: OperatorServiceLocalBean.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 10
Project: whackpad   File: TestUtils.java   View Source Code Vote up 5 votes
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());
    }
}
 
Example 11
Project: aaden-pay   File: SimpleProperty.java   View Source Code Vote up 5 votes
@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);
	}
}
 
Example 12
Project: marathonv5   File: OMapContainer.java   View Source Code Vote up 5 votes
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;
}
 
Example 13
Project: oscm   File: ServiceFactory.java   View Source Code Vote up 5 votes
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();
}
 
Example 14
Project: Cognizant-Intelligent-Test-Scripter   File: PropUtils.java   View Source Code Vote up 5 votes
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()));
            }
        }
    }
}
 
Example 15
Project: Backmemed   File: CustomColors.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 16
Project: oscm   File: LdapSettingsManagementServiceBean.java   View Source Code Vote up 5 votes
public void resetOrganizationSettings(String orgId)
        throws ObjectNotFoundException {
    

    Organization organization = getOrganization(orgId);
    // first remove all existing settings
    Query query = ds
            .createNamedQuery("OrganizationSetting.removeAllForOrganization");
    query.setParameter("organization", organization);
    query.executeUpdate();

    Properties platformProps = getPlatformSettings();

    if (platformProps != null) {
        List<OrganizationSetting> settings = new ArrayList<OrganizationSetting>();
        for (Object e : platformProps.keySet()) {
            String key = (String) e;
            OrganizationSetting setting = createOrganizationSetting(
                    organization, key, "");
            settings.add(setting);
        }
        // now assign the settings to the organization
        // (may be empty if no properties provided)
        organization.setOrganizationSettings(settings);
    }

    
}
 
Example 17
Project: aliyun-maxcompute-data-collectors   File: OdpsImportJob.java   View Source Code Vote up 5 votes
private Map<String, OdpsType> getColTypeMap() {
  Map colTypeMap = Maps.newLinkedHashMap();
  Properties userMapping = options.getMapColumnOdps();
  String[] columnNames = getColumnNames();

  for(Object column : userMapping.keySet()) {
    boolean found = false;
    for(String c : columnNames) {
      if (c.equals(column)) {
        found = true;
        break;
      }
    }
    if (!found) {
      throw new IllegalArgumentException("No column by the name " + column
              + "found while importing data");
    }
  }
  for(String col: columnNames) {
    String userType = userMapping.getProperty(col);
    if(userType != null) {
      colTypeMap.put(col, OdpsType.valueOf(userType));
    } else {
      LOG.warn("Column " + col
              + " type not specified, defaulting to STRING.");
      colTypeMap.put(col, OdpsType.STRING);
    }
  }
  return colTypeMap;
}
 
Example 18
Project: jkami   File: MappingProperty.java   View Source Code Vote up 4 votes
private static void changeProperties(Properties mapping) {
    for (Object key : mapping.keySet()) {
        String s = key.toString();
        mappingEntity.put(s, mapping.getProperty(key.toString()));
    }
}
 
Example 19
Project: Backmemed   File: CustomColors.java   View Source Code Vote up 4 votes
private static float[][] readDyeColors(Properties p_readDyeColors_0_, String p_readDyeColors_1_, String p_readDyeColors_2_, String p_readDyeColors_3_)
{
    EnumDyeColor[] aenumdyecolor = EnumDyeColor.values();
    Map<String, EnumDyeColor> map = new HashMap();

    for (int i = 0; i < aenumdyecolor.length; ++i)
    {
        EnumDyeColor enumdyecolor = aenumdyecolor[i];
        map.put(enumdyecolor.getName(), enumdyecolor);
    }

    float[][] afloat1 = new float[aenumdyecolor.length][];
    int k = 0;

    for (Object s0 : p_readDyeColors_0_.keySet())
    {
    	String s = (String) s0;

        String s1 = p_readDyeColors_0_.getProperty(s);

        if (s.startsWith(p_readDyeColors_2_))
        {
            String s2 = StrUtils.removePrefix(s, p_readDyeColors_2_);

            if (s2.equals("lightBlue"))
            {
                s2 = "light_blue";
            }

            EnumDyeColor enumdyecolor1 = (EnumDyeColor)map.get(s2);
            int j = parseColor(s1);

            if (enumdyecolor1 != null && j >= 0)
            {
                float[] afloat = new float[] {(float)(j >> 16 & 255) / 255.0F, (float)(j >> 8 & 255) / 255.0F, (float)(j & 255) / 255.0F};
                afloat1[enumdyecolor1.ordinal()] = afloat;
                ++k;
            }
            else
            {
                warn("Invalid color: " + s + " = " + s1);
            }
        }
    }

    if (k <= 0)
    {
        return (float[][])null;
    }
    else
    {
        dbg(p_readDyeColors_3_ + " colors: " + k);
        return afloat1;
    }
}
 
Example 20
Project: BibliotecaPS   File: MysqlIO.java   View Source Code Vote up 4 votes
private void sendConnectionAttributes(Buffer buf, String enc, MySQLConnection conn) throws SQLException {
    String atts = conn.getConnectionAttributes();

    Buffer lb = new Buffer(100);
    try {

        Properties props = getConnectionAttributesAsProperties(atts);

        for (Object key : props.keySet()) {
            lb.writeLenString((String) key, enc, conn.getServerCharset(), null, conn.parserKnowsUnicode(), conn);
            lb.writeLenString(props.getProperty((String) key), enc, conn.getServerCharset(), null, conn.parserKnowsUnicode(), conn);
        }

    } catch (UnsupportedEncodingException e) {

    }

    buf.writeByte((byte) (lb.getPosition() - 4));
    buf.writeBytesNoNull(lb.getByteBuffer(), 4, lb.getBufLength() - 4);

}