/** * Example license header for Java files * * http://www.andromda.org/ */ // // Attention: Generated code! Do not modify by hand! // Generated by: HibernateSearchParameter.vsl in andromda-spring-cartridge. // package org.andromda.spring; import java.util.regex.Pattern; /** * A CriteriaSearchParameter represents a parameter for a CriteriaSearch. *
*
* The parameterValue is the actual value to be searched for. *
*
* The parameterPattern describes the actual parameter which shall be considered for * the search. It contains the dot-seperated path and the name of the parameter starting at the * rootEntity of the actual CriteriaSearch. The pattern of a the street of an address * of a person would look like address.street (assuming the entity structure to be * aPerson.getAddress().getStreet()). *
*
* Usually, if a parameter is null (or if the parameter is of type String * and empty), it is not considered for a search. If searchIfNull is true * it is explicitly searched for the parameter to be null (or empty if the parameter is of type * String).
*
* The comparator defines the comparator for the parameter. For parameters of type * String the default comparator is the LIKE_COMPARATOR. The * EQUAL_COMPARATOR is default for other parameters. * * @author Stefan Reichert * @author Peter Friese * @author Chad Brandon */ public class CriteriaSearchParameter extends SearchParameter { public static final Pattern PATTERN = Pattern.compile("\\."); /** Order relevance not set */ public static final int RELEVANCE_UNSET = -1; private Object parameterValue; private String parameterPattern; private net.sf.hibernate.expression.MatchMode matchMode = null; private int orderDirection = ORDER_UNSET; private int orderRelevance = RELEVANCE_UNSET; /** * Constructor for CriteriaSearchParameter. Sets searchIfNull to * false and uses the EQUAL_COMPARATOR. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). */ public CriteriaSearchParameter(Object parameterValue, String parameterPattern) { this(parameterValue, parameterPattern, false, EQUAL_COMPARATOR); } /** * Constructor for CriteriaSearchParameter for a String parameter. * Sets searchIfNull to false and uses the * LIKE_COMPARATOR. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). */ public CriteriaSearchParameter(String parameterValue, String parameterPattern) { this(parameterValue, parameterPattern, false, LIKE_COMPARATOR); } /** * Constructor for CriteriaSearchParameter for a String[] parameter. * Sets searchIfNull to false and uses the * LIKE_COMPARATOR. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). */ public CriteriaSearchParameter(String[] parameterValue, String parameterPattern) { this(parameterValue, parameterPattern, false, LIKE_COMPARATOR); } /** * Constructor for CriteriaSearchParameter. Sets searchIfNull to false. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). */ public CriteriaSearchParameter(Object parameterValue, String parameterPattern, int comparator) { this(parameterValue, parameterPattern, false, comparator); } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. */ public CriteriaSearchParameter( Object parameterValue, String parameterPattern, boolean searchIfNull) { this(parameterValue, parameterPattern, searchIfNull, EQUAL_COMPARATOR); } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. */ public CriteriaSearchParameter( String parameterValue, String parameterPattern, boolean searchIfNull) { this(parameterValue, parameterPattern, searchIfNull, LIKE_COMPARATOR); } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. */ public CriteriaSearchParameter( String[] parameterValue, String parameterPattern, boolean searchIfNull) { this(parameterValue, parameterPattern, searchIfNull, LIKE_COMPARATOR); } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. * @param comparator Indicates what comparator is to be used (e.g. like, =, <, ...). */ public CriteriaSearchParameter( Object parameterValue, String parameterPattern, boolean searchIfNull, int comparator) { super(parameterPattern, parameterValue); this.parameterValue = parameterValue; this.parameterPattern = parameterPattern; super.setSearchIfNull(searchIfNull); this.setComparator(comparator); } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( Object parameterValue, String parameterPattern, boolean searchIfNull, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern, searchIfNull); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( String parameterValue, String parameterPattern, boolean searchIfNull, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern, searchIfNull); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( String[] parameterValue, String parameterPattern, boolean searchIfNull, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern, searchIfNull); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param searchIfNull Indicates whether the query should contain an * IS NULL if the parameter is null. * @param comparator Indicates what comparator is to be used (e.g. like, =, <, ...). * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( String parameterValue, String parameterPattern, boolean searchIfNull, int comparator, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern, searchIfNull, comparator); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param comparator Indicates what comparator is to be used (e.g. like, =, <, ...). * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( Object parameterValue, String parameterPattern, int comparator, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern, comparator); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( Object parameterValue, String parameterPattern, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( String parameterValue, String parameterPattern, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern); this.matchMode = matchMode; } /** * Constructor for CriteriaSearchParameter. * * @param parameterValue The actual value of the parameter. * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). * @param matchMode The hibernate matchmode to be used in string comparisons. */ public CriteriaSearchParameter( String[] parameterValue, String parameterPattern, net.sf.hibernate.expression.MatchMode matchMode) { this(parameterValue, parameterPattern); this.matchMode = matchMode; } /** * @return The pattern of this parameter (dot-seperated path e.g. person.address.street). */ public String getParameterPattern() { return parameterPattern; } /** * Sets the pattern of this parameter. * * @param parameterPattern The pattern of this parameter (dot-seperated path e.g. person.address.street). */ public void setParameterPattern(String parameterPattern) { this.parameterPattern = parameterPattern; } /** * Parse the parameter pattern and return the last part of the name. * * @param parameterPattern The parameter pattern. * @return The last part of the parameter pattern, i.e. the attribute name. */ private String parseParameterName(String parameterPattern) { // parsing the pattern of the parameter String[] path = CriteriaSearchParameter.PATTERN.split(parameterPattern); return path[path.length - 1]; } /** * @return The last part of the parameter pattern, i.e. the attribute name. */ public String getParameterName() { return parseParameterName(parameterPattern); } /** * @return The value of this parameter. */ public Object getParameterValue() { return parameterValue; } /** * Sets the value of this parameter. * * @param parameterValue The value of this parameter. */ public void setParameterValue(Object parameterValue) { this.parameterValue = parameterValue; } /** * @return The hibernate matchmode of this parameter. */ public net.sf.hibernate.expression.MatchMode getMatchMode() { return matchMode; } /** * Sets the hibernate matchmode of this parameter. * * @param matchMode The hibernate matchmode. */ public void setMatchMode(net.sf.hibernate.expression.MatchMode matchMode) { this.matchMode = matchMode; } /** * @return The order (ascending or descending) for this parameter. * @see ORDER_ASC * @see ORDER_DESC * @see ORDER_UNSET */ public int getOrderDirection() { return orderDirection; } /** * Sets the ordering for this parameter. * * @param orderDirection The ordering for this parameter. */ public void setOrderDirection(int orderDirection) { this.orderDirection = orderDirection; } /** * @return The relevance for this parameter. * @see RELEVANCE_UNSET */ public int getOrderRelevance() { return orderRelevance; } /** * Sets the ordering relevance for this parameter. * * @param order The ordering relevance for this parameter. */ public void setOrderRelevance(int relevance) { this.orderRelevance = relevance; } private static final long serialVersionUID = 1L; }