Class BasicMethodRegistry

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

public class BasicMethodRegistry extends Object implements MethodRegistry
  • Constructor Details

    • BasicMethodRegistry

      public BasicMethodRegistry()
  • Method Details

    • getJavaMethod

      public Method getJavaMethod(Class<?> klass, 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(String alias, Class<?> klass, String methodName, 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.