org.erights.e.elib.prim
Class JavaMatcher

java.lang.Object
  |
  +--org.erights.e.elib.prim.JavaMatcher
All Implemented Interfaces:
EStackItem, Script
Direct Known Subclasses:
JavaInstanceMatcher, JavaStaticMatcher, JavaSugarMatcher

public abstract class JavaMatcher
extends Object
implements Script, EStackItem

Untamed: Abstract superclass of all the CRAPI-based wrappers of java.lang.reflect.Methods representing matchers for installing them in VTables as matchers.

Author:
Mark S. Miller

Field Summary
private  CallCounter myCallCounter
           
(package private)  java.lang.reflect.Method myMethod
           
 
Constructor Summary
(package private) JavaMatcher(java.lang.reflect.Method method)
           
 
Method Summary
 Object execute(Object self, String aVerb, Object[] args)
          Enabled:
(package private) abstract  String explain()
           
(package private) abstract  Object innerExecute(Object self, Object[] pair)
          Do the part of execute(java.lang.Object, java.lang.String, java.lang.Object[]) that's specific to a particular kind of JavaMatcher.
(package private) static boolean isMatcher(java.lang.reflect.Method method, int offset)
          Is this method a plausible matcher method?
 void protocol(Object optSelf, FlexList mTypes)
          Enabled:
 boolean respondsTo(Object optSelf, String verb, int arity)
          Enabled:
 Script shorten(Object optSelf, String aVerb, Object[] args)
          Enabled: Just returns this.
 void subPrintOn(TextWriter out, int priority)
          Enabled:
 String toString()
          Suppressed:
 void traceOn(TextWriter out)
          Enabled:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myMethod

final java.lang.reflect.Method myMethod

myCallCounter

private final CallCounter myCallCounter
Constructor Detail

JavaMatcher

JavaMatcher(java.lang.reflect.Method method)
Method Detail

isMatcher

static boolean isMatcher(java.lang.reflect.Method method,
                         int offset)
Is this method a plausible matcher method?

This isMatcher/2 only does part of the work, and should only be used from the isMatcher/1 methods in the concrete subclasses of this class.

Parameters:
method - The method to be tested.
offset - How many parameter positions should be skipped?
Returns:
Whether method's name is "match" and the parameters after offset have the types String and ConstList.

shorten

public Script shorten(Object optSelf,
                      String aVerb,
                      Object[] args)
Enabled: Just returns this.

Specified by:
shorten in interface Script
Parameters:
optSelf - If present, then a script could shorten using instance-specific data.
aVerb - Must be interned
args - Typically, only its arity is used. But OverloaderNode uses the types of the arguments to select among Java overloads.
Returns:
The Script to use in lieu of this one. Note that it's always correct a Script to just return itself.

innerExecute

abstract Object innerExecute(Object self,
                             Object[] pair)
Do the part of execute(java.lang.Object, java.lang.String, java.lang.Object[]) that's specific to a particular kind of JavaMatcher.

Parameters:
self - The object whose matcher is being invoked.
pair - A pair of a String and a ConstList, representing the verb and args of the original message, respectively.

execute

public Object execute(Object self,
                      String aVerb,
                      Object[] args)
Enabled:

Specified by:
execute in interface Script

protocol

public void protocol(Object optSelf,
                     FlexList mTypes)
Enabled:

Specified by:
protocol in interface Script
Parameters:
optSelf -
mTypes -

respondsTo

public boolean respondsTo(Object optSelf,
                          String verb,
                          int arity)
Enabled:

Specified by:
respondsTo in interface Script
Parameters:
optSelf -
verb -
arity -
Returns:

explain

abstract String explain()

subPrintOn

public void subPrintOn(TextWriter out,
                       int priority)
                throws IOException
Enabled:

IOException

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.

traceOn

public void traceOn(TextWriter out)
             throws IOException
Enabled:

Specified by:
traceOn in interface EStackItem
IOException


comments?