LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyFilter

java.lang.Object
  extended by leon.info.LyTag
      extended by leon.info.LyInfo
          extended by leon.info.LyObjectInfo
              extended by leon.info.LyFilter
All Implemented Interfaces:
java.lang.Cloneable, LyFilterElement, LyCommentInterface

public final class LyFilter
extends LyObjectInfo
implements LyFilterElement

The LyFilter class implements the description of a filter used to filter objects list.
A filter has a type which defines the type of filtering performed. Supported filter types are : Type.AND (and filter), Type.OR (or filter).
Filters contain filter elements which is an interface implemented buy both LyFilerExpression and by LyFilter. This means that a filter may contain simple filter expressions and sub-filters. This allows to build complex filters.

See also tag of leon.dtd

See Also:
LyFilterExpression, LyFilterRelation

Nested Class Summary
static class LyFilter.Type
          Filter types.
 
Nested classes/interfaces inherited from class leon.info.LyTag
LyTag.Model
 
Field Summary
static java.lang.String __VERSION
           
 
Fields inherited from class leon.info.LyObjectInfo
NULL, PART_ALL, PART_BIND, PART_DATA, PART_GUI, PART_LABEL
 
Constructor Summary
LyFilter()
          Constructor of a default filter.
LyFilter(LyFilter.Type type)
          Constructor of a filter with a given filter type.
LyFilter(LyFilter.Type type, boolean not)
          Constructor of a filter with a given filter type.
LyFilter(java.lang.String id, LyFilter template, LyFilter.Type type)
          Constructor of an identified filter.
LyFilter(java.lang.String id, LyFilter template, LyFilter.Type type, boolean not)
          Constructor of an identified filter.
 
Method Summary
 void addElement(LyFilterElement element)
          Adds a new element to this filter.
 void addElement(LyFilterElement element, int position)
          Inserts a new element to this filter at the given position.
 LyFilter cloneFilter()
          Clone this filter.
 LyFilter cloneFilter(LyDataSession session)
          Clone this filter.
 boolean contains(LyFieldInfo fieldInfo)
          Checks if an expression is found concerning the given field info.
 boolean contains(LyFilterElement element)
          Checks if a filter element is found in this filter.
 java.lang.String dump()
          Dumps current filter as a String.
 LyFilterElement getElement(int idx)
          Get a filter element from this filter at the given index.
 java.util.Vector<LyFilterElement> getElements()
          Returns the list of filter elements defined on this filter This is a COPY of the internal list, therefore this list may be freely manipulated by the application.
 LyInfoList<LyFieldInfo> getFieldInfos()
          Gets list of fieldInfos that this filter refers to.
 LyInfoList<LyFieldInfo> getFieldInfos(boolean recurseFilterRelation)
          Gets list of fieldInfos that this filter refers to.
 int getIndex(LyFilterElement element)
          Gets index for the given element.
 LyFilter getInvertedFilter()
          Clones and inverts this filter.
 LyFilter getPeerFilter()
          Get an peer equivalent of the current filter
 int getSize()
          Return the number of filter elements of this filter.
 LyFilter.Type getType()
          Accessor to the type of the filter.
 void getValues(LyFieldInfo fieldInfo, java.util.Vector<java.lang.Object> result)
          Gets all filter values corresponding to the given field info.
 boolean hasLocalFields()
          Indicate if this filter has a least one local fields.
 boolean isDynamic()
          Checks if this filter is dynamic or not.
 boolean isExtended()
          Indicates whether the filter is simple or extended.
 boolean isImpacted(LyValueSet values, boolean recurse)
          Checks if this filter if impacted by the changes contained in the value set.
 boolean isNot()
          Indicates if the filter is a negation of the expression.
 LyObjectList match(java.util.Enumeration<?> objects, LySimpleObjectList list)
          Adds to given list objects of the given list that match this filter.
 int match(java.util.Enumeration<java.lang.Object> objects)
          Counts objects of the given list that match this filter.
 boolean match(LyValueSet values)
          Check if the specified values matches current filter.
 boolean match(java.lang.Object object)
          Check if the specified object matches current filter.
 boolean matchClass(LyClassInfo classInfo)
          Indicates if current filter may be applied to the specified class info.
 void removeElement(LyFilterElement element)
          Removes an element from this filter.
 void setId(java.lang.String id)
          Sets id of this info.
 void setType(LyFilter.Type type)
          Sets filter type for this filter.
 void writeXml(java.io.PrintWriter pw)
          Writes XML corresponding to this filter element.
 
Methods inherited from class leon.info.LyObjectInfo
clone, getAlias, getData, getDataList, getDatas, getFilePrefix, getGroup, getInternalAlias, getInternalFilePrefix, getInternalName, getMarks, getName, getTemplate, getTip, getUserData, hasMark, hasMarks, hasTemplate, isTemplate, putData, putData, removeData, toName
 
Methods inherited from class leon.info.LyInfo
getApplication, getFile, getId, getInclude, isIncluded, isInternal, isInternal, isLoaded, isLocked, load, setApplication, setFile, toString
 
Methods inherited from class leon.info.LyTag
getCommentsEnd, getCommentsStart, getEnvironment, getModelType, getParent, getRootProject, hasAncestor, isExtern, setCommentsEnd, setCommentsStart, wasCloned
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface leon.info.LyFilterElement
getName
 
Methods inherited from interface leon.parser.LyCommentInterface
getCommentsEnd, getCommentsStart, setCommentsEnd, setCommentsStart
 

Field Detail

__VERSION

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

LyFilter

public LyFilter(java.lang.String id,
                LyFilter template,
                LyFilter.Type type)
Constructor of an identified filter.

Parameters:
id - Id of the filter.
template - Template model used to construct this filter.
type - Type of the filter. Supported filter types are : Type.AND (and filter), Type.OR (or filter).

LyFilter

public LyFilter(java.lang.String id,
                LyFilter template,
                LyFilter.Type type,
                boolean not)
Constructor of an identified filter.

Parameters:
id - Id of the filter.
template - Template model used to construct this filter.
type - Type of the filter.
not - Indicates if the filter is a negation of the expression. Supported filter types are : Type.AND (and filter), Type.OR (or filter).

LyFilter

public LyFilter(LyFilter.Type type)
Constructor of a filter with a given filter type.

Parameters:
type - Type of the filter. Supported filter types are : Type.AND (and filter), Type.OR (or filter).

LyFilter

public LyFilter(LyFilter.Type type,
                boolean not)
Constructor of a filter with a given filter type.

Parameters:
type - Type of the filter.
not - Indicates if the filter is a negation of the expression. Supported filter types are : Type.AND (and filter), Type.OR (or filter).

LyFilter

public LyFilter()
Constructor of a default filter. Default type is Type.AND (and filter).

Method Detail

setId

public void setId(java.lang.String id)
Sets id of this info.


cloneFilter

public LyFilter cloneFilter()
Clone this filter.


cloneFilter

public LyFilter cloneFilter(LyDataSession session)
Clone this filter.


getInvertedFilter

public LyFilter getInvertedFilter()
Clones and inverts this filter.

Returns:
the cloned and inverted filter

match

public boolean match(java.lang.Object object)
Check if the specified object matches current filter.

Specified by:
match in interface LyFilterElement
Parameters:
object - Object to check.
Returns:
True if the object matches filter criteria, false otherwise.
See Also:
LyFilterElement.match(java.lang.Object)

match

public boolean match(LyValueSet values)
Check if the specified values matches current filter.

Specified by:
match in interface LyFilterElement
Parameters:
values - Values to check.
Returns:
True if the object matches filter criteria, false otherwise.
See Also:
LyFilterElement.match(java.lang.Object)

matchClass

public boolean matchClass(LyClassInfo classInfo)
Indicates if current filter may be applied to the specified class info. Verifies that every field info contained in current filter is contained in the specified class info.

Parameters:
classInfo - Class info to check.
Returns:
True if the filter may be applied to specified class info, false otherwise.

dump

public java.lang.String dump()
Dumps current filter as a String.

Returns:
String representation of this filter.

writeXml

public void writeXml(java.io.PrintWriter pw)
Writes XML corresponding to this filter element.

Specified by:
writeXml in interface LyFilterElement
Parameters:
pw - PrintWriter on which the XML is written.

getFieldInfos

public LyInfoList<LyFieldInfo> getFieldInfos()
Gets list of fieldInfos that this filter refers to.

Returns:
List of fieldInfos that the filter depends on.

getFieldInfos

