/** Saves the given IniList to the given file. */ public void saveINI(IniList ini, String path, boolean append, boolean sorted) throws IOException { BufferedWriter out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(path, append), Constants.ENCODING)); for (IniTable table : ini) { String header = table.get(IniTable.HEADER_KEY); out.write("[" + header + "]\n"); Set<String> keys; if (sorted) { Map<String, String> treeMap = new TreeMap<String, String>(table); keys = treeMap.keySet(); } else { keys = table.keySet(); } for (String key : keys) { out.write(key + " = " + table.get(key) + "\n"); } out.write("\n"); } out.close(); }
/** * Flattens all of the INI tables into a single HashMap whose keys are * of the format "[table name] table key". */ public HashMap<String, String> flattenIntoHashMap() { HashMap<String, String> h = new HashMap<String, String>(); for (IniTable table : this) { String tableName = table.get(IniTable.HEADER_KEY); for (String key : table.keySet()) { if (!key.equals(IniTable.HEADER_KEY)) { h.put("[" + tableName + "] " + key, table.get(key)); } } } return h; }
/** * Flattens all of the INI tables into a single HashMap whose keys are * of the format "[table name] table key". * * @return a HashMap containing all key/value pairs in every {@link IniTable} * as described above */ public HashMap<String, String> flattenIntoHashMap() { HashMap<String, String> h = new HashMap<String, String>(); for (IniTable table : this) { String tableName = table.get(IniTable.HEADER_KEY); for (String key : table.keySet()) { if (!key.equals(IniTable.HEADER_KEY)) { h.put("[" + tableName + "] " + key, table.get(key)); } } } return h; }
keys = table.keySet();
private IniList getIniFile(String filename) throws FormatException, IOException { LOGGER.debug("getIniFile procession: {}", filename); RandomAccessInputStream stream = getFile(filename); String data = stream.readString((int) stream.length()); if (!data.startsWith("[")) { data = data.substring(data.indexOf('['), data.length()); } data = DataTools.stripString(data); BufferedReader reader = new BufferedReader(new StringReader(data)); stream.close(); IniList list = parser.parseINI(reader); // most of the values will be wrapped in double quotes for (IniTable table : list) { LOGGER.debug(""); LOGGER.debug("[" + table.get(IniTable.HEADER_KEY) + "]"); String[] keys = table.keySet().toArray(new String[table.size()]); for (String key : keys) { String value = sanitizeValue(table.get(key)); LOGGER.debug(key + " = " + value); table.put(key, value); } } reader.close(); return list; }
private IniList getIniFile(String filename) throws FormatException, IOException { LOGGER.debug("getIniFile procession: {}", filename); RandomAccessInputStream stream = getFile(filename); String data = stream.readString((int) stream.length()); if (!data.startsWith("[")) { data = data.substring(data.indexOf('['), data.length()); } data = DataTools.stripString(data); BufferedReader reader = new BufferedReader(new StringReader(data)); stream.close(); IniList list = parser.parseINI(reader); // most of the values will be wrapped in double quotes for (IniTable table : list) { LOGGER.debug(""); LOGGER.debug("[" + table.get(IniTable.HEADER_KEY) + "]"); String[] keys = table.keySet().toArray(new String[table.size()]); for (String key : keys) { String value = sanitizeValue(table.get(key)); LOGGER.debug(key + " = " + value); table.put(key, value); } } reader.close(); return list; }
for (String key : table.keySet()) { if (key.equals(IniTable.HEADER_KEY)) continue; String value = table.get(key);
for (String key : table.keySet()) { if (key.equals(IniTable.HEADER_KEY)) continue; String value = table.get(key);
for (String key : image.keySet()) { addGlobalMeta(key, image.get(key));
for (String key : image.keySet()) { addGlobalMeta(key, image.get(key));
Double macroHeight = new Double(slideInfo.get("PhysicalMacroHeight")); for (String key : slideInfo.keySet()) { addGlobalMeta(key, slideInfo.get(key));
Double macroHeight = new Double(slideInfo.get("PhysicalMacroHeight")); for (String key : slideInfo.keySet()) { addGlobalMeta(key, slideInfo.get(key));