Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ulu.view
Class UMethod  view UMethod download UMethod.java

java.lang.Object
  extended byjava.util.Observable
      extended byulu.view.Flagged
          extended byulu.view.UMethod
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
JAFMethod, ScriptedMethod

public class UMethod
extends Flagged
implements java.io.Serializable

Represents a method of a ViewItem that can be populated with parameters and then invoked.

Similar idea to the java.lang.reflect.Method, but I can't reuse that as it exposes no public constructors or factories, and doesn't quite do everything I need. Added a 'U' to the name for happy coexistence of short class names.

The ulu.view.Handler interface denotes something that will process a UMethod once it has been invoked.


Field Summary
protected  Handler handler
          handler that processes invocations of this method (may be the method itself, the item it belongs to, or whatever other implementation)
protected  java.lang.String Name
          name of this method
static java.lang.String PARAM_NAME_TARGET_OBJECT
          standard naming for a parameter (usually hidden) that represents the target object on which the method should be applied - useful for generating self-contained methods where the Handler needn't keep a reference to the specific target object (and is typically responsible for handling many instances of the method and many target objects)
protected  java.util.Vector params
          parameters that may be passed along with the method
protected  java.lang.Class Return
          the return type of this method
 
Fields inherited from class ulu.view.Flagged
FLAG_ALLOWED_VALS, FLAG_GROUP_MEMBERSHIP, FLAG_HIDDEN, FLAG_OPTIONAL, FLAG_RETURN_INLINE, FLAG_SUGGESTED_VALS, flags, MEMBERSHIP_GROUP_DEFAULT_VISIBLE, MEMBERSHIP_GROUP_GENERAL, MEMBERSHIP_GROUP_UBIQUITOUS
 
Fields inherited from class java.util.Observable
 
Constructor Summary
UMethod()
          null constructor for subclassing
UMethod(java.lang.String n, java.lang.Class ret, Handler h)
          constructor requires name and return type
 
Method Summary
 void addParam(UField f)
          add a parameter to the Method
 void addParams(ulu.ut.ParamString ps)
          Take an ulu.ut.ParamString and add an empty field for each embedded variable
 void addParams(ulu.ut.ParamString ps, java.lang.String input)
          Take an ulu.ut.ParamString along with an input data string, and add a field for each embedded variable, prefilled with the data from the input text (if there is any) - by default, all fields will be required String values, may wish to add some way of specifying required, read-only, etc.
 boolean complete()
          returns true if all required fields have been filled.
 int countParams()
          count number of parameters
 Handler getHandler()
          the handler for this Method (most commonly defined by the View that offers the method)
 java.lang.String getName()
          the name of the method
 UField getParam(java.lang.String name)
          get a parameter by name
 java.util.Enumeration getParams()
          enumerate the method's parameters
 java.lang.Class getReturn()
          the return class of the method (null indicates a void return)
 java.lang.Object invoke()
          invoke the method by delegating to a method-handler interface
 
Methods inherited from class ulu.view.Flagged
get, set
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_NAME_TARGET_OBJECT

public static final java.lang.String PARAM_NAME_TARGET_OBJECT
standard naming for a parameter (usually hidden) that represents the target object on which the method should be applied - useful for generating self-contained methods where the Handler needn't keep a reference to the specific target object (and is typically responsible for handling many instances of the method and many target objects)

See Also:
Constant Field Values

Name

protected java.lang.String Name
name of this method


Return

protected java.lang.Class Return
the return type of this method


params

protected java.util.Vector params
parameters that may be passed along with the method


handler

protected Handler handler
handler that processes invocations of this method (may be the method itself, the item it belongs to, or whatever other implementation)

Constructor Detail

UMethod

public UMethod()
null constructor for subclassing


UMethod

public UMethod(java.lang.String n,
               java.lang.Class ret,
               Handler h)
        throws java.lang.NullPointerException
constructor requires name and return type

Method Detail

getName

public java.lang.String getName()
the name of the method


getReturn

public java.lang.Class getReturn()
the return class of the method (null indicates a void return)


getHandler

public Handler getHandler()
the handler for this Method (most commonly defined by the View that offers the method)


countParams

public int countParams()
count number of parameters


addParam

public void addParam(UField f)
add a parameter to the Method


getParams

public java.util.Enumeration getParams()
enumerate the method's parameters


getParam

public UField getParam(java.lang.String name)
get a parameter by name


complete

public boolean complete()
returns true if all required fields have been filled. A well-behaved client will check this before allowing the method to be invoked, as it will always return null without going back to backend if not complete


invoke

public java.lang.Object invoke()
                        throws java.lang.Exception
invoke the method by delegating to a method-handler interface


addParams

public void addParams(ulu.ut.ParamString ps)

Take an ulu.ut.ParamString and add an empty field for each embedded variable

A convenient way to add several parameters at once - used to parse JDBC urls for example


addParams

public void addParams(ulu.ut.ParamString ps,
                      java.lang.String input)

Take an ulu.ut.ParamString along with an input data string, and add a field for each embedded variable, prefilled with the data from the input text (if there is any) - by default, all fields will be required String values, may wish to add some way of specifying required, read-only, etc. at a later date