public void testTranslationKeyExistence() throws IOException { // use English version as the reference: final File englishFile = getEnglishTranslationFile(); final Properties enProps = new Properties(); enProps.load(new FileInputStream(englishFile)); final Set<Object> englishKeys = enProps.keySet(); for (Language lang : Language.REAL_LANGUAGES) { if (lang.getShortName().equals("en")) { continue; } final Properties langProps = new Properties(); final File langFile = getTranslationFile(lang); if (!langFile.exists()) { continue; } try (FileInputStream stream = new FileInputStream(langFile)) { langProps.load(stream); final Set<Object> langKeys = langProps.keySet(); for (Object englishKey : englishKeys) { if (!langKeys.contains(englishKey)) { System.err.println("***** No key '" + englishKey + "' in file " + langFile); } } } } }
/** This method is responsible for undeploying it. */ public void unDeploy() throws EARException { try { Properties fileProperties = readProperties(filesPath); Properties contextProperties = readProperties(contextFilePath); // remove context entries for (Object key : contextProperties.keySet()) { String context = contextProperties.getProperty(key.toString()); ContextClassLoaderLookup.getInstance().removeContext(context); } // remove files for (Object key : fileProperties.keySet()) { File file = new File(fileProperties.getProperty(key.toString())); file.delete(); } // remove the configuration files filesPath.delete(); contextFilePath.delete(); } catch (Exception ex) { log.error("Failed to undeploy the ear because :" + ex.getMessage(), ex); throw new EARException("Failed to undeploy the ear because :" + ex.getMessage(), ex); } }
// public SessionFactory newSessionFactory(Configuration config) throws HibernateException { public Configuration newConfiguration() throws HibernateException { Configuration config = super.newConfiguration(); log.debug("Configuring hibernate sessionFactory properties"); Properties moduleProperties = Context.getConfigProperties(); // override or initialize config properties with module-provided ones for (Object key : moduleProperties.keySet()) { String prop = (String) key; String value = (String) moduleProperties.get(key); log.trace("Setting module property: " + prop + ":" + value); config.setProperty(prop, value); if (!prop.startsWith("hibernate")) config.setProperty("hibernate." + prop, value); } Properties properties = Context.getRuntimeProperties(); // loop over runtime properties and override each in the configuration for (Object key : properties.keySet()) { String prop = (String) key; String value = (String) properties.get(key); log.trace("Setting property: " + prop + ":" + value); config.setProperty(prop, value); if (!prop.startsWith("hibernate")) config.setProperty("hibernate." + prop, value); } // load in the default hibernate properties try { InputStream propertyStream = ConfigHelper.getResourceAsStream("/hibernate.default.properties"); Properties props = new Properties(); OpenmrsUtil.loadProperties(props, propertyStream); propertyStream.close(); // Only load in the default properties if they don't exist config.mergeProperties(props); } catch (IOException e) { log.fatal("Unable to load default hibernate properties", e); } log.debug( "Setting global Hibernate Session Interceptor for SessionFactory, Interceptor: " + chainingInterceptor); // make sure all autowired interceptors are put onto our chaining interceptor // sort on the keys so that the devs/modules have some sort of control over the order of the // interceptors List<String> keys = new ArrayList<String>(interceptors.keySet()); Collections.sort(keys); for (String key : keys) { chainingInterceptor.addInterceptor(interceptors.get(key)); } config.setInterceptor(chainingInterceptor); return config; }
private Properties merge(Properties include, Properties exclude) { Set<Object> in = new HashSet<Object>(include.keySet()); in.addAll(exclude.keySet()); Properties merged = new Properties(); for (Object key : in) { if (include.containsKey(key)) { merged.put(key, include.get(key)); } else if (exclude.containsKey(key)) { merged.put(key, exclude.get(key)); } } return merged; }
private void removeProperties(String propertiesFilePath, String... propertiesName) { if (propertiesName.length > 0) { Properties properties = CommandsUtils.readProperties(propertiesFilePath); if (properties != null && !properties.isEmpty()) { for (String propertieName : propertiesName) { if (properties.keySet().contains(propertieName)) { properties.remove(propertieName); } } FileOutputStream fos = null; try { fos = new FileOutputStream(propertiesFilePath); properties.store(fos, ""); } catch (FileNotFoundException e) { // nothing to do } catch (IOException e) { // nothing to do } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { // nothing to do } } } } } }
public Properties getDBPameterProperties(String connectionStr) { Properties paramProperties = new Properties(); if (connectionStr != null) { String matchSubStr = connectionStr.substring(0, 8); Set<Object> s = PROP.keySet(); Iterator<Object> it = s.iterator(); while (it.hasNext()) { String id = (String) it.next(); String value = PROP.getProperty(id); if (value.contains(matchSubStr)) { paramProperties.setProperty(PluginConstant.DBTYPE_PROPERTY, id); MessageFormat mf = new MessageFormat(value); Object[] parseResult = mf.parse(connectionStr, new ParsePosition(0)); if (parseResult != null) { if (parseResult[0] != null) { paramProperties.setProperty( PluginConstant.HOSTNAME_PROPERTY, (String) parseResult[0]); } if (parseResult[1] != null) { paramProperties.setProperty(PluginConstant.PORT_PROPERTY, (String) parseResult[1]); } break; } } } } else { paramProperties.setProperty(PluginConstant.DBTYPE_PROPERTY, ""); paramProperties.setProperty(PluginConstant.HOSTNAME_PROPERTY, ""); paramProperties.setProperty(PluginConstant.PORT_PROPERTY, ""); } return paramProperties; }
/** * Return a list of resource model configuration * * @param props properties * @return List of Maps, each map containing "type": String, "props":Properties */ public static List<Map<String, Object>> listResourceModelConfigurations(final Properties props) { final ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); int i = 1; boolean done = false; while (!done) { final String prefix = RESOURCES_SOURCE_PROP_PREFIX + "." + i; if (props.containsKey(prefix + ".type")) { final String providerType = props.getProperty(prefix + ".type"); final Properties configProps = new Properties(); final int len = (prefix + ".config.").length(); for (final Object o : props.keySet()) { final String key = (String) o; if (key.startsWith(prefix + ".config.")) { configProps.setProperty(key.substring(len), props.getProperty(key)); } } final HashMap<String, Object> map = new HashMap<String, Object>(); map.put("type", providerType); map.put("props", configProps); list.add(map); } else { done = true; } i++; } return list; }
protected void registerFromProperties(Properties properties) { if (properties != null) { class2ElementRegistry.clear(); // for ( String keyOrClassName: properties.keySet() ) { for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) { String keyOrClassName = (String) iter.next(); String element = (String) properties.get(keyOrClassName); Object key = keyOrClassName; try { key = Class.forName(keyOrClassName); } catch (ClassNotFoundException e) { } if (handlerClass == null) { try { register(key, Class.forName(element)); } catch (ClassNotFoundException e) { e.printStackTrace(); } } else { register(key, element); } } } }
private void initControls() { IConnectionProfile profile = getConnectionProfile(); Properties props = profile.getBaseProperties(); if (null != props.get(IWSProfileConstants.PARAMETER_MAP) & !props.get(IWSProfileConstants.PARAMETER_MAP).equals(StringUtilities.EMPTY_STRING)) { this.parameterMap = ((Map) props.get(IWSProfileConstants.PARAMETER_MAP)); } if (null != props.get(ICredentialsCommon.USERNAME_PROP_ID)) { usernameText.setText((String) props.get(ICredentialsCommon.USERNAME_PROP_ID)); } if (null != props.get(ICredentialsCommon.PASSWORD_PROP_ID)) { passwordText.setText((String) props.get(ICredentialsCommon.PASSWORD_PROP_ID)); } String url = ConnectionInfoHelper.readEndPointProperty(props); if (null != url) { urlText.setText(url); } if (null != props.get(ICredentialsCommon.SECURITY_TYPE_ID)) { securityText.setText((String) props.get(ICredentialsCommon.SECURITY_TYPE_ID)); } for (Object key : props.keySet()) { String keyStr = (String) key; if (ICredentialsCommon.PASSWORD_PROP_ID.equalsIgnoreCase(keyStr) || ICredentialsCommon.SECURITY_TYPE_ID.equalsIgnoreCase(keyStr) || ICredentialsCommon.USERNAME_PROP_ID.equalsIgnoreCase(keyStr) || IWSProfileConstants.END_POINT_URI_PROP_ID.equalsIgnoreCase(keyStr)) { // do nothing; } else { extraProperties.put(key, props.get(key)); } } }
protected Map<String, String> getMetadata(ZipReader zipReader) throws KBArticleImportException { InputStream inputStream = null; try { inputStream = zipReader.getEntryAsInputStream(".METADATA"); if (inputStream == null) { return Collections.emptyMap(); } Properties properties = new Properties(); properties.load(inputStream); Map<String, String> metadata = new HashMap<String, String>(properties.size()); for (Object key : properties.keySet()) { Object value = properties.get(key); if (value != null) { metadata.put(key.toString(), value.toString()); } } return metadata; } catch (IOException ioe) { throw new KBArticleImportException(ioe); } finally { StreamUtil.cleanUp(inputStream); } }
private static DeviceMacReferenceMap readDeviceMacReferenceMap(final String fileName) throws IOException { final DeviceMacReferenceMap deviceMacReferenceMap; final File referenceToMacMapPropertiesFile = new File(fileName); if (!referenceToMacMapPropertiesFile.exists()) { log.error("Reference file {} does not exist!"); System.exit(EXIT_CODE_REFERENCE_FILE_NOT_EXISTING); } else if (!referenceToMacMapPropertiesFile.canRead()) { log.error("Reference file {} is not readable!"); System.exit(EXIT_CODE_REFERENCE_FILE_NOT_READABLE); } else if (referenceToMacMapPropertiesFile.isDirectory()) { log.error("Reference file {} is a directory!"); System.exit(EXIT_CODE_REFERENCE_FILE_IS_DIRECTORY); } Properties properties = new Properties(); properties.load(new FileInputStream(referenceToMacMapPropertiesFile)); deviceMacReferenceMap = new DeviceMacReferenceMap(); for (Object key : properties.keySet()) { final String value = (String) properties.get(key); deviceMacReferenceMap.put((String) key, new MacAddress(value)); } return deviceMacReferenceMap; }
/** 读取配置文件中的全局参数的配置,存到缓存中 */ private static void initProperties() { try { logger.debug("加载属性配置文件开始!"); String propUrl = getSysPath() + "config.properties"; logger.debug("系统全局参数的路径是:" + propUrl); FileInputStream fis = new FileInputStream(propUrl); // 属性文件流 Properties prop = new Properties(); // 属性集合对象 prop.load(fis); // 将属性文件流装载到Properties对象中 logger.debug("属性的长度:" + prop.size()); Map<String, String> paramMap = new HashMap<String, String>(); Iterator<Object> it = prop.keySet().iterator(); while (it.hasNext()) { String key = (String) (it.next()); String value = prop.getProperty(key); logger.debug(key + "=" + value); // global.ip=192.168.0.242的格式 // map.put(key, prop.getProperty(key)); paramMap.put(key, value); } logger.debug("加载属性配置文件结束!"); setConfigMap(paramMap); } catch (FileNotFoundException e) { logger.error("文件未找到!"); e.printStackTrace(); } catch (IOException e) { logger.error("读取文件的时候异常!"); e.printStackTrace(); } catch (Exception e) { logger.error("其它异常!"); e.printStackTrace(); } }
@SuppressWarnings("null") KernelPropertiesImpl() { final Properties sysProps = System.getProperties(); final File propsFile = new File(sysProps.getProperty("ami.kernel.properties", "/etc/ami/kernel.properties")); configDir = propsFile.getParentFile(); final Properties properties = new Properties(); try { final FileReader reader = new FileReader(propsFile); try { properties.load(reader); } finally { reader.close(); } } catch (final FileNotFoundException e) { throw new FoobarError("Kernel properties file (" + propsFile + ") not found", e); } catch (final IOException e) { throw new FoobarError("Unable to read kernel properties file (" + propsFile + ")", e); } final Map<String, String> map = new HashMap<String, String>(); for (final Object key : properties.keySet()) { if (key instanceof String) { final Object value = properties.get(key); if (value instanceof String) map.put((String) key, (String) value); } } this.properties = Collections.unmodifiableMap(map); }
public static final void loadBuildingEnemiesData(Context c) { Properties props = DataStore.loadResources(c, ResourceUtil.getRID(R.raw.class, "bd_enemies")); Set<Object> keys = props.keySet(); for (Object key : keys) { // Log.e("TTTT","TTTT key: " + key); String bd_id_lane[] = key.toString().split("-"); if (bd_id_lane.length != 2) continue; String bd_id = bd_id_lane[0]; int lane = Integer.parseInt(bd_id_lane[1]); String value = props.getProperty(key.toString()); BuildingEnemiesData bed = new BuildingEnemiesData(bd_id, value); BuildingEnemiesData[] bd_enemies = buildingEnemiesDataMap.get(bd_id); if (bd_enemies == null) { bd_enemies = new BuildingEnemiesData[5]; buildingEnemiesDataMap.put(bd_id, bd_enemies); } bd_enemies[lane] = bed; } }
private void addPropertiesToProject(Project project) { Properties projectProperties = new Properties(); File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES); LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile); if (projectPropertiesFile.isFile()) { projectProperties = GUtil.loadProperties(projectPropertiesFile); LOGGER.debug( "Adding project properties (if not overwritten by user properties): {}", projectProperties.keySet()); } else { LOGGER.debug("project property file does not exists. We continue!"); } Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties)); ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties(); for (Map.Entry<String, String> entry : mergedProperties.entrySet()) { if (project.hasProperty(entry.getKey())) { project.setProperty(entry.getKey(), entry.getValue()); } else { extraProperties.set(entry.getKey(), entry.getValue()); } } }
/* * (non-Javadoc) * * @see org.ow2.play.service.registry.api.Registry#load(java.lang.String) */ @Override @WebMethod public void load(String url) throws RegistryException { if (logger.isLoggable(Level.FINE)) { logger.fine(String.format("Load from url %s", url)); } if (url == null) { throw new RegistryException("Can not load properties from null value"); } // This is the only time we initialize if not already done... if (!initialized) { init(); } Properties props = new Properties(); try { URL u = new URL(url); props.load(u.openStream()); for (Object key : props.keySet()) { String k = key.toString(); Object v = props.getProperty(k); if (v != null) { this.put(k, v.toString()); } } } catch (Exception e) { logger.warning(e.getMessage()); throw new RegistryException(e); } }
public static Map<String, Properties> loadDBConfig(Properties p) { Map<String, Properties> dbConfigs = Maps.newHashMapWithExpectedSize(1); for (Object o : p.keySet()) { String _key = String.valueOf(o); String value = p.getProperty(_key); if (StringUtils.startsWithIgnoreCase(_key, "db")) { int last_idx = _key.lastIndexOf(StringPool.DOT); if (last_idx > 2) { // like db.second.url String config_name = _key.substring(_key.indexOf(StringPool.DOT) + 1, last_idx); if (logger.isDebugEnabled()) { logger.debug("the db config is {}", config_name); } Properties db_config_props = dbConfigs.get(config_name); if (db_config_props == null) { db_config_props = new Properties(); dbConfigs.put(config_name, db_config_props); } _key = _key.replace(StringPool.DOT + config_name, StringPool.EMPTY); db_config_props.put(_key, value); } else { Properties db_main_props = dbConfigs.get("main"); if (db_main_props == null) { db_main_props = new Properties(); dbConfigs.put("main", db_main_props); } db_main_props.put(_key, value); } } } return dbConfigs; }
public PropertyPanel(String title, Properties properties) { super(); setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), title)); setLayout(new GridLayout(1, 1, 10, 10)); JTextArea area = new JTextArea(Math.min(properties.size(), 20), 40); area.setEditable(false); area.setOpaque(false); area.setTabSize(16); Iterator iter = properties.keySet().iterator(); if (iter.hasNext()) { // first line String key = (String) iter.next(); area.append(key); area.append("\t"); area.append(properties.getProperty(key)); } while (iter.hasNext()) { // remaining lines area.append("\n"); String key = (String) iter.next(); area.append(key); area.append("\t"); area.append(properties.getProperty(key)); } add(new JScrollPane(area)); }
public static void removeGroupProperties(String id, Properties properties) { for (Object key : properties.keySet()) { if (key.toString().startsWith(id + ".")) { properties.remove(key); } } }
private ModuleOptionsMetadata makeSimpleModuleOptions(Properties props) { SimpleModuleOptionsMetadata result = new SimpleModuleOptionsMetadata(); for (Object key : props.keySet()) { if (key instanceof String) { String propName = (String) key; Matcher matcher = DESCRIPTION_KEY_PATTERN.matcher(propName); if (!matcher.matches()) { continue; } String optionName = matcher.group(1); String description = props.getProperty(propName); Object defaultValue = props.getProperty(String.format("options.%s.default", optionName)); String type = props.getProperty(String.format("options.%s.type", optionName)); Class<?> clazz = null; if (type != null) { if (SHORT_CLASSNAMES.containsKey(type)) { clazz = SHORT_CLASSNAMES.get(type); } else { try { clazz = Class.forName(type); } catch (ClassNotFoundException e) { throw new IllegalStateException( "Can't find class used for type of option '" + optionName + "': " + type); } } } ModuleOption moduleOption = new ModuleOption(optionName, description) .withDefaultValue(defaultValue) .withType(clazz); result.add(moduleOption); } } return result; }
public static Properties getSystemProperties() { Properties res = ourSystemProperties; if (res == null) { res = new Properties(); res.putAll(System.getProperties()); for (Iterator<Object> itr = res.keySet().iterator(); itr.hasNext(); ) { final String propertyName = itr.next().toString(); if (propertyName.startsWith("idea.")) { itr.remove(); } } for (Map.Entry<String, String> entry : System.getenv().entrySet()) { String key = entry.getKey(); if (key.startsWith("=")) { continue; } if (SystemInfo.isWindows) { key = key.toUpperCase(); } res.setProperty("env." + key, entry.getValue()); } ourSystemProperties = res; } return res; }
/** * Transform JNDI properties passed in the form <tt>hibernate.jndi.*</tt> to the format accepted * by <tt>InitialContext</tt> by triming the leading "<tt>hibernate.jndi</tt>". */ public static Properties getJndiProperties(Properties properties) { HashSet specialProps = new HashSet(); specialProps.add(Environment.JNDI_CLASS); specialProps.add(Environment.JNDI_URL); Iterator iter = properties.keySet().iterator(); Properties result = new Properties(); while (iter.hasNext()) { String prop = (String) iter.next(); if (prop.indexOf(Environment.JNDI_PREFIX) > -1 && !specialProps.contains(prop)) { result.setProperty( prop.substring(Environment.JNDI_PREFIX.length() + 1), properties.getProperty(prop)); } } String jndiClass = properties.getProperty(Environment.JNDI_CLASS); String jndiURL = properties.getProperty(Environment.JNDI_URL); // we want to be able to just use the defaults, // if JNDI environment properties are not supplied // so don't put null in anywhere if (jndiClass != null) result.put(Context.INITIAL_CONTEXT_FACTORY, jndiClass); if (jndiURL != null) result.put(Context.PROVIDER_URL, jndiURL); return result; }
@Override protected void processProperties( ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { /* * 覆盖父类的方法,截取解析到的参数值,放入自定义的map中,供外部调用。 */ // build the properties we need Map<String, String> tempProps = new HashMap<String, String>(props.size()); PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX); for (Object keyObj : props.keySet()) { String key = String.valueOf(keyObj); String value = props.getProperty(key); if (StringUtils.hasText(value) && value.startsWith(SECRET_PREFIX)) { try { String tmp = CryptoUtil.decryptApi(value.substring(SECRET_PREFIX.length())); value = tmp; } catch (Exception e) { e.printStackTrace(); } } value = helper.replacePlaceholders(value, props); tempProps.put(key, value); props.setProperty(key, value); } // 这个map只读 this.resolvedProps = Collections.unmodifiableMap(tempProps); PropsUtil.setProperties(resolvedProps); // 必须放在后面执行, 否则在xml配置属性的时候会不可用 super.processProperties(beanFactoryToProcess, props); }
public ConnectionlessQueryServicesImpl( QueryServices services, ConnectionInfo connInfo, Properties info) { super(services); userName = connInfo.getPrincipal(); metaData = newEmptyMetaData(); // Use KeyValueBuilder that builds real KeyValues, as our test utils require this this.kvBuilder = GenericKeyValueBuilder.INSTANCE; Configuration config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); for (Entry<String, String> entry : services.getProps()) { config.set(entry.getKey(), entry.getValue()); } if (info != null) { for (Object key : info.keySet()) { config.set((String) key, info.getProperty((String) key)); } } for (Entry<String, String> entry : connInfo.asProps()) { config.set(entry.getKey(), entry.getValue()); } // Without making a copy of the configuration we cons up, we lose some of our properties // on the server side during testing. config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config); TransactionManager txnManager = new TransactionManager(config); this.txSystemClient = new InMemoryTxSystemClient(txnManager); }
@SuppressWarnings("unchecked") private void loadProperties() { try { log.debug("packName=" + packName); log.debug("fileName=" + fileName); FileInputStream fileInput = new FileInputStream(getFilePath(packName, fileName)); prop.load(fileInput); String entityUp = prop.getProperty("Entity"); log.debug("entityUp:" + entityUp); if (entityUp == null || entityUp.trim().equals("")) { log.warn("Entity not specified, exit!"); return; } String entityLow = entityUp.substring(0, 1).toLowerCase() + entityUp.substring(1); log.debug("entityLow:" + entityLow); prop.put("entity", entityLow); if (log.isDebugEnabled()) { Set ps = prop.keySet(); for (Object o : ps) { log.debug(o + "=" + prop.get(o)); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public static void setSystemProperties(ContextAware contextAware, Properties props) { for (Object o : props.keySet()) { String key = (String) o; String value = props.getProperty(key); setSystemProperty(contextAware, key, value); } }
/** @param args */ public static void main(String[] args) { try { InputStream in = SupportDBUrlStore.class.getResourceAsStream("dburl.properties"); // $NON-NLS-1$ PROP.load(in); in.close(); Set<?> s = PROP.keySet(); // System.out.println(s.toString()); Iterator<?> it = s.iterator(); while (it.hasNext()) { String id = (String) it.next(); String value = PROP.getProperty(id); System.out.println("\n" + id + "-------" + value); // $NON-NLS-1$ //$NON-NLS-2$ // Object[] arguments = { "10.78.23.23", "33456", "testDB" }; Object[] arguments = { "{hostname}", "{port}", "{dbname}", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ System.out.println(MessageFormat.format(value, arguments)); } // System.out.println(p.toString()); } catch (Exception e) { log.error(e, e); } }
private Properties getModelConnectionProperties(ModelResource mr) { try { if (ModelIdentifier.isRelationalSourceModel(mr)) { IConnectionInfoProvider provider = null; try { provider = getProvider(mr); } catch (Exception e) { // If provider throws exception its OK because some models may not have connection info. } if (provider != null) { Properties properties = provider.getProfileProperties(mr); // ConnectionProperties(mr); Properties p2 = provider.getConnectionProperties(mr); String translatorName = provider.getTranslatorName(mr); for (Object key : p2.keySet()) { properties.put(key, p2.get(key)); } if (translatorName != null) { properties.put(getString("translatorKey"), translatorName); // $NON-NLS-1$ } if (properties != null && !properties.isEmpty()) { return properties; } } } } catch (CoreException e) { DatatoolsUiConstants.UTIL.log(e); } return null; }
private static String propsToString(Properties props) { StringBuilder builder = new StringBuilder(); for (Object key : props.keySet()) { builder.append(key).append("=").append(props.getProperty(key.toString())).append("\n"); } return builder.toString(); }
private String createParameterString() { // put required parameters for (OauthConstants constant : OauthConstants.values()) { String key = OAuth.percentEncode(constant.name()); String value = OAuth.percentEncode(properties.getProperty(constant.name())); if (constant.equals(OauthConstants.oauth_nonce)) { value = OAuth.percentEncode(nonce); } if (constant.equals(OauthConstants.oauth_timestamp)) { value = OAuth.percentEncode(String.valueOf(timestamp)); } parameterMap.put(key, value); } // put optional parameters for (Object key_ : optionalParameters.keySet()) { String keyStr = (String) key_; String key = OAuth.percentEncode(keyStr); String value = OAuth.percentEncode(optionalParameters.get(keyStr).toString()); parameterMap.put(key, value); } StringBuilder builder = new StringBuilder(); for (String s : parameterMap.keySet()) { builder.append(s).append('=').append(parameterMap.get(s)).append("&"); } builder.setLength(builder.lastIndexOf("&")); return builder.toString(); }