|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dtools.ini.IniSection
org.dtools.ini.AdvancedIniSection
public class AdvancedIniSection
This implementation of the IniSection
interface offers faster
performance compared with the BasicIniSection
implementation,
but at the expense of greater memory usage.
Field Summary |
---|
Fields inherited from class org.dtools.ini.IniSection |
---|
validator |
Fields inherited from interface org.dtools.ini.Commentable |
---|
COMMENT_SYMBOL |
Constructor Summary | |
---|---|
AdvancedIniSection(String name)
Default constructor which creates a new instance of this IniSection and sets the IniSection to have a
default IniValidator and to be case insensitive. |
|
AdvancedIniSection(String name,
boolean caseSensitive)
Default constructor which creates a new instance of this IniSection and sets the IniSection to have a
default IniValidator and to be case insensitive. |
|
AdvancedIniSection(String name,
IniValidator validator)
Default constructor which creates a new instance of this IniSection and sets the IniSection to have a
default IniValidator and to be case insensitive. |
|
AdvancedIniSection(String name,
IniValidator validator,
boolean caseSensitive)
Default constructor which creates a new instance of this IniSection and sets the IniSection to have a
default IniValidator and to be case insensitive. |
Method Summary | |
---|---|
boolean |
addItem(IniItem item)
Adds an IniItem to this section. |
boolean |
addItem(IniItem item,
int index)
Adds an IniItem to this section at the given index. |
IniItem |
addItem(String name)
Adds a new IniItem to this section with the given name. |
IniItem |
addItem(String itemName,
int index)
Adds an IniItem to this section at the given index. |
void |
addItems(String... itemNames)
Add multiple new items to this section. |
Object |
clone()
This class implements the Cloneable interface, but leaves implementation to subclasses which override this class. |
protected IniItem |
createItem(String name)
This method creates and returns a new instance of an IniItem with the same IniValidator and case
sensitivity as this object. |
IniItem |
getItem(int index)
Get the item which is at the given index. |
IniItem |
getItem(String name)
Returns the item with the given name, or null if no item exists with the given name. |
Collection<String> |
getItemNames()
This method returns a collection of all the names of all the items within this section. |
Collection<IniItem> |
getItems()
Get a collection of all the items within this section. |
int |
getNumberOfItems()
Return the number of IniItems that this array has. |
boolean |
hasItem(IniItem item)
Predicate that returns true if an item is in this section. |
boolean |
hasItem(String name)
Predicate that returns true if an item already exists. |
int |
indexOf(IniItem item)
Returns the index of item that is in this section. |
int |
indexOf(String name)
Returns the index of item that is in this section. |
boolean |
isEmpty()
Predicate that returns true if the section has no items, false if it does have at least one item. |
Iterator<IniItem> |
iterator()
|
boolean |
merge(IniSection otherSection)
This method merges another IniSection to this section. |
void |
moveItem(int fromIndex,
int toIndex)
This method moves an item at index fromIndex to the index
toIndex . |
boolean |
removeItem(IniItem item)
Removes the item this section. |
Methods inherited from class org.dtools.ini.IniSection |
---|
equals, getEndLineComment, getName, getPostComment, getPreComment, getValidator, hashCode, isCaseSensitive, moveItem, removeAll, removeEndLineComment, removeItem, removeItem, removeItems, removePostComment, removePreComment, setEndLineComment, setPostComment, setPreComment, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AdvancedIniSection(String name)
Default constructor which creates a new instance of this
IniSection
and sets the IniSection
to have a
default IniValidator
and to be case insensitive.
name
- The name of this IniSection
.
InvalidNameException
- if the name of the IniSection
given is not considered valid by this object's IniValidator
.public AdvancedIniSection(String name, IniValidator validator)
Default constructor which creates a new instance of this
IniSection
and sets the IniSection
to have a
default IniValidator
and to be case insensitive.
name
- The name of this IniSection
.validator
- The validator of this IniSection
.
InvalidNameException
- if the name of the IniSection
given is not considered valid by this object's IniValidator
.public AdvancedIniSection(String name, boolean caseSensitive)
Default constructor which creates a new instance of this
IniSection
and sets the IniSection
to have a
default IniValidator
and to be case insensitive.
name
- The name of this IniSection
.caseSensitive
- Sets whether this IniSection
is case
sensitive.
InvalidNameException
- if the name of the IniSection
given is not considered valid by this object's IniValidator
.public AdvancedIniSection(String name, IniValidator validator, boolean caseSensitive)
Default constructor which creates a new instance of this
IniSection
and sets the IniSection
to have a
default IniValidator
and to be case insensitive.
name
- The name of this IniSection
.validator
- The validator of this IniSection
.caseSensitive
- Sets whether this IniSection
is case
sensitive.
InvalidNameException
- if the name of the IniSection
given is not considered valid by this object's IniValidator
.Method Detail |
---|
public boolean addItem(IniItem item)
IniSection
addItem
in class IniSection
item
- the item to add
public boolean addItem(IniItem item, int index)
IniSection
addItem
in class IniSection
item
- the item to addindex
- the index where to add the item, where 0 is the index of the
first item. Any items that already exists at this index will be
moved to index + 1
. If the value is greater than the
number of items within this section, then the item is appended to
the end of the section.
public IniItem addItem(String name)
IniSection
addItem
in class IniSection
name
- The name of the item to add.
public IniItem addItem(String itemName, int index)
IniSection
addItem
in class IniSection
itemName
- The name of the item to add.index
- The index where to add the item, where 0 is the index of the
first item. Any items that already exists at this index will be
moved to index + 1
. If the value is greater than the
number of items within this section, then the item is appended to
the end of the section.
protected IniItem createItem(String name)
IniSection
IniItem
with the same IniValidator
and case
sensitivity as this object.
createItem
in class IniSection
name
- The name of the IniItem
to create.
IniItem
with the same
IniValidator
and case sensitivity as this object.public void addItems(String... itemNames)
IniSection
addItems
in class IniSection
itemNames
- the names of the items to add.public IniItem getItem(int index)
IniSection
getItem
in class IniSection
index
- the index of the item to retrieve.
public IniItem getItem(String name)
IniSection
getItem
in class IniSection
name
- The name of the item.
public Collection<String> getItemNames()
IniSection
getItemNames
in class IniSection
public Collection<IniItem> getItems()
IniSection
getItems
in class IniSection
public int getNumberOfItems()
IniSection
getNumberOfItems
in class IniSection
public boolean hasItem(IniItem item)
IniSection
hasItem
in class IniSection
item
- The item to test.
public boolean hasItem(String name)
IniSection
hasItem
in class IniSection
name
- the name of the item to test
public int indexOf(IniItem item)
IniSection
-1
is returned.
indexOf
in class IniSection
item
- The IniItem whose index will be returned.
public int indexOf(String name)
IniSection
-1
is returned.
indexOf
in class IniSection
name
- The name of the item whose index will be returned.
public boolean isEmpty()
IniSection
isEmpty
in class IniSection
public boolean merge(IniSection otherSection)
IniSection
merge
in class IniSection
otherSection
- the other section to merge to this section
public void moveItem(int fromIndex, int toIndex)
IniSection
fromIndex
to the index
toIndex
.
moveItem
in class IniSection
fromIndex
- The index of the item to movetoIndex
- The index where to place the item, any items already at
that index will be moved to index+1
.public boolean removeItem(IniItem item)
IniSection
removeItem
in class IniSection
item
- The item to remove.
public Object clone()
IniSection
This class implements the Cloneable interface, but leaves implementation to subclasses which override this class.
clone
in class IniSection
thisObject.equals(
thisObject.clone() );
, but returns false for thisObject ==
thisObject.clone();
public Iterator<IniItem> iterator()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |