|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.core.util.IniEditor.Section
public static class IniEditor.Section
Loads, edits and saves a section of an INI-style configuration file. This
class does actually belong to the internals of IniEditor and
should rarely ever be used directly. It's exposed because it can be
useful for plain, section-less configuration files (Java-style
properties, for example).
| Field Summary | |
|---|---|
static String |
DEFAULT_OPTION_FORMAT
|
static char |
HEADER_END
|
static char |
HEADER_START
|
| Constructor Summary | |
|---|---|
IniEditor.Section(String name)
Constructs a new section. |
|
IniEditor.Section(String name,
boolean isCaseSensitive)
Constructs a new section, specifying case-sensitivity. |
|
IniEditor.Section(String name,
char[] delims)
Constructs a new section, defining comment delimiters. |
|
IniEditor.Section(String name,
char[] delims,
boolean isCaseSensitive)
Constructs a new section, defining comment delimiters. |
|
| Method Summary | |
|---|---|
void |
addBlankLine()
Adds a blank line to the end of this section. |
void |
addComment(String comment)
Adds a comment line to the end of this section. |
void |
addComment(String comment,
char delim)
Adds a comment line to the end of this section. |
String |
get(String option)
Returns an option's value. |
boolean |
hasOption(String name)
Checks whether a given option exists in this section. |
void |
load(BufferedReader reader)
Loads options from a reader into this instance. |
List<String> |
optionNames()
Returns the names of all options in this section. |
boolean |
remove(String option)
Removes an option if it exists. |
void |
save(PrintWriter writer)
Prints this section to a print writer. |
void |
set(String option,
String value)
Sets an option's value and creates the option if it doesn't exist. |
void |
set(String option,
String value,
char delim)
Sets an option's value and creates the option if it doesn't exist. |
void |
setOptionFormat(org.rhq.core.util.IniEditor.OptionFormat format)
Sets the option format for this section. |
void |
setOptionFormatString(String formatString)
Sets the option format for this section to the given string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_OPTION_FORMAT
public static final char HEADER_START
public static final char HEADER_END
| Constructor Detail |
|---|
public IniEditor.Section(String name)
name - the section's name
IllegalArgumentException - the section's name is illegal
public IniEditor.Section(String name,
boolean isCaseSensitive)
name - the section's nameisCaseSensitive - option names are case-sensitive if this is true
IllegalArgumentException - the section's name is illegal
public IniEditor.Section(String name,
char[] delims)
name - the section's namedelims - an array of characters to be recognized as starters of
comment lines; the first of them will be used for newly created
comments
IllegalArgumentException - the section's name is illegal
public IniEditor.Section(String name,
char[] delims,
boolean isCaseSensitive)
name - the section's namedelims - an array of characters to be recognized as starters of
comment lines; the first of them will be used for newly created
commentsisCaseSensitive - option names are case-sensitive if this is true
IllegalArgumentException - the section's name is illegal| Method Detail |
|---|
public void setOptionFormatString(String formatString)
%s three times, these
will be replaced with the option name, the option separator and the
option value in this order. Literal percentage signs must be escaped
by preceding them with another percentage sign (i.e., %%
corresponds to one percentage sign). The default format string is
"%s %s %s".
Option formats may look like format strings as supported by Java 1.5,
but the string is in fact parsed in a custom fashion to guarantee
backwards compatibility. So don't try clever stuff like using format
conversion types other than %s.
formatString - a format string, containing %s
exactly three times
IllegalArgumentException - if the format string is illegalpublic void setOptionFormat(org.rhq.core.util.IniEditor.OptionFormat format)
format - a compiled option formatpublic List<String> optionNames()
public boolean hasOption(String name)
name - the name of the option to test for
public String get(String option)
option - the name of the option
null if no
option with the specified name exists
public void set(String option,
String value)
option - the option's namevalue - the option's value
IllegalArgumentException - the option name is illegal,
ie contains a '=' character or consists only of white space
public void set(String option,
String value,
char delim)
option - the option's namevalue - the option's valuedelim - the delimiter between name and value for this option
IllegalArgumentException - the option name is illegal,
ie contains a '=' character or consists only of white spacepublic boolean remove(String option)
option - the name of the option
true if the option was actually removedpublic void addComment(String comment)
comment - the comment
public void addComment(String comment,
char delim)
comment - the commentdelim - the delimiter used to mark the start of this commentpublic void addBlankLine()
public void load(BufferedReader reader)
throws IOException
reader - where to read from
IOException - at an I/O problem
public void save(PrintWriter writer)
throws IOException
writer - where to write
IOException - at an I/O problem
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||