|
Business Components | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractCollection | +--java.util.AbstractList | +--java.util.Vector | +--oracle.jbo.ViewCriteria
A list of row criteria for a View Object's WHERE clause.
The lengths of the ViewCriteriaRow
s in the list must
all match the number of attributes in the View Object.
The following example of a user-defined function, demoCriteria
uses several methods in the ViewCriteria and
ViewCriteriaRow
classes to create and populate criteria rows and to demonstrate
"query-by-example".
The printViewObject is a helper function that executes the
View Object query and prints the results to the screen.
public static void demoCriteria(ApplicationModule appMod) { // Create and populate criteria rows to support query-by-example. ViewObject empView = appMod.createViewObject("emp", "d2e.EmpView"); ViewCriteria vc = empView.createViewCriteria(); ViewCriteriaRow vcRow = vc.createViewCriteriaRow(); // ViewCriteriaRow attribute name is case-sensitive. // ViewCriteriaRow attribute value requires operator and value. // Note also single-quotes around string value. vcRow.setAttribute("Job", "= 'MANAGER'"); vc.addElement(vcRow); vcRow = vc.createViewCriteriaRow(); vcRow.setAttribute("Sal", "> 2500"); vc.addElement(vcRow); empView.applyViewCriteria(vc); // Multiple rows are OR-ed in WHERE clause. System.out.println("Demo View Criteria"); //Should print employees that are MANAGER or have Sal > 2500 QueryDemo.printViewObject(empView); } public static void printViewObject(ViewObject vo) { // Execute the query, print results to the screen. vo.executeQuery(); while (vo.hasNext()) { Row row = vo.next();\ String rowDataStr = ""; // How many attributes (columns) is the View Object using? int numAttrs = vo.getAttributeCount(); // Column numbers start with 0, not 1. for (int columnNo = 0; columnNo < numAttrs; columnNo++) { // See also Row.getAttribute(String name). Object attrData = row.getAttribute(columnNo); rowDataStr += (attrData + "\t"); } System.out.println(rowDataStr); } }
Fields inherited from class java.util.Vector |
capacityIncrement,
elementCount,
elementData |
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary | |
ViewCriteria(ViewObject viewObject)
Creates an empty view criteria object. |
Method Summary | |
ViewCriteriaRow |
createViewCriteriaRow()
Creates a new criteria row as a ViewCriteriaRow object. |
int |
getAttributeIndexOf(java.lang.String name)
Finds the column associated with an attribute name. |
ViewObject |
getViewObject()
Gets the View Object that owns the view criteria. |
Methods inherited from class java.util.Vector |
add,
add,
addAll,
addAll,
addElement,
capacity,
clear,
clone,
contains,
containsAll,
copyInto,
elementAt,
elements,
ensureCapacity,
equals,
firstElement,
get,
hashCode,
indexOf,
indexOf,
insertElementAt,
isEmpty,
lastElement,
lastIndexOf,
lastIndexOf,
remove,
remove,
removeAll,
removeAllElements,
removeElement,
removeElementAt,
removeRange,
retainAll,
set,
setElementAt,
setSize,
size,
subList,
toArray,
toArray,
toString,
trimToSize |
Methods inherited from class java.util.AbstractList |
iterator,
listIterator,
listIterator |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ViewCriteria(ViewObject viewObject)
viewObject
- the owner of the ViewCriteria
.Method Detail |
public ViewObject getViewObject()
ViewObject
that contains the ViewCriteria
.public int getAttributeIndexOf(java.lang.String name)
name
- the column name.public ViewCriteriaRow createViewCriteriaRow()
ViewCriteriaRow
, an array for WHERE clause criteria.ViewCriteriaRow
|
Business Components | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |