Class BasicMethodRegistry

java.lang.Object
com.scriptbasic.executors.BasicMethodRegistry
All Implemented Interfaces:
MethodRegistry

public class BasicMethodRegistry
extends java.lang.Object
implements MethodRegistry
  • Constructor Summary

    Constructors 
    Constructor Description
    BasicMethodRegistry()  
  • Method Summary

    Modifier and Type Method Description
    java.lang.reflect.Method getJavaMethod​(java.lang.Class<?> klass, java.lang.String alias)
    Get the method for a given alias used to name a method in a specific Java class.
    void registerJavaMethod​(java.lang.String alias, java.lang.Class<?> klass, java.lang.String methodName, java.lang.Class<?>[] argumentTypes)
    Register a java method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getJavaMethod

      public java.lang.reflect.Method getJavaMethod​(java.lang.Class<?> klass, java.lang.String alias)
      Description copied from interface: MethodRegistry
      Get the method for a given alias used to name a method in a specific Java class.
      Specified by:
      getJavaMethod in interface MethodRegistry
      Parameters:
      klass - the class where the method is. If this parameter is null then the class will be fetched from the global registry of methods.
      alias - the alias with which the method was registered for a specific signature.
      Returns:
      the located method that match the name and the signature what was registered.
    • registerJavaMethod

      public void registerJavaMethod​(java.lang.String alias, java.lang.Class<?> klass, java.lang.String methodName, java.lang.Class<?>[] argumentTypes) throws BasicRuntimeException
      Description copied from interface: MethodRegistry
      Register a java method.
      Specified by:
      registerJavaMethod in interface MethodRegistry
      Parameters:
      alias - the alias of the method. This is the name how the BASIC program will refer to the method. Although the BASIC source code makes it optional to provide an alias it is not optional here. It may be same as the string contained in the parameter methodName but it should be passed here and should not be null
      klass - the class in which the method is implemented.
      methodName - the Java name of the method.
      argumentTypes - the argument classes that form the signature of the method together with the name and class of the method.
      Throws:
      BasicRuntimeException - is thrown if the registration of the alias is not unique in the actual interpreter. You can not register a name for a method and then later the same alias for a different method.