public class SectionContent extends Content
Modifier and Type | Class and Description |
---|---|
private static class |
SectionContent.KeyRenderer
The class to present key-value pair in one ordered list.
|
static interface |
SectionContent.Renderable
The interface to present single line and key-value pair in one ordered list.
|
private static class |
SectionContent.TextRenderer
The class to present single line in one ordered list.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String> |
keyMap
Map to store key=value pars.
|
private java.lang.String |
name
The section name associated with the content.
|
private int |
nextKeyNumber
The position of the last key=value pair in the ordering list.
|
private java.util.List<SectionContent.Renderable> |
ordering
List to control section line ordering.
|
Constructor and Description |
---|
SectionContent(java.lang.String name)
Constructs an instance of the data section in INI file.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String key,
java.lang.String value)
Adds the key=value pair to the section internals assuming this is the new key.
|
boolean |
alreadyInSection(java.lang.String key)
Checks if the given key already added to the section internals..
|
java.lang.String |
getKeys()
Getting the comma-separated list of the keys for this section.
|
java.lang.String |
getName()
Getting the name of this section.
|
java.lang.String |
getValueForKey(java.lang.String key)
Gets the value associated with the given key inside the section.
|
boolean |
notEmpty()
Checks if the content of the section is empty or not.
|
void |
remove(java.lang.String key)
Removes the key=value pair from the section internal map.
|
void |
store(java.lang.String textLine)
Stores the empty line or comment iside the section content.
|
void |
store(java.lang.String key,
java.lang.String value)
Stores the key=value pair into the section internal map.
|
void |
storeAsPseudoKey(java.lang.String textLine)
Stores the line iside the section content as pseudo key.
|
void |
write(java.io.PrintWriter pw)
Writes the content of the data section to the file via Writer object provided.
|
private java.util.Map<java.lang.String,java.lang.String> keyMap
private java.lang.String name
private java.util.List<SectionContent.Renderable> ordering
private int nextKeyNumber
public SectionContent(java.lang.String name)
name
- The name of the section corresponding to the key=value pairs of the INI file.public java.lang.String getName()
public void write(java.io.PrintWriter pw)
public boolean notEmpty()
public void store(java.lang.String key, java.lang.String value)
key
- The String key name to store.value
- The String value to be associated with the given key name.public void remove(java.lang.String key)
key
- The String key name to remove.public void add(java.lang.String key, java.lang.String value)
key
- The String key name to store.value
- The String value to be associated with the given key name.public void store(java.lang.String textLine)
textLine
- The ignored text line to store.public void storeAsPseudoKey(java.lang.String textLine)
textLine
- The ignored text line to store.public java.lang.String getValueForKey(java.lang.String key)
key
- The String key name of the value to be retrieved.null
if there is no
key=value pair inside the section.public boolean alreadyInSection(java.lang.String key)
key
- The String key name to check.true
if the key was already added to internal map, false
otherwise.public java.lang.String getKeys()