List of usage examples for java.util Properties get
@Override
public Object get(Object key)
From source file:com.glaf.core.util.CalendarUtils.java
public static void initWorkDayEnv() { java.util.Properties p = loadCalendarProperties(); String morning = "00:00~00:00"; if (p.get("morning") != null) { morning = (String) p.get("morning"); }/* w ww . j a va 2 s .c o m*/ if (p.get("mode") != null) { mode = Integer.parseInt((String) p.get("mode")); } String marr[] = morning.split("~"); String submarr1[] = marr[0].split(":"); startTime = Integer.parseInt(submarr1[0] + submarr1[1]); String submarr2[] = marr[1].split(":"); endTime = Integer.parseInt(submarr2[0] + submarr2[1]); }
From source file:com.glaf.core.util.CalendarUtils.java
/** * ???? 1?2?-1??//from w w w . j a va2 s . c o m * * @return */ public static String getDutyCalendar(Date date) { String dutyCalendar = "-1"; String morning = ""; String evening = ""; Properties props = loadCalendarProperties(); if (props != null) { morning = (String) props.get("morning"); evening = (String) props.get("evening"); } if (StringUtils.isEmpty(morning)) { morning = "00:00~00:00"; } if (StringUtils.isEmpty(evening)) { evening = "00:00~00:00"; } boolean rst = isDutyCalendar(date, morning); if (rst) { dutyCalendar = "1"; } else { rst = isDutyCalendar(date, evening); if (rst) { dutyCalendar = "2"; } } return dutyCalendar; }
From source file:com.cssweb.android.common.CssIniFile.java
public static String loadIni(Context context, int parmInt, String key) { String str = null;//from w w w. ja va 2 s .c om Properties properties = new Properties(); try { FileInputStream stream = context.openFileInput(GetFileName(parmInt)); properties.load(stream); Object obj = properties.get(key); if (obj != null) str = obj.toString(); stream.close(); } catch (FileNotFoundException e) { } catch (IOException e) { } return str; }
From source file:com.google.api.ads.adwords.jaxws.extensions.AwReporting.java
/** * Initialize the application context, adding the properties configuration file depending on the * specified path./* ww w . j a va 2s. c o m*/ * * @param propertiesPath the path to the file. * @return the resource loaded from the properties file. * @throws IOException error opening the properties file. */ private static Properties initApplicationContextAndProperties(String propertiesPath) throws IOException { Resource resource = new ClassPathResource(propertiesPath); if (!resource.exists()) { resource = new FileSystemResource(propertiesPath); } LOGGER.trace("Innitializing Spring application context."); DynamicPropertyPlaceholderConfigurer.setDynamicResource(resource); Properties properties = PropertiesLoaderUtils.loadProperties(resource); String dbType = (String) properties.get(AW_REPORT_MODEL_DB_TYPE); if (dbType != null && dbType.equals(DataBaseType.MONGODB.name())) { LOGGER.debug("Using MONGO DB configuration properties."); appCtx = new ClassPathXmlApplicationContext("classpath:aw-reporting-mongodb-beans.xml"); } else { LOGGER.debug("Using SQL DB configuration properties."); appCtx = new ClassPathXmlApplicationContext("classpath:aw-reporting-sql-beans.xml"); } return properties; }
From source file:com.digitalgeneralists.assurance.Application.java
static void installDb(InputStream propertiesFileStream, InputStream dbScriptStream) throws IOException, SQLException { Logger logger = Logger.getLogger(Application.class); Connection dbConnection = null; ResultSet rs = null;/*from www . ja v a 2 s . c om*/ try { Properties properties = new Properties(); if (propertiesFileStream != null) { properties.load(propertiesFileStream); } else { throw new FileNotFoundException("The database properties file could not be loaded."); } String dbUrl = (String) properties.get("jdbc.url"); String dbUser = (String) properties.get("jdbc.username"); String dbPassword = (String) properties.get("jdbc.password"); dbConnection = DriverManager.getConnection(dbUrl, dbUser, dbPassword); ArrayList<String> listOfDatabases = new ArrayList<String>(); DatabaseMetaData meta = dbConnection.getMetaData(); String[] tableTypes = { "TABLE" }; rs = meta.getTables(null, null, Application.verificationTableName, tableTypes); while (rs.next()) { String databaseName = rs.getString("TABLE_NAME"); listOfDatabases.add(databaseName.toUpperCase()); } if (listOfDatabases.contains(Application.verificationTableName)) { logger.info("Database already exists"); } else { ScriptRunner runner = new ScriptRunner(dbConnection, true, true); Reader dbScript = new InputStreamReader(dbScriptStream); runner.runScript(dbScript); logger.info("Database is created"); } } finally { if (rs != null) { try { rs.close(); rs = null; } catch (SQLException e) { // The ship is going down. Not much we can do. logger.fatal(e); } } if (dbConnection != null) { dbConnection.close(); dbConnection = null; } } logger = null; }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, * copying all properties (key-value pairs) over. * <p>Uses <code>Properties.propertyNames()</code> to even catch * default properties linked into the original Properties instance. * @param props the Properties instance to merge (may be <code>null</code>) * @param map the target Map to merge the properties into *///w ww . jav a 2 s . c om @SuppressWarnings("unchecked") public static void mergePropertiesIntoMap(Properties props, Map map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); Object value = props.getProperty(key); if (value == null) { // Potentially a non-String value... value = props.get(key); } map.put(key, value); } } }
From source file:Main.java
public static void mergePropertiesIntoMap(Properties props, Map map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } else {/*from www .j a va 2 s . com*/ String key; Object value; if (props != null) { for (Enumeration en = props.propertyNames(); en.hasMoreElements(); map.put(key, value)) { key = (String) en.nextElement(); value = props.getProperty(key); if (value == null) { value = props.get(key); } } } } }
From source file:com.haulmont.cuba.core.entity.LocaleHelper.java
public static String getLocalizedName(String localeBundle) { Locale locale = AppBeans.get(UserSessionSource.class).getLocale(); String localeName = null;/* w w w . j a va2 s .c o m*/ if (StringUtils.isNotEmpty(localeBundle)) { Properties localeProperties = loadProperties(localeBundle); if (localeProperties != null) { String key = locale.getLanguage(); if (StringUtils.isNotEmpty(locale.getCountry())) key += "_" + locale.getCountry(); if (localeProperties.containsKey(key)) localeName = (String) localeProperties.get(key); } } return localeName; }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, copying all * properties (key-value pairs) over.// w w w .jav a2s . c o m * <p> * Uses {@code Properties.propertyNames()} to even catch default properties * linked into the original Properties instance. * * @param props * the Properties instance to merge (may be {@code null}) * @param map * the target Map to merge the properties into */ @SuppressWarnings("unchecked") public static <K, V> void mergePropertiesIntoMap(Properties props, Map<K, V> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); Object value = props.getProperty(key); if (value == null) { // Potentially a non-String value... value = props.get(key); } map.put((K) key, (V) value); } } }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over. * <p>//from ww w .j ava 2s . com * Uses <code>Properties.propertyNames()</code> to even catch default properties linked into the original Properties * instance. * @param props the Properties instance to merge (may be <code>null</code>) * @param map the target Map to merge the properties into */ public static void mergePropertiesIntoMap(Properties props, Map<String, Object> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); Object value = props.getProperty(key); if (value == null) { // Potentially a non-String value... value = props.get(key); } map.put(key, value); } } }