Class ClsLoader

java.lang.Object
org.apache.jena.sparql.util.ClsLoader

public class ClsLoader extends Object
Helper for loading class instances

This is primarily used as a helper by MappedLoader to dynamically load in functions without a need to pre-register them. Since these class names originate from URIs which may contain characters which are not valid in Java class names this class implements a simple escaping scheme.

Escaping Scheme

Escaping is applied only to the last portion of the class name, typically MappedLoader takes care of mapping a function library namespace prefix into a java package name and likely only the last portion (the function name) will require escaping.

If the first character of the class name is invalid it is replaced with F_. If any subsequent characters are invalid they are ignored and the subsequent valid character (if any) is promoted to upper case giving a camel case style valid class name.

For example if the last portion of the class name were foo-bar-faz then we would end up with an escaped class name of fooBarFaz.

  • Constructor Details

    • ClsLoader

      public ClsLoader()
  • Method Details

    • loadClass

      public static Class<?> loadClass(String classNameOrURI)
    • loadClass

      public static Class<?> loadClass(String classNameOrURI, Class<?> requiredClass)
    • loadAndInstantiate

      public static Object loadAndInstantiate(String uri, Class<?> requiredClass)
    • escape

      public static String escape(String className)