/** * Get the value for the key specified by the index for the first section. * * @param key the key * @param index the index * @return the value at the specified index * @throws ArrayIndexOutOfBoundsException when the index is out of bounds */ public String getValue(String key, int index) { IniSection section = getSection(); return section == null ? null : section.get(key, index); }
/** * Get the unmodifiable set of keys of the first section. * The set has insertion order. * * @return the keys of the first section */ public Collection<String> getKeys() { IniSection section = getSection(); return section == null ? null : section.getKeys(); }
/** * Get the number of values for a key in the first section * * @param key the key * @return the number of values for a key in the first section */ public int getValueSize(String key) { IniSection section = getSection(); return section == null ? 0 : section.size(key); }
/** * Get the first value for the key in the first section. * * @param key the key * @return the value at the specified index * @throws ArrayIndexOutOfBoundsException when the index is out of bounds */ public String getValue(String key) { IniSection section = getSection(); return section == null ? null : section.get(key); }
/** * Add a value for the key. Duplicate values are not allowed. * * @param key the key for the section * @param value the value for the key * @return whether the value was added or is already present. */ public boolean addValue(String key, String value) { IniSection section = getSection(); return section == null || section.add(key, value); }
/** * Replace a value for a key. * A null for key or value is not allowed. * An empty string for a key is not allowed. * * @param key the key for the section * @param value the value for the key * @return {@code true} if the element was added or already was present */ public boolean replaceValue(String key, String value) { IniSection section = getSection(); return section == null || section.replace(key, value); }
/** * Get the values of a key of the first section. * The collection has insertion order. * Note many keys only have one value. * A key that has no values returns null. * * @param key the key * @return the keyed values or null if the key doesn't exist */ public Collection<String> getValues(String key) { IniSection section = getSection(); return section == null ? null : section.getValues(key); }