Business Components

oracle.jbo
Class ViewCriteria

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--oracle.jbo.ViewCriteria

public class ViewCriteria
extends java.util.Vector

A list of row criteria for a View Object's WHERE clause.

The lengths of the ViewCriteriaRows 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);
       }
    }
 

Since:
JDeveloper 3.0
See Also:
Serialized Form

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

ViewCriteria

public ViewCriteria(ViewObject viewObject)
Creates an empty view criteria object.
Parameters:
viewObject - the owner of the ViewCriteria.
Method Detail

getViewObject

public ViewObject getViewObject()
Gets the View Object that owns the view criteria.
Returns:
the ViewObject that contains the ViewCriteria.

getAttributeIndexOf

public int getAttributeIndexOf(java.lang.String name)
Finds the column associated with an attribute name.
Parameters:
name - the column name.
Returns:
a column index.

createViewCriteriaRow

public ViewCriteriaRow createViewCriteriaRow()
Creates a new criteria row as a ViewCriteriaRow object. A ViewCriteriaRow object is an array for WHERE clause criteria.
Returns:
a ViewCriteriaRow, an array for WHERE clause criteria.
See Also:
ViewCriteriaRow

Business Components