?? criteria.java
字號:
{ throw new RuntimeException("getJoinL() in Criteria is no longer supported!"); } /** * Adds an 'IN' clause with the criteria supplied as an Object * array. For example: * * <p> * FOO.NAME IN ('FOO', 'BAR', 'ZOW') * <p> * * where 'values' contains three objects that evaluate to the * respective strings above when .toString() is called. * * If a criterion for the requested column already exists, it is * replaced. * * @param column The column to run the comparison on * @param values An Object[] with the allowed values. * @return A modified Criteria object. */ public Criteria addIn(String column, Object[] values) { add(column, (Object) values, Criteria.IN); return this; } /** * Adds an 'IN' clause with the criteria supplied as an int array. * For example: * * <p> * FOO.ID IN ('2', '3', '7') * <p> * * where 'values' contains those three integers. * * If a criterion for the requested column already exists, it is * replaced. * * @param column The column to run the comparison on * @param values An int[] with the allowed values. * @return A modified Criteria object. */ public Criteria addIn(String column, int[] values) { add(column, (Object) values, Criteria.IN); return this; } /** * Adds an 'IN' clause with the criteria supplied as a List. * For example: * * <p> * FOO.NAME IN ('FOO', 'BAR', 'ZOW') * <p> * * where 'values' contains three objects that evaluate to the * respective strings above when .toString() is called. * * If a criterion for the requested column already exists, it is * replaced. * * @param column The column to run the comparison on * @param values A List with the allowed values. * @return A modified Criteria object. */ public Criteria addIn(String column, List values) { add(column, (Object) values, Criteria.IN); return this; } /** * Adds a 'NOT IN' clause with the criteria supplied as an Object * array. For example: * * <p> * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW') * <p> * * where 'values' contains three objects that evaluate to the * respective strings above when .toString() is called. * * If a criterion for the requested column already exists, it is * replaced. * * @param column The column to run the comparison on * @param values An Object[] with the disallowed values. * @return A modified Criteria object. */ public Criteria addNotIn(String column, Object[] values) { add(column, (Object) values, Criteria.NOT_IN); return this; } /** * Adds a 'NOT IN' clause with the criteria supplied as an int * array. For example: * * <p> * FOO.ID NOT IN ('2', '3', '7') * <p> * * where 'values' contains those three integers. * * If a criterion for the requested column already exists, it is * replaced. * * @param column The column to run the comparison on * @param values An int[] with the disallowed values. * @return A modified Criteria object. */ public Criteria addNotIn(String column, int[] values) { add(column, (Object) values, Criteria.NOT_IN); return this; } /** * Adds a 'NOT IN' clause with the criteria supplied as a List. * For example: * * <p> * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW') * <p> * * where 'values' contains three objects that evaluate to the * respective strings above when .toString() is called. * * If a criterion for the requested column already exists, it is * replaced. * * @param column The column to run the comparison on * @param values A List with the disallowed values. * @return A modified Criteria object. */ public Criteria addNotIn(String column, List values) { add(column, (Object) values, Criteria.NOT_IN); return this; } /** * Adds "ALL " to the SQL statement. */ public void setAll() { selectModifiers.add(ALL.toString()); } /** * Adds "DISTINCT " to the SQL statement. */ public void setDistinct() { selectModifiers.add(DISTINCT.toString()); } /** * Sets ignore case. * * @param b True if case should be ignored. * @return A modified Criteria object. */ public Criteria setIgnoreCase(boolean b) { ignoreCase = b; return this; } /** * Is ignore case on or off? * * @return True if case is ignored. */ public boolean isIgnoreCase() { return ignoreCase; } /** * Set single record? Set this to <code>true</code> if you expect the query * to result in only a single result record (the default behaviour is to * throw a TorqueException if multiple records are returned when the query * is executed). This should be used in situations where returning multiple * rows would indicate an error of some sort. If your query might return * multiple records but you are only interested in the first one then you * should be using setLimit(1). * * @param b set to <code>true</code> if you expect the query to select just * one record. * @return A modified Criteria object. */ public Criteria setSingleRecord(boolean b) { singleRecord = b; return this; } /** * Is single record? * * @return True if a single record is being returned. */ public boolean isSingleRecord() { return singleRecord; } /** * Set cascade. * * @param b True if cascade is set. * @return A modified Criteria object. */ public Criteria setCascade(boolean b) { cascade = b; return this; } /** * Is cascade set? * * @return True if cascade is set. */ public boolean isCascade() { return cascade; } /** * Set limit. * * @param limit An int with the value for limit. * @return A modified Criteria object. */ public Criteria setLimit(int limit) { this.limit = limit; return this; } /** * Get limit. * * @return An int with the value for limit. */ public int getLimit() { return limit; } /** * Set offset. * * @param offset An int with the value for offset. * @return A modified Criteria object. */ public Criteria setOffset(int offset) { this.offset = offset; return this; } /** * Get offset. * * @return An int with the value for offset. */ public int getOffset() { return offset; } /** * Add select column. * * @param name A String with the name of the select column. * @return A modified Criteria object. */ public Criteria addSelectColumn(String name) { selectColumns.add(name); return this; } /** * Get select columns. * * @return An StringStack with the name of the select * columns. */ public UniqueList getSelectColumns() { return selectColumns; } /** * Get select modifiers. * * @return An UniqueList with the select modifiers. */ public UniqueList getSelectModifiers() { return selectModifiers; } /** * Add group by column name. * * @param groupBy The name of the column to group by. * @return A modified Criteria object. */ public Criteria addGroupByColumn(String groupBy) { groupByColumns.add(groupBy); return this; } /** * Add order by column name, explicitly specifying ascending. * * @param name The name of the column to order by. * @return A modified Criteria object. */ public Criteria addAscendingOrderByColumn(String name) { orderByColumns.add(name + ' ' + ASC); return this; } /** * Add order by column name, explicitly specifying descending. * * @param name The name of the column to order by. * @return A modified Criteria object. */ public Criteria addDescendingOrderByColumn(String name) { orderByColumns.add(name + ' ' + DESC); return this; } /** * Get order by columns. * * @return An UniqueList with the name of the order columns. */ public UniqueList getOrderByColumns() { return orderByColumns; } /** * Get group by columns. * * @return An UniqueList with the name of the groupBy clause. */ public UniqueList getGroupByColumns() { return groupByColumns; } /** * Get Having Criterion. * * @return A Criterion that is the having clause. */ public Criterion getHaving() { return having; } /** * Remove an object from the criteria. * * @param key A String with the key to be removed. * @return The removed object. */ public Object remove(String key) { Object foo = super.remove(key); if (foo instanceof Criterion) { return ((Criterion) foo).getValue(); } return foo; } /** * Build a string representation of the Criteria. * * @return A String with the representation of the Criteria. */ public String toString() { StringBuffer sb = new StringBuffer("Criteria:: "); Iterator it = keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); sb.append(key).append("<=>") .append(super.get(key).toString()).append(": "); } try { sb.append("\nCurrent Query SQL (may not be complete or applicable): ") .append(BasePeer.createQueryDisplayString(this)); } catch (Exception exc) { } return sb.toString(); } /** * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. */ public boolean equals(Object crit) { boolean isEquiv = false; if (crit == null || !(crit instanceof Criteria)) { isEquiv = false; } else if (this == crit) { isEquiv = true; } else if (this.size() == ((Criteria) crit).size()) { Criteria criteria = (Criteria) crit; if (this.offset == criteria.getOffset() && this.limit == criteria.getLimit() && ignoreCase == criteria.isIgnoreCase() && singleRecord == criteria.isSingleRecord() && cascade == criteria.isCascade() && dbName.equals(criteria.getDbName()) && selectModifiers.equals(criteria.getSelectModifiers()) && selectColumns.equals(criteria.getSelectColumns()) && orderByColumns.equals(criteria.getOrderByColumns()) ) { isEquiv = true; for (Iterator it = criteria.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); if (this.containsKey(key)) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -