org.dtools.ini
Class AdvancedIniFile

java.lang.Object
  extended by org.dtools.ini.IniFile
      extended by org.dtools.ini.AdvancedIniFile
All Implemented Interfaces:
Cloneable, Iterable<IniSection>

public class AdvancedIniFile
extends IniFile

This implementation of the IniFile interface offers faster performance compared with the BasicIniFile implementation, but at the expense of greater memory usage.

Since:
0.2.00
Version:
1.1.0
Author:
David Lewis

Field Summary
 
Fields inherited from class org.dtools.ini.IniFile
validator
 
Constructor Summary
AdvancedIniFile()
          Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator and to be case insensitive.
AdvancedIniFile(boolean caseSensitive)
          Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator.
AdvancedIniFile(IniValidator validator)
          Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator and to be case insensitive.
AdvancedIniFile(IniValidator validator, boolean caseSensitive)
          Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator and to be case insensitive.
 
Method Summary
 boolean addSection(IniSection section, int index)
          Adds a section to this INI file.
 Object clone()
           
protected  IniSection createSection(String name)
          This method creates and returns a new instance of an IniSection with the same IniValidator and case sensitivity as this object.
 IniSection getSection(int index)
          Get the section which is at the given index.
 Collection<IniSection> getSections()
          Gets a collection of all the sections within this INI file.
 int indexOf(IniSection section)
          Get the index of the given section, where 0 is the index is the first section.
 Iterator<IniSection> iterator()
           
 boolean removeSection(IniSection section)
          Removes the given section only if the section is within this IniFile
 
Methods inherited from class org.dtools.ini.IniFile
addOrMergeSection, addSection, addSection, addSection, addSections, equals, getNumberOfItems, getNumberOfSections, getSection, getSectionNames, getValidator, hashCode, hasSection, hasSection, indexOf, isCaseSensitive, isEmpty, merge, moveSection, moveSection, removeAll, removeSection, removeSection, removeSections, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AdvancedIniFile

public AdvancedIniFile()

Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator and to be case insensitive.

Since:
0.1.15

AdvancedIniFile

public AdvancedIniFile(boolean caseSensitive)

Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator.

Parameters:
caseSensitive - Sets whether this instance of IniFile is case sensitive or not.
Since:
0.1.15

AdvancedIniFile

public AdvancedIniFile(IniValidator validator)

Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator and to be case insensitive.

Parameters:
validator - Sets the IniValidator if this instance of IniFile.
Since:
0.1.15

AdvancedIniFile

public AdvancedIniFile(IniValidator validator,
                       boolean caseSensitive)

Default constructor which creates a new instance of BasicIniFile and sets the IniFile to have a default IniValidator and to be case insensitive.

Parameters:
caseSensitive - Sets whether this instance of IniFile is case sensitive or not.
validator - Sets the IniValidator if this instance of IniFile.
Since:
0.1.15
Method Detail

addSection

public boolean addSection(IniSection section,
                          int index)
Description copied from class: IniFile

Adds a section to this INI file. If an existing section has the same name as the given section, then the new section is not added and the method returns false. If the given section is of a type that is not compatible with the class that implements this interface, then a compatible copy of the section is made which is then added to the class.

Specified by:
addSection in class IniFile
Parameters:
section - The section to add to this INI file.
index - The index where to add the section, where 0 is the index of the first section. Any section that already exists at this index will be moved to index + 1. If the value is greater than the number of sections within this INI file, then the section is appended to the end of the INI file.
Returns:
True if the section was added successfully, false if a section with the same name already exists.

createSection

protected IniSection createSection(String name)
Description copied from class: IniFile

This method creates and returns a new instance of an IniSection with the same IniValidator and case sensitivity as this object.

Specified by:
createSection in class IniFile
Parameters:
name - The name of the IniSection to create.
Returns:
A new instance of an IniSection with the same IniValidator and case sensitivity as this object.

getSection

public IniSection getSection(int index)
Description copied from class: IniFile
Get the section which is at the given index.

Specified by:
getSection in class IniFile
Parameters:
index - the index of the section to retrieve.
Returns:
The section that is at the given index.

getSections

public Collection<IniSection> getSections()
Description copied from class: IniFile
Gets a collection of all the sections within this INI file.

Specified by:
getSections in class IniFile
Returns:
A collection of all the Sections.

indexOf

public int indexOf(IniSection section)
Description copied from class: IniFile
Get the index of the given section, where 0 is the index is the first section. If the given section is not in this INI file, then -1 is returned.

Specified by:
indexOf in class IniFile
Parameters:
section - The section whose index will be retured
Returns:
The index of the section, or -1 is no such section exists.

removeSection

public boolean removeSection(IniSection section)
Description copied from class: IniFile
Removes the given section only if the section is within this IniFile

Specified by:
removeSection in class IniFile
Parameters:
section - The section to remove.
Returns:
boolean, true if the IniSection was removed, false it the given IniSection did not exists in the first place.

clone

public Object clone()
Specified by:
clone in class IniFile

iterator

public Iterator<IniSection> iterator()