LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyInfoDataList<Info extends LyInfo,Data>

java.lang.Object
  extended by leon.info.LyInfoList<Info>
      extended by leon.info.LyInfoDataList<Info,Data>
All Implemented Interfaces:
java.lang.Cloneable

public final class LyInfoDataList<Info extends LyInfo,Data>
extends LyInfoList<Info>

This class is an utility class to manage a list of Info with an associated data. This data is untyped to allow different usages.
By default, this list doesn't accept multiple occurrences of the same pair (info, data) but this mode can be set on to enable them (this mode can only be chosen at beginning).
At start, these lists are writable, but can't be modified anymore, once turned to unwritable.

See Also:
LyInfo, LyObjectInfo

Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyInfoDataList()
          Default constructor with no parameters.
LyInfoDataList(boolean multiple)
          Constructor with choice of multiple occurrences or not.
LyInfoDataList(LyInfoDataList<Info,Data> infoDataList)
          Constructor with choice of multiple occurrences or not.
 
Method Summary
 int addInfo(Info info, Data data)
          Adds a new pair (info, data) to this list at the end of the list.
 int addInfo(Info info, Data data, int position)
          Adds a new pair (info, data) to this list at the given position.
 int addInfo(Info info, int position)
          Adds a new info with no associated data to this list at the given position.
 void addList(LyInfoDataList<Info,Data> list)
          Adds all infos of the given list to this list.
 boolean contains(Info info, Data data)
          Checks if the given pair (info, data) is contained in this list.
 Data getData(Info info)
          Gets data associated to the given info.
 Data getData(int index)
          Gets data at the specified index.
 int getIndex(Info info, Data data)
          Get index of a pair (info, data) in this list.
 int removeInfo(Info info)
          Removes the specified info from the info list.
 int removeInfo(Info info, Data data)
          Removes the specified pair (info, data) from this list.
 void resetInfos()
          Resets this list (remove all pairs from this list).
 
Methods inherited from class leon.info.LyInfoList
addInfo, addList, addList, clone, contains, contains, contains, equals, getComponentType, getIndex, getInfo, getInfo, getInfo, getInfos, getInfos, getInfos, getInfos, getInfos, getInfos, getInfosById, getInfosByName, getInfosByName, getObjectInfosByName, getObjectInfosByName, getSize, isWritable, lock, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LyInfoDataList

public LyInfoDataList()
Default constructor with no parameters. Multiple occurrences are not allowed.


LyInfoDataList

public LyInfoDataList(boolean multiple)
Constructor with choice of multiple occurrences or not.

Parameters:
multiple - Boolean indicating if multiple occurrences are allowed or not.

LyInfoDataList

public LyInfoDataList(LyInfoDataList<Info,Data> infoDataList)
Constructor with choice of multiple occurrences or not.

Parameters:
multiple - Boolean indicating if multiple occurrences are allowed or not.
Method Detail

getData

public Data getData(int index)
Gets data at the specified index.

Parameters:
index - Index of the requested data.
Returns:
Data at the given index (may be null if no data specified at this position).
Throws:
java.lang.ArrayIndexOutOfBoundsException - If index is negative, or greater than or equal to the number of infos in the list.

getData

public Data getData(Info info)
Gets data associated to the given info.

Parameters:
info - Info for which an associated data is searched.
Returns:
Data associated to this info (may be null if no data specified for this info).
Throws:
java.lang.IllegalArgumentException - If the given info is not in this list.

addInfo

public int addInfo(Info info,
                   Data data,
                   int position)
Adds a new pair (info, data) to this list at the given position.

Parameters:
info - Info that should be added.
data - Data associated to the info.
position - Position where this pair has to be added. A negative index or an index greater than or equal to the number of infos in this list, means insert at the end of the list.
Returns:
Effective index where the pair (info, data) was inserted. -1 if this pair was already in this list and this list doesn't allow multiple occurrences.
Throws:
java.lang.IllegalStateException - If this list is not writable.

addInfo

public int addInfo(Info info,
                   Data data)
Adds a new pair (info, data) to this list at the end of the list.

Parameters:
info - Info that should be added.
data - Data associated to the info.
Returns:
Effective index where the pair (info, data) was inserted. -1 if this pair was already in this list and this list doesn't allow multiple occurrences.
Throws:
java.lang.IllegalStateException - If this list is not writable.

addInfo

public int addInfo(Info info,
                   int position)
Adds a new info with no associated data to this list at the given position.

Overrides:
addInfo in class LyInfoList<Info extends LyInfo>
Parameters:
info - Info that should be added.
position - Position where this info must be added. A negative index or an index greater than or equal to the number of infos in this list, means insert at the end of the list.
Returns:
Effective index where the info was inserted. -1 if this info associated with no data was already in this list and this list doesn't allow multiple occurrences.
Throws:
java.lang.IllegalStateException - If this list is not writable.

removeInfo

public int removeInfo(Info info)
Removes the specified info from the info list. This method is overridden to remove data associated to this info. If several pairs are registered with the same field info, the first one is removed.

Overrides:
removeInfo in class LyInfoList<Info extends LyInfo>
Parameters:
info - Info to remove.
Returns:
Index of the removed pair, -1 if the info was not in this list.

removeInfo

public int removeInfo(Info info,
                      Data data)
Removes the specified pair (info, data) from this list.

Parameters:
info - Info to remove.
data - Data associated to the info.
Returns:
Index of the removed pair, -1 if the given pair couldn't be found.
Throws:
java.lang.IllegalStateException - If this list is not writable.

addList

public void addList(LyInfoDataList<Info,Data> list)
Adds all infos of the given list to this list. If the given list is a LyInfoDataList, associated data are also copied. Otherwise, infos are added with no associated data.

Parameters:
list - List of infos to add to this list.
Throws:
java.lang.IllegalStateException - If this list is not writable.

resetInfos

public void resetInfos()
Resets this list (remove all pairs from this list).

Overrides:
resetInfos in class LyInfoList<Info extends LyInfo>
Throws:
java.lang.IllegalStateException - If this list is not writable.

getIndex

public int getIndex(Info info,
                    Data data)
Get index of a pair (info, data) in this list.

Parameters:
info - The searched info.
data - Associated data (null means no data).
Returns:
Index if this pair in the list if it was found, -1 otherwise.

contains

public boolean contains(Info info,
                        Data data)
Checks if the given pair (info, data) is contained in this list.

Parameters:
info - The searched info.
info - Its associated data.
Returns:
True if the given pair is found in this list, false otherwise.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com