本文整理匯總了Java中java.util.Properties.size方法的典型用法代碼示例。如果您正苦於以下問題:Java Properties.size方法的具體用法?Java Properties.size怎麽用?Java Properties.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Properties
的用法示例。
在下文中一共展示了Properties.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readMessages
import java.util.Properties; //導入方法依賴的package包/類
private static void readMessages ()
{
messages = new Properties ();
Enumeration fileList = msgFiles.elements ();
DataInputStream stream;
while (fileList.hasMoreElements ())
try
{
stream = FileLocator.locateLocaleSpecificFileInClassPath ((String)fileList.nextElement ());
messages.load (stream);
}
catch (IOException e)
{
}
if (messages.size () == 0)
messages.put (defaultKey, "Error reading Messages File.");
}
示例2: toString
import java.util.Properties; //導入方法依賴的package包/類
public static String toString(Properties p, String[] propOrder) {
StringBuffer sb = new StringBuffer();
if (p.size() > 1) {
sb.append("{");
}
char[] convertBuf = new char[1024];
for (int i = 0; i < propOrder.length; i++) {
sb.append(escape(p.getProperty(propOrder[i]), convertBuf));
if (i < propOrder.length - 1) {
sb.append(", ");
}
}
if (p.size() > 1) {
sb.append("}");
}
return sb.toString();
}
示例3: readParam
import java.util.Properties; //導入方法依賴的package包/類
private String readParam(Properties props, String paramName) {
String paramValue = null;
if (props.size() > 0) {
paramValue = props.getProperty(CLIENTTESTS_XRAY_PROPERTIES_PREFIX + paramName);
}
if (paramValue == null) {
paramValue = System.getProperty(CLIENTTESTS_XRAY_PROPERTIES_PREFIX + paramName);
}
if (paramValue == null) {
paramValue = System.getenv(CLIENTTESTS_XRAY_ENV_VAR_PREFIX + paramName.toUpperCase());
}
if (paramValue == null) {
failInit();
}
return paramValue;
}
示例4: propertiesToString
import java.util.Properties; //導入方法依賴的package包/類
/**
* Converts connection properties to a String to be passed to the mappers.
* @param properties JDBC connection parameters
* @return String to be passed to configuration
*/
protected static String propertiesToString(Properties properties) {
List<String> propertiesList = new ArrayList<String>(properties.size());
for(Entry<Object, Object> property : properties.entrySet()) {
String key = StringEscapeUtils.escapeCsv(property.getKey().toString());
if (key.equals(property.getKey().toString()) && key.contains("=")) {
key = "\"" + key + "\"";
}
String val = StringEscapeUtils.escapeCsv(property.getValue().toString());
if (val.equals(property.getValue().toString()) && val.contains("=")) {
val = "\"" + val + "\"";
}
propertiesList.add(StringEscapeUtils.escapeCsv(key + "=" + val));
}
return StringUtils.join(propertiesList, ',');
}
示例5: convert
import java.util.Properties; //導入方法依賴的package包/類
/**
* Convert Properties to a Map with String keys and String values.
*
* @param properties the properties object
* @return the equivalent {@code Map<String,String>}
*/
public static Map<String, String> convert(Properties properties) {
Map<String, String> result = new HashMap<>(properties.size());
for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
result.put(key, properties.getProperty(key));
}
return result;
}
示例6: createCacheClient
import java.util.Properties; //導入方法依賴的package包/類
public static void createCacheClient(Pool poolAttr, String regionName, Properties dsProperties,
Boolean addControlListener, Properties javaSystemProperties) throws Exception {
new CacheServerTestUtil().createCache(dsProperties);
IgnoredException.addIgnoredException("java.net.ConnectException||java.net.SocketException");
if (javaSystemProperties != null && javaSystemProperties.size() > 0) {
Enumeration e = javaSystemProperties.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
System.setProperty(key, javaSystemProperties.getProperty(key));
}
}
PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
pf.init(poolAttr);
PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(p.getName());
if (addControlListener.booleanValue()) {
factory.addCacheListener(new ControlListener());
}
RegionAttributes attrs = factory.create();
cache.createRegion(regionName, attrs);
pool = p;
}
示例7: createCacheClient
import java.util.Properties; //導入方法依賴的package包/類
public static void createCacheClient(Pool poolAttr, String regionName,
Properties dsProperties, Boolean addControlListener, Properties javaSystemProperties) throws Exception {
new CacheServerTestUtil("temp").createCache(dsProperties);
addExpectedException("java.net.ConnectException||java.net.SocketException");
if (javaSystemProperties != null && javaSystemProperties.size() > 0) {
Enumeration e = javaSystemProperties.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
System.setProperty(key, javaSystemProperties.getProperty(key));
}
}
PoolFactoryImpl pf = (PoolFactoryImpl)PoolManager.createFactory();
pf.init(poolAttr);
PoolImpl p = (PoolImpl)pf.create("CacheServerTestUtil");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(p.getName());
if (addControlListener.booleanValue()) {
factory.addCacheListener(new ControlListener());
}
RegionAttributes attrs = factory.create();
cache.createRegion(regionName, attrs);
pool = p;
}
示例8: createQueryParameters
import java.util.Properties; //導入方法依賴的package包/類
public static List<NameValuePair> createQueryParameters(Properties queryParams){
if (queryParams == null || queryParams.size() == 0) {
return Collections.EMPTY_LIST;
}
List<NameValuePair> params = new ArrayList<NameValuePair>();
for (String propName : queryParams.stringPropertyNames()) {
params.add(new BasicNameValuePair(propName, queryParams.getProperty(propName)));
}
return params;
}
示例9: parseRules
import java.util.Properties; //導入方法依賴的package包/類
private RandomMobsRule[] parseRules(Properties p_parseRules_1_, ResourceLocation p_parseRules_2_, ConnectedParser p_parseRules_3_)
{
List list = new ArrayList();
int i = p_parseRules_1_.size();
for (int j = 0; j < i; ++j)
{
int k = j + 1;
String s = p_parseRules_1_.getProperty("skins." + k);
if (s != null)
{
int[] aint = p_parseRules_3_.parseIntList(s);
int[] aint1 = p_parseRules_3_.parseIntList(p_parseRules_1_.getProperty("weights." + k));
Biome[] abiome = p_parseRules_3_.parseBiomes(p_parseRules_1_.getProperty("biomes." + k));
RangeListInt rangelistint = p_parseRules_3_.parseRangeListInt(p_parseRules_1_.getProperty("heights." + k));
if (rangelistint == null)
{
rangelistint = this.parseMinMaxHeight(p_parseRules_1_, k);
}
RandomMobsRule randommobsrule = new RandomMobsRule(p_parseRules_2_, aint, aint1, abiome, rangelistint);
list.add(randommobsrule);
}
}
RandomMobsRule[] arandommobsrule = (RandomMobsRule[])((RandomMobsRule[])list.toArray(new RandomMobsRule[list.size()]));
return arandommobsrule;
}
示例10: toArray
import java.util.Properties; //導入方法依賴的package包/類
@TargetApi(9)
public static String toArray(Properties properties) {
if (properties != null && properties.size() > 0) {
String[] result = new String[properties.size()];
int index = 0;
properties.toString();
String key;
for (Iterator i$ = properties.stringPropertyNames().iterator(); i$.hasNext(); result[index++] = key + properties.getProperty(key)) {
key = (String) i$.next();
}
}
return null;
}
示例11: unsetJavaSystemProperties
import java.util.Properties; //導入方法依賴的package包/類
public static void unsetJavaSystemProperties(Properties javaSystemProperties) {
if (javaSystemProperties != null && javaSystemProperties.size() > 0) {
Enumeration e = javaSystemProperties.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
System.clearProperty(key);
}
}
}
示例12: createInitialContext
import java.util.Properties; //導入方法依賴的package包/類
/**
* Create a new JNDI initial context. Invoked by {@link #getContext}.
* <p>The default implementation use this template's environment settings.
* Can be subclassed for custom contexts, e.g. for testing.
* @return the initial Context instance
* @throws NamingException in case of initialization errors
*/
protected Context createInitialContext() throws NamingException {
Hashtable<?, ?> icEnv = null;
Properties env = getEnvironment();
if (env != null) {
icEnv = new Hashtable<Object, Object>(env.size());
CollectionUtils.mergePropertiesIntoMap(env, icEnv);
}
return new InitialContext(icEnv);
}
示例13: resolveInterfaceMappings
import java.util.Properties; //導入方法依賴的package包/類
/**
* Resolve the given interface mappings, turning class names into Class objects.
* @param mappings the specified interface mappings
* @return the resolved interface mappings (with Class objects as values)
*/
private Map<String, Class<?>[]> resolveInterfaceMappings(Properties mappings) {
Map<String, Class<?>[]> resolvedMappings = new HashMap<String, Class<?>[]>(mappings.size());
for (Enumeration<?> en = mappings.propertyNames(); en.hasMoreElements();) {
String beanKey = (String) en.nextElement();
String[] classNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
Class<?>[] classes = resolveClassNames(classNames, beanKey);
resolvedMappings.put(beanKey, classes);
}
return resolvedMappings;
}
示例14: convert
import java.util.Properties; //導入方法依賴的package包/類
/**
* Convert Properties to a Map with String keys and values. Entries whose key or value is not a String are omitted.
*/
public static Map<String, String> convert(Properties properties) {
Map<String, String> result = new HashMap<>(properties.size());
for (String key : properties.stringPropertyNames()) {
result.put(key, properties.getProperty(key));
}
return result;
}
示例15: makeConnection
import java.util.Properties; //導入方法依賴的package包/類
/**
* Create a connection to the database; usually used only from within
* getConnection(), which enforces a singleton guarantee around the
* Connection object.
*/
protected Connection makeConnection() throws SQLException, Exception {
Connection connection;
String driverClass = getDriverClass();
try {
Class.forName(driverClass);
} catch (ClassNotFoundException cnfe) {
throw new RuntimeException("Could not load db driver class: "
+ driverClass);
}
String username = options.getString(DBConfiguration.DataSourceInfo.USERNAME_PROPERTY);
String password = options.getString(DBConfiguration.DataSourceInfo.PASSWORD_PROPERTY);
// String connectString = options.getString(DBConfiguration.DataSourceInfo.URL_PROPERTY_READ_ONLY);
// if(!readOnly){
// connectString = (String)(options.get(DBConfiguration.DataSourceInfo.URL_PROPERTY_READ_WRITE));
// }
String connectionParamsStr = options.getString(DBConfiguration.CONNECTION_PARAMS_PROPERTY);
Properties connectionParams = DBConfiguration.propertiesFromString(connectionParamsStr);
if (connectionParams != null && connectionParams.size() > 0) {
LOG.debug("User specified connection params. "
+ "Using properties specific API for making connection.");
Properties props = new Properties();
if (username != null) {
props.put("user", username);
}
if (password != null) {
props.put("password", password);
}
props.putAll(connectionParams);
connection = DriverManager.getConnection(this.conString, props);
} else {
LOG.debug("No connection paramenters specified. "
+ "Using regular API for making connection.");
if (username == null) {
connection = DriverManager.getConnection(this.conString);
} else {
connection = DriverManager.getConnection(
this.conString, username, password);
}
}
// We only use this for metadata queries. Loosest semantics are okay.
connection.setTransactionIsolation(getMetadataIsolationLevel());
connection.setAutoCommit(false);
return connection;
}