public class Ini extends Objectimplements Map <String ,Ini .Section >
Sections, keyed by section name. Each
Section is itself a map of
String name/value pairs. Name/value pairs are guaranteed to be unique within each
Section only - not across the entire
Ini instance.
| Modifier and Type | Class and Description |
|---|---|
static class |
Ini
|
| Modifier and Type | Field and Description |
|---|---|
static String |
COMMENT_POUND
|
static String |
COMMENT_SEMICOLON
|
static String |
DEFAULT_CHARSET_NAME
|
static String |
DEFAULT_SECTION_NAME
|
protected static char |
ESCAPE_TOKEN
|
static String |
SECTION_PREFIX
|
static String |
SECTION_SUFFIX
|
| Constructor and Description |
|---|
Ini()
Creates a new empty
Ini instance.
|
Ini(Ini
Creates a new
Ini instance with the specified defaults.
|
| Modifier and Type | Method and Description |
|---|---|
Ini |
addSection(String
Ensures a section with the specified name exists, adding a new one if it does not yet exist.
|
void |
clear()
|
boolean |
containsKey(Object
|
boolean |
containsValue(Object
|
Set |
entrySet()
|
boolean |
equals(Object
|
static Ini |
fromResourcePath(String
Creates a new
Ini instance loaded with the INI-formatted data in the resource at the given path.
|
Ini |
get(Object
|
Ini |
getSection(String
Returns the
Ini.Section with the given name or
null if no section with that name exists.
|
protected static String |
getSectionName(String
|
Set |
getSectionNames()
Returns the names of all sections managed by this
Ini instance or an empty collection if there are no sections.
|
String |
getSectionProperty(String
Returns the value of the specified section property, or
null if the section or property do not exist.
|
String |
getSectionProperty(String
Returns the value of the specified section property, or the
defaultValue if the section or property do not exist.
|
Collection |
getSections()
Returns the sections managed by this
Ini instance or an empty collection if there are no sections.
|
int |
hashCode()
|
boolean |
isEmpty()
Returns
true if no sections have been configured, or if there are sections, but the sections themselves are all empty,
false otherwise.
|
protected static boolean |
isSectionHeader(String
|
Set |
keySet()
|
void |
load(InputStream
Loads the INI-formatted text backed by the given InputStream into this instance.
|
void |
load(Reader
Loads the INI-formatted text backed by the given Reader into this instance.
|
void |
load(Scanner
Loads the INI-formatted text backed by the given Scanner.
|
void |
load(String
Loads the specified raw INI-formatted text into this instance.
|
void |
loadFromPath(String
Loads data from the specified resource path into this current
Ini instance.
|
Ini |
put(String
|
void |
putAll(Map
|
Ini |
remove(Object
|
Ini |
removeSection(String
Removes the section with the specified name and returns it, or
null if the section did not exist.
|
void |
setSectionProperty(String
Sets a name/value pair for the section with the given
sectionName.
|
int |
size()
|
String |
toString()
|
Collection |
values()
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic static final StringDEFAULT_SECTION_NAME
public static final StringDEFAULT_CHARSET_NAME
public static final StringCOMMENT_POUND
public static final StringCOMMENT_SEMICOLON
public static final StringSECTION_PREFIX
public static final StringSECTION_SUFFIX
protected static final char ESCAPE_TOKEN
public Ini()
Ini instance.
public Ini(Inidefaults)
Ini instance with the specified defaults.
defaults - the default sections and/or key-value pairs to copy into the new instance.
public boolean isEmpty()
true if no sections have been configured, or if there are sections, but the sections themselves are all empty,
false otherwise.
isEmpty in interface
Map<String,Ini.Section >
true if no sections have been configured, or if there are sections, but the sections themselves are all empty,
false otherwise.
public Set<String > getSectionNames()
Ini instance or an empty collection if there are no sections.
Ini instance or an empty collection if there are no sections.
public Collection<Ini .Section > getSections()
Ini instance or an empty collection if there are no sections.
Ini instance or an empty collection if there are no sections.
public Ini.Section getSection(String sectionName)
Ini.Section with the given name or
null if no section with that name exists.
sectionName - the name of the section to retrieve.
Ini.Section with the given name or
null if no section with that name exists.
public Ini.Section addSection(String sectionName)
sectionName - the name of the section to ensure existence
public Ini.Section removeSection(String sectionName)
null if the section did not exist.
sectionName - the name of the section to remove.
null if the section did not exist.
public void setSectionProperty(StringsectionName, String propertyName, String propertyValue)
sectionName. If the section does not yet exist, it will be created. If the
sectionName is null or empty, the name/value pair will be placed in the default (unnamed, empty string) section.
sectionName - the name of the section to add the name/value pair
propertyName - the name of the property to add
propertyValue - the property value
public StringgetSectionProperty(String sectionName, String propertyName)
null if the section or property do not exist.
sectionName - the name of the section to retrieve to acquire the property value
propertyName - the name of the section property for which to return the value
null if the section or property do not exist.
public StringgetSectionProperty(String sectionName, String propertyName, String defaultValue)
defaultValue if the section or property do not exist.
sectionName - the name of the section to add the name/value pair
propertyName - the name of the property to add
defaultValue - the default value to return if the section or property do not exist.
defaultValue if the section or property do not exist.
public static InifromResourcePath(String resourcePath) throws ConfigurationException
Ini instance loaded with the INI-formatted data in the resource at the given path. The resource path may be any value interpretable by the
ResourceUtils.getInputStreamForPath method.
resourcePath - the resource location of the INI data to load when creating the
Ini instance.
Ini instance loaded with the INI-formatted data in the resource at the given path.
ConfigurationException - if the path cannot be loaded into an
Ini instance.
public void loadFromPath(StringresourcePath) throws ConfigurationException
Ini instance. The resource path may be any value interpretable by the
ResourceUtils.getInputStreamForPath method.
resourcePath - the resource location of the INI data to load into this instance.
ConfigurationException - if the path cannot be loaded
public void load(StringiniConfig) throws ConfigurationException
iniConfig - the raw INI-formatted text to load into this instance.
ConfigurationException - if the text cannot be loaded
public void load(InputStreamis) throws ConfigurationException
is - the
InputStream from which to read the INI-formatted text
ConfigurationException - if unable
public void load(Readerreader)
reader - the
Reader from which to read the INI-formatted text
public void load(Scannerscanner)
scanner - the
Scanner from which to read the INI-formatted text
protected static boolean isSectionHeader(Stringline)
public boolean equals(Objectobj)
public int hashCode()
public StringtoString()
public int size()
public boolean containsKey(Objectkey)
public boolean containsValue(Objectvalue)
public Ini.Section get(Object key)
public Ini.Section put(String key, Ini .Section value)
public Ini.Section remove(Object key)
public void putAll(Map<? extends String ,? extends Ini .Section > m)
public void clear()
public Collection<Ini .Section > values()
public Set<Map .Entry <String ,Ini .Section >> entrySet()