public LyInfoList<LyFieldInfo> getFieldInfos(boolean recurseFilterRelation)
Gets list of fieldInfos that this filter refers to.

Parameters:
recurseFilterRelation - indicates if search must be performed recursively on the relation filters elements. If false, only relation field info of the relation filters are added to the result list.
Returns:
List of fieldInfos that the filter depends on.

getValues

public void getValues(LyFieldInfo fieldInfo,
                      java.util.Vector<java.lang.Object> result)
Gets all filter values corresponding to the given field info.

Parameters:
fieldInfo - A field info.
result - result list.

match

public LyObjectList match(java.util.Enumeration<?> objects,
                          LySimpleObjectList list)
Adds to given list objects of the given list that match this filter. This method is provided for optimization purpose to avoid multiple accesses of filter elements.

Parameters:
objects - List to filter.
list - Result list (may be null).
Returns:
An objects list containing all objects of the list given as parameter that match this filter.

match

public int match(java.util.Enumeration<java.lang.Object> objects)
Counts objects of the given list that match this filter. This method is provided for optimization purpose to avoid multiple accesses of filter elements.

Parameters:
objects - List of objects to apply on filter.
Returns:
Number of objects matching this filter.

getElement

public LyFilterElement getElement(int idx)
Get a filter element from this filter at the given index.

Parameters:
idx - Index of the searched element.
Returns:
Filter element at the searched position which is either a new sub-filter or filterExpression or null if no such element exists.

getElements

public java.util.Vector<LyFilterElement> getElements()
Returns the list of filter elements defined on this filter This is a COPY of the internal list, therefore this list may be freely manipulated by the application.

Returns:
List of filter elements, or an empty Vector. Never returns null.

getSize

public int getSize()
Return the number of filter elements of this filter.

Returns:
Number of elements in the filter.

getType

public LyFilter.Type getType()
Accessor to the type of the filter.

Returns:
Filter type (Type.AND or Type.OR).

isExtended

public boolean isExtended()
Indicates whether the filter is simple or extended. A filter is extended if it contains another filter or if it contains filter expressions that does not apply on the same field info. If there is only one field info reached by many expressions, it should be a relation or choice field info (otherwise filter is considered as an extended one).

Returns:
true if the filter is an extended one, false if it is simple.

contains

public boolean contains(LyFieldInfo fieldInfo)
Checks if an expression is found concerning the given field info.

Parameters:
fieldInfo - The fieldInfo.
Returns:
True if an expression with the specified is found, false otherwise.

contains

public boolean contains(LyFilterElement element)
Checks if a filter element is found in this filter.

Parameters:
element - The filter element.
Returns:
True if the filter element is found, false otherwise.

isNot

public boolean isNot()
Indicates if the filter is a negation of the expression.

Returns:
true if the filter is a negation of the expression, false otherwise.

hasLocalFields

public boolean hasLocalFields()
Indicate if this filter has a least one local fields. Local fields with join or reverse damon are not taken into account.

Returns:
true if the filter only use local fields.

setType

public void setType(LyFilter.Type type)
Sets filter type for this filter.

Parameters:
type - New type for filter.
Throws:
java.lang.IllegalArgumentException - If the given type is one of the supported types (Type.AND or Type.OR).

addElement

public void addElement(LyFilterElement element)
Adds a new element to this filter.

Parameters:
element - Element to add to this filter. This element can be either a sub-filter or a filter expression.

addElement

public void addElement(LyFilterElement element,
                       int position)
Inserts a new element to this filter at the given position.

Parameters:
element - Element to add to this filter. This element can be either a sub-filter or a filter expression.
position - Position where the element is inserted.

removeElement

public void removeElement(LyFilterElement element)
Removes an element from this filter.

Parameters:
element - Element to remove from the filter.

getIndex

public int getIndex(LyFilterElement element)
Gets index for the given element.

Returns:
Index of the element in the filter.

isImpacted

public boolean isImpacted(LyValueSet values,
                          boolean recurse)
Checks if this filter if impacted by the changes contained in the value set.


isDynamic

public boolean isDynamic()
Checks if this filter is dynamic or not. The filter is dynamic when it has an element that depends on a dynamic value given by the session.


getPeerFilter

public LyFilter getPeerFilter()
Get an peer equivalent of the current filter

Returns:
a peer equivalent of the current filter

(c) January 2013 - W4 S.A.

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