LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyInfoList<Info extends LyInfo>

java.lang.Object
  extended by leon.info.LyInfoList<Info>
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
LyInfoDataList

public class LyInfoList<Info extends LyInfo>
extends java.lang.Object
implements java.lang.Cloneable

This class is an utility class to manage a list of LyInfo. Its only purpose is to avoid duplicate code between all classes that extend LyInfo.
By default, this list doesn't accept multiple occurrences of the same info, but this mode can be set on to enable them (this mode can only be chosen at construction).
After construction, these lists are writable, but once turned to unwritable by lock method, they can't be modified anymore (nor returned to a writable state).

See Also:
LyInfo, LyObjectInfo

Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyInfoList()
          Default constructor with no parameters.
LyInfoList(boolean multiple)
          Constructor with choice of multiple occurrences or not.
LyInfoList(Info info)
          Constructs a new list and add the given info to it.
LyInfoList(Info[] infos)
          Constructs a new list from an array of infos
LyInfoList(java.util.List<Info> list)
          Constructs a new list from a List containing infos.
LyInfoList(LyInfoList<Info> infoList)
          Constructs a new list from an existing one.
 
Method Summary
 int addInfo(Info info)
          Adds a new info at the end of this info list.
 int addInfo(Info info, int position)
          Adds a new info to this info list at the specified position.
 void addList(java.util.List<Info> list)
          Adds all infos of the given list to this list.
 void addList(LyInfoList<Info> list)
          Adds all infos of the given list to this list.
 java.lang.Object clone()
          Returns a clone of this list.
 boolean contains(Info info)
          Checks if the given info is contained in this list.
 boolean contains(LyInfoList<Info> infos)
          Checks if the given list of infos are contained in this list.
 boolean contains(LyInfoList<Info> infos, boolean all)
          Checks if the given list of infos are contained in this list.
 boolean equals(java.lang.Object obj)
          Compare infolist content.
 java.lang.Class<?> getComponentType()
           
 int getIndex(Info info)
          Get index of a given info.
 Info getInfo(int index)
          Gets info at the specified index.
 Info getInfo(java.lang.String id)
          Fetches the info with the specified identifier or name (only works for stored infos that are instances of LyObjectInfo).
 Info getInfo(java.lang.String id, boolean byName)
          Fetches the info with the specified identifier or name (only works for stored infos that are instances of LyObjectInfo).
 java.util.Vector<Info> getInfos()
          Returns a vector containing all infos of this list.
 LyInfoList<Info> getInfos(java.util.BitSet marks)
          Shortcut for the previous method with 'matchAll' set to true (infos matching all marks requested).
 LyInfoList<Info> getInfos(java.util.BitSet marks, boolean matchAll)
          Gets infos that have the given marks (all or one of them).
<T extends Info>
LyInfoList<T>
getInfos(java.lang.Class<T> infoClass)
          Returns a sub-list of this list of all infos of a given java class.
 LyInfoList<Info> getInfos(int mark)
          Shortcut for the previous method with 'not' set to false (matching required).
 LyInfoList<Info> getInfos(int mark, boolean not)
          Gets the list of infos that match or that don't match a given mark.
 LyInfoList<Info> getInfosById()
          Returns a list containing all object infos of this list sorted by their id.
 LyInfoList<Info> getInfosByName()
          Returns a list containing all infos of this list sorted by their names.
 LyInfoList<Info> getInfosByName(LyEnvironment translationEnv)
          Returns a list containing all infos of this list sorted by their names.
 LyInfoList<Info> getObjectInfosByName()
          Deprecated. Use getInfosByName(LyEnvironment).
 LyInfoList<Info> getObjectInfosByName(LyEnvironment translationEnv)
          Deprecated. Use getInfosByName(LyEnvironment).
 int getSize()
          Returns the number of infos in this list.
 boolean isWritable()
          Checks writable mode on this list.
 void lock()
          Locks this list (turn it to unwritable).
 int removeInfo(Info info)
          Removes the specified info from this info list.
 void resetInfos()
          Resets info list (remove all infos from this list).
 LyInfo[] toArray()
          Returns an array containing all of the elements in this collection.
 java.lang.String toString()
          Dumps content of this list.
 
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

LyInfoList

public LyInfoList()
Default constructor with no parameters. This new list won't allow multiple occurrences of the same info.


LyInfoList

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

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

LyInfoList

public LyInfoList(LyInfoList<Info> infoList)
Constructs a new list from an existing one. The new list allows multiple occurrences if the copied one allows this.

Parameters:
infoList - Copied list.

LyInfoList

public LyInfoList(java.util.List<Info> list)
Constructs a new list from a List containing infos. The new list doesn't multiple occurrences even if the copied vector contains multiple occurrences of the same objects.

Parameters:
list - Vector from which infos are copied.

LyInfoList

public LyInfoList(Info[] infos)
Constructs a new list from an array of infos

Parameters:
infos - Infos array.

LyInfoList

public LyInfoList(Info info)
Constructs a new list and add the given info to it. Other infos can be added after if needed before locking the list.

Parameters:
info - Info added in our new list.
Method Detail

getComponentType

public java.lang.Class<?> getComponentType()

isWritable

public final boolean isWritable()
Checks writable mode on this list.

Returns:
True if the list is writable, false otherwise.

getInfo

public final Info getInfo(java.lang.String id)
Fetches the info with the specified identifier or name (only works for stored infos that are instances of LyObjectInfo). The first search is made by id, and if it fails a search is then done by name.

Parameters:
id - Identifier (or name) of the requested info
Returns:
The reference to the requested info, or null if it could not be found.

getInfo

public final Info getInfo(java.lang.String id,
                          boolean byName)
Fetches the info with the specified identifier or name (only works for stored infos that are instances of LyObjectInfo).

