|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.IniFile
public class IniFile
Used to read and parse an .ti file. Sections are defined by inclosing a word with [] brackets, ex. [section] name and value pairs are formated like name = value, the equal sign separates name/value pairs The .ti file will be looked for in jar files first then the current directory.
Field Summary | |
---|---|
boolean |
fileFound
Set to true if file was found. |
Constructor Summary | |
---|---|
IniFile(java.lang.String fileName)
Constructor for the IniFile Class. |
Method Summary | |
---|---|
boolean |
addSection(java.lang.String sec)
Adds a new section with no key/value pairs. |
void |
addSection(java.lang.String sec,
java.lang.String key,
java.lang.String value)
Adds a key/value pair to an existing section or creates the section if it does not exist. |
boolean |
addValuePair(java.lang.String sec,
java.lang.String key,
java.lang.String value)
Adds a key/value pair to the an existing section, if section does not exist the key/value is NOT added. |
boolean |
appendValuePair(java.lang.String sec,
java.lang.String key,
java.lang.String value)
Appends a key/value to an existing section, if the key/value does not exist then it is created. |
void |
clearAll()
Clears all sections and key/value pairs. |
java.lang.String |
getFileName()
Returns the filename. |
int |
getSectionCount()
Returns the number of sections in file. |
java.lang.Object[] |
getSectionKeys(java.lang.Object sectionName)
Returns an array of key names in the section. |
java.lang.Object[] |
getSectionNames()
Get an array of all section names. |
boolean |
getSectionValueAsBoolean(java.lang.Object sectionName,
java.lang.Object keyName)
Gets value as a boolean value. |
int |
getSectionValueAsInt(java.lang.Object sectionName,
java.lang.Object keyName)
Returns a value of a key/value pairs as an integer |
java.lang.String |
getSectionValueAsString(java.lang.Object sectionName,
java.lang.Object keyName)
Returns the value of a key/value pair as a string but does not expand any variables. |
java.lang.String |
getSectionValueAsString(java.lang.Object sectionName,
java.lang.Object keyName,
boolean flag)
Returns the value of a key/value pair as a string. |
int |
getSectionValueCount(java.lang.Object sectionName)
Returns key/value pair count of a section |
ValuePairMap |
getSectionValues(java.lang.Object sectionName)
Return the linked list of a section. |
int |
getValueCount()
returns the number of total key/values pairs by adding all sections together. |
boolean |
keyExists(java.lang.Object sectionName,
java.lang.Object key)
Checks if a key exists in given section. |
void |
moveDownValuePair(java.lang.String sec,
java.lang.String key)
Moves the key/value pair one place down in the linked list if it can. |
void |
moveToBottomValuePair(java.lang.String sec,
java.lang.String key)
Moves the key/value pair to bottom of linked list. |
void |
moveToTopValuePair(java.lang.String sec,
java.lang.String key)
Moves the key/value pair to top of the linked list. |
void |
moveUpValuePair(java.lang.String sec,
java.lang.String key)
Moves the key/value pair one place up in the linked list if it can. |
boolean |
open(java.lang.String fileName)
Open the file and parse contents. |
boolean |
printSection(java.lang.Object sectionName)
Prints the name/value pairs for a section. |
boolean |
removeSection(java.lang.String sec)
Removes an existing section and all of it's key/value pairs. |
boolean |
removeValuePair(java.lang.String sec,
java.lang.String key)
Removes an existing key/value pair from an existing section. |
boolean |
renameSection(java.lang.String from,
java.lang.String to)
Renames a section. |
boolean |
renameValuePair(java.lang.String sec,
java.lang.String from,
java.lang.String to)
Rename key of a ValuePair |
void |
reread()
Rereads the file, discarding all changes. |
boolean |
sectionExists(java.lang.Object sectionName)
Checks if section exists. |
java.lang.String |
toString()
Prints all of the sections. |
boolean |
writeFile(java.lang.String topSection)
Writes the complete sections to the filename given when you created class. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public boolean fileFound
Constructor Detail |
---|
public IniFile(java.lang.String fileName)
fileName
- name of .ti type file to create or read.Method Detail |
---|
public java.lang.String getFileName()
public void reread()
public void clearAll()
public boolean open(java.lang.String fileName)
fileName
- full path to file.
public void addSection(java.lang.String sec, java.lang.String key, java.lang.String value)
sec
- section namekey
- key within sectionvalue
- value of the keypublic boolean addSection(java.lang.String sec)
sec
- section name
public boolean renameSection(java.lang.String from, java.lang.String to)
from
- from section nameto
- to section name
public void moveToTopValuePair(java.lang.String sec, java.lang.String key)
sec
- section name.key
- key name.public void moveToBottomValuePair(java.lang.String sec, java.lang.String key)
sec
- section name.key
- key name.public void moveUpValuePair(java.lang.String sec, java.lang.String key)
sec
- section name.key
- key name.public void moveDownValuePair(java.lang.String sec, java.lang.String key)
sec
- section name.key
- key name.public boolean addValuePair(java.lang.String sec, java.lang.String key, java.lang.String value)
sec
- section namekey
- key within sectionvalue
- value of the key
public boolean appendValuePair(java.lang.String sec, java.lang.String key, java.lang.String value)
sec
- section namekey
- key within sectionvalue
- value of the key
public boolean removeSection(java.lang.String sec)
sec
- section name to remove
public boolean removeValuePair(java.lang.String sec, java.lang.String key)
sec
- section namekey
- key within section
public boolean renameValuePair(java.lang.String sec, java.lang.String from, java.lang.String to)
sec
- section namefrom
- from value keyto
- to value key
public int getSectionCount()
public int getValueCount()
public int getSectionValueCount(java.lang.Object sectionName)
sectionName
- section name
public java.lang.String getSectionValueAsString(java.lang.Object sectionName, java.lang.Object keyName)
sectionName
- section namekeyName
- key name within section
public java.lang.String getSectionValueAsString(java.lang.Object sectionName, java.lang.Object keyName, boolean flag)
sectionName
- section namekeyName
- key name within sectionflag
- whether to expand variables or not.
public int getSectionValueAsInt(java.lang.Object sectionName, java.lang.Object keyName)
sectionName
- section namekeyName
- key name within section
public boolean getSectionValueAsBoolean(java.lang.Object sectionName, java.lang.Object keyName)
sectionName
- keyName
-
public ValuePairMap getSectionValues(java.lang.Object sectionName)
sectionName
-
public java.lang.Object[] getSectionNames()
public java.lang.Object[] getSectionKeys(java.lang.Object sectionName)
sectionName
-
public boolean sectionExists(java.lang.Object sectionName)
sectionName
-
public boolean keyExists(java.lang.Object sectionName, java.lang.Object key)
sectionName
- key
-
public boolean writeFile(java.lang.String topSection)
topSection
- - string comment to place at top of file.
public boolean printSection(java.lang.Object sectionName)
sectionName
-
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |