List of usage examples for java.util LinkedHashMap LinkedHashMap
public LinkedHashMap()
From source file:Main.java
public static Map<String, Integer> getProvince(SQLiteDatabase db, String tableName) { Map<String, Integer> provinceMap = new LinkedHashMap<String, Integer>(); Cursor cursor = db.query(tableName, new String[] { "DQX_DQXX01", "DQXX02" }, "DQXX03=?", new String[] { "1" }, null, null, "DQX_DQXX01 ASC"); if (cursor != null) { while (cursor.moveToNext()) { provinceMap.put(cursor.getString(1), cursor.getInt(0)); }// ww w .jav a 2s . c o m } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return provinceMap; }
From source file:Main.java
public static LinkedHashMap<String, Integer> getDateMap(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w .jav a2 s .co m*/ LinkedHashMap<String, Integer> datemap = new LinkedHashMap<String, Integer>(); datemap.put("year", cal.get(Calendar.YEAR)); datemap.put("month", cal.get(Calendar.MONTH)); datemap.put("day", cal.get(Calendar.DAY_OF_MONTH)); datemap.put("hour", cal.get(Calendar.HOUR_OF_DAY)); datemap.put("minute", cal.get(Calendar.MINUTE)); datemap.put("second", cal.get(Calendar.SECOND)); datemap.put("millisecond", cal.get(Calendar.MILLISECOND)); return datemap; }
From source file:Main.java
public static Map<String, Integer> getArea(SQLiteDatabase db, String tableName, int dqx_dqxx01) { Map<String, Integer> areaMap = new LinkedHashMap<String, Integer>(); Cursor cursor = db.query(tableName, new String[] { "DQXX02", "DQXX01" }, "DQX_DQXX01=?", new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC"); if (cursor != null) { while (cursor.moveToNext()) { areaMap.put(cursor.getString(0), cursor.getInt(1)); }/*from w w w . j a va 2s .com*/ } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return areaMap; }
From source file:Main.java
public static Map<Integer, String> asMap(Map.Entry<Integer, String>... entries) { Map<Integer, String> map = new LinkedHashMap<Integer, String>(); for (Map.Entry<Integer, String> name : entries) { map.put(name.getKey(), name.getValue()); }/*from w ww . ja v a 2s. c om*/ return map; }
From source file:Main.java
/** * Create new {@link java.util.LinkedHashMap}. * * @param <K>/*www .j av a2 s . c o m*/ * key * @param <V> * value * @return {@link java.util.LinkedHashMap} */ public static <K, V> Map<K, V> newLinkedHashMap() { return new LinkedHashMap<K, V>(); }
From source file:Main.java
/** * Converts the given pair of arrays into a map that maps each keys[i] to * the corresponding values[i].//from ww w . j a va 2 s .com * @return the map (empty map if keys == null or values == null) */ public static <K, V> Map<K, V> asMap(K[] keys, V[] values) { Map<K, V> map = new LinkedHashMap<K, V>(); if (keys == null || values == null) { return map; } for (int i = 0, len = Math.min(keys.length, values.length); i < len; i++) { map.put(keys[i], values[i]); } return map; }
From source file:Main.java
public static String getDeviceInfos(Context context) { Map<String, String> infos = new LinkedHashMap<>(); DisplayMetrics dm = context.getResources().getDisplayMetrics(); int densityDpi = dm.densityDpi; infos.put("API Level", String.valueOf(Build.VERSION.SDK_INT)); infos.put("OS Version", Build.VERSION.RELEASE); infos.put("Model", Build.MODEL); infos.put("Manufacturer", Build.MANUFACTURER); infos.put("Brand", Build.BRAND); infos.put("Device / Product", Build.DEVICE + " / " + Build.PRODUCT); infos.put("Kernel-Version", System.getProperty("os.version")); StringBuilder sb = new StringBuilder(); sb.append("<table class=\"table table-striped\">"); sb.append("<tbody>"); for (Map.Entry<String, String> deviceInfo : infos.entrySet()) { sb.append("<tr><th>"); sb.append(deviceInfo.getKey());/*from www . j a v a 2 s . c o m*/ sb.append("</th><td>"); sb.append(deviceInfo.getValue()); sb.append("</td></tr>"); } sb.append("<tbody>"); sb.append("</table>"); return sb.toString(); }
From source file:Main.java
public static Map<String, String> convertProperties2Map(Properties properties) { if (properties == null) { return null; }//from w w w .j av a 2 s . co m Map<String, String> map = new LinkedHashMap<String, String>(); Set<Entry<Object, Object>> entrySet = properties.entrySet(); for (Entry<Object, Object> entry : entrySet) { map.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } return map; }
From source file:Main.java
/** * A Utility method for creating LRU cache * * @param size size of the cache//from w w w . j ava2 s.c o m * @return a new cache with the provided size */ public static <K, V> Map<K, V> createLRUCache(final int size) { return new LinkedHashMap<K, V>() { private static final long serialVersionUID = 5261489276168775084L; @Override protected boolean removeEldestEntry(Map.Entry<K, V> entry) { return size() > size; } }; }
From source file:Main.java
public static Map<String, Integer> getCity(SQLiteDatabase db, String tableName, int dqx_dqxx01, boolean municipalities) { Map<String, Integer> cityMap = new LinkedHashMap<String, Integer>(); Cursor cursor = db.query(tableName, new String[] { "DQXX02", "DQXX01" }, "DQX_DQXX01=?", new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC"); if (cursor != null) { if (municipalities) { cursor.moveToNext();/*from w ww. j a v a 2s . c om*/ } while (cursor.moveToNext()) { cityMap.put(cursor.getString(0), cursor.getInt(1)); } } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return cityMap; }