Parameters:
id - Identifier or name of the requested info, as specified by the following parameter.
byName - Boolean indicating if the search is done on id or on name.
Returns:
Reference to the requested info, or null if it could not be found.

getInfos

public final LyInfoList<Info> getInfos(java.util.BitSet marks,
                                       boolean matchAll)
Gets infos that have the given marks (all or one of them). This method is only available for a list of LyObjectInfo.

Parameters:
marks - The requested marks
matchAll - Indicates if the info must have at least one mark (false) or all of them (true).
Returns:
A list of objectInfos from this list that have the given marks (may be empty).

getInfos

public final LyInfoList<Info> getInfos(java.util.BitSet marks)
Shortcut for the previous method with 'matchAll' set to true (infos matching all marks requested).

Parameters:
marks - The requested marks.
Returns:
List of infos of this list matching all given marks. (may be empty).
See Also:
getInfos(java.util.BitSet, boolean)

getInfos

public final LyInfoList<Info> getInfos(int mark,
                                       boolean not)
Gets the list of infos that match or that don't match a given mark. This method is provided to allow optimization if only of mark is searched on infos of this list.

Parameters:
mark - The requested mark
not - To invert the search : the result are the infos that have not the mark.
Returns:
List of infos of this list matching (or not matching) the given mark (may be empty).

getInfos

public final LyInfoList<Info> getInfos(int mark)
Shortcut for the previous method with 'not' set to false (matching required).

Parameters:
mark - The requested mark.
Returns:
List of infos of this list matching the given mark (may be empty).
See Also:
getInfos(java.util.BitSet, boolean)

getSize

public final int getSize()
Returns the number of infos in this list.

Returns:
Number of infos of this list.

getInfo

public final Info getInfo(int index)
Gets info at the specified index. This method is kept for upward compatibility.

Parameters:
index - Index of the requested info.
Returns:
Info at the given index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If index is negative, or greater than or equal to the number of infos in the list.

getInfos

public final java.util.Vector<Info> getInfos()
Returns a vector containing all infos of this list. This is a COPY of the internal list, therefore this list may be freely manipulated by the application.

Returns:
Set of infos of this list, or an empty Vector.

getInfos

public <T extends Info> LyInfoList<T> getInfos(java.lang.Class<T> infoClass)
Returns a sub-list of this list of all infos of a given java class.

Parameters:
infoClass - The java class.
Returns:
The sub-list of all infos of the given java class.

getInfosById

public final LyInfoList<Info> getInfosById()
Returns a list containing all object infos of this list sorted by their id.

Returns:
Vector of infos of this list.

getObjectInfosByName

public final LyInfoList<Info> getObjectInfosByName()
Deprecated. Use getInfosByName(LyEnvironment).

Returns a list containing all object infos of this list sorted by their names.


getInfosByName

public final LyInfoList<Info> getInfosByName()
Returns a list containing all infos of this list sorted by their names. The sort does not translate the names from the environment

Returns:
List of infos of this list.

getObjectInfosByName

public final LyInfoList<Info> getObjectInfosByName(LyEnvironment translationEnv)
Deprecated. Use getInfosByName(LyEnvironment).

Returns a list containing all object infos of this list sorted by their names.


getInfosByName

public final LyInfoList<Info> getInfosByName(LyEnvironment translationEnv)
Returns a list containing all infos of this list sorted by their names.

Parameters:
translationEnv - optional environment to translate strings
Returns:
List of infos of this list.

lock

public final void lock()
Locks this list (turn it to unwritable). Once locked, this list can't become writable anymore and won't accept any modification of its content.


addInfo

public int addInfo(Info info,
                   int position)
Adds a new info to this info list at the specified position.

Parameters:
info - Info that should be added.
position - Requested position. 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 the info 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 final int addInfo(Info info)
Adds a new info at the end of this info list.

Parameters:
info - Info that should be added
Returns:
Effective index where the info was inserted. -1 if the info 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 this info list.

Parameters:
info - Info to remove.
Returns:
Index of the removed info, -1 if the info was not in this list.
Throws:
java.lang.IllegalStateException - If this list is not writable.

addList

public void addList(LyInfoList<Info> list)
Adds all infos of the given list to this list.

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

addList

public void addList(java.util.List<Info> list)
Adds all infos of the given list to this list.

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 info list (remove all infos from this list).

Throws:
java.lang.IllegalStateException - If this list is not writable.

getIndex

public final int getIndex(Info info)
Get index of a given info.

Parameters:
info - The searched info.
Returns:
Index if the info in this list if it was found, -1 otherwise.

contains

public final boolean contains(Info info)
Checks if the given info is contained in this list.

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

contains

public final boolean contains(LyInfoList<Info> infos)
Checks if the given list of infos are contained in this list.

Parameters:
infos - the searched list of infos.
Returns:
True if all the infos of the list are found in this list, false otherwise.

contains

public final boolean contains(LyInfoList<Info> infos,
                              boolean all)
Checks if the given list of infos are contained in this list.

Parameters:
infos - the searched list of infos.
Returns:
True if all the infos of the list are found in this list, false otherwise.

clone

public java.lang.Object clone()
Returns a clone of this list. Redefined to properly clone internal table of infos.

Overrides:
clone in class java.lang.Object
Returns:
Cloned list.

equals

public boolean equals(java.lang.Object obj)
Compare infolist content.

Overrides:
equals in class java.lang.Object
Parameters:
obj - another list to compare content

toString

public java.lang.String toString()
Dumps content of this list.

Overrides:
toString in class java.lang.Object

toArray

public LyInfo[] toArray()
Returns an array containing all of the elements in this collection.

Returns:
an array containing the elements of this collection

(c) January 2013 - W4 S.A.

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