|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.prosyst.util.ini.IniFile
public class IniFile
This class provides an easy access to sectioned files.
Every section starts with a definition:
[<section's name>].
Every key name is defined only for it's section block as follows:
<key name> = <key value>.
Sections do not have end delimiters - they end as the new section is defined or as the end of file is reached.
Sectioned files are defined as follows:
[<section's name>]
<key name> = <key value>
:
[<another section's name>]
:
It is possible to add commented lines and to comment certain key-value pairs.
A commented line will have a "//" in front of it.
A commented key-value pair will have a "##" in front of it.
| Field Summary | |
|---|---|
protected java.io.File |
lastLoadedFile
This holds a reference to the last loaded file. |
protected com.prosyst.util.ini.Queue |
sections
This is a Queue of IniSection objects. |
| Constructor Summary | |
|---|---|
IniFile()
Constructs a new IniFile structure. |
|
| Method Summary | |
|---|---|
void |
addSection(IniSection section)
Appends a new section. |
boolean |
containsSection(IniSection section)
Returns true if the given section is already contained. |
void |
deleteAllSections()
Deletes all sections. |
void |
deleteSection(IniSection section)
Deletes a section. |
void |
deleteSection(java.lang.String sectionName,
boolean ignoreCase)
Deletes the first section found by its name. |
IniFile |
duplicate()
Returns a duplicate of this object. |
java.io.File |
getLastLoadedFile()
Returns the last loaded file if the data was loaded from a file and not from a stream. |
IniSection |
getSection(int index)
Returns the section at a given index. |
IniSection |
getSection(java.lang.String sectionName,
boolean ignoreCase)
Returns the section by its name. |
int |
getSectionCount()
Returns the number of sections. |
int |
getSectionIndex(IniSection section)
Returns the index of a given section. |
void |
insertSection(IniSection section,
int index)
Inserts a section at a given index. |
void |
load(java.io.File iniFile)
Loads all sections from the given file. |
void |
load(java.io.InputStream inputStream)
Loads all sections from the given input stream. |
void |
save(java.io.File iniFile)
Saves all sections to the file. |
void |
save(java.io.OutputStream stream)
Saves all sections to the output stream. |
void |
setSection(IniSection section,
int index)
Sets a section at index. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected com.prosyst.util.ini.Queue sections
IniSection objects.
protected java.io.File lastLoadedFile
| Constructor Detail |
|---|
public IniFile()
IniFile structure.
| Method Detail |
|---|
public void load(java.io.File iniFile)
throws java.io.IOException
iniFile - file to be loaded
java.io.IOException
public void load(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - stream to be loaded
java.io.IOException
public void save(java.io.File iniFile)
throws java.io.IOException
iniFile - the file to be saved in
java.io.IOException
public void save(java.io.OutputStream stream)
throws java.io.IOException
stream - the stream to be saved in
java.io.IOExceptionpublic void addSection(IniSection section)
section - non-null section to be appendedpublic boolean containsSection(IniSection section)
true if the given section is already contained.
section - section to be checked
true if the section is already containedpublic void deleteSection(IniSection section)
section - section to be deletedpublic void deleteAllSections()
public void deleteSection(java.lang.String sectionName,
boolean ignoreCase)
sectionName - the section nameignoreCase - true if it is to ignore case while searchingpublic IniSection getSection(int index)
index - section's index
public IniSection getSection(java.lang.String sectionName,
boolean ignoreCase)
sectionName - the section's nameignoreCase - true if it is to ignore case while searching
null if not found.public int getSectionCount()
public int getSectionIndex(IniSection section)
section - section to search
public void insertSection(IniSection section,
int index)
addSection method.
section - section to be insertedindex - the index, at which the section is inserted
public void setSection(IniSection section,
int index)
addSection method.
section - the section to be setindex - the section's indexpublic IniFile duplicate()
public java.io.File getLastLoadedFile()
public java.lang.String toString()
toString in class java.lang.Object
|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||