Package ortus.boxlang.runtime.runnables
Class BoxClassSupport
java.lang.Object
ortus.boxlang.runtime.runnables.BoxClassSupport
The methods in this class are an extension of IClassRunnable. They are here for better readability
since IClassRunnables don't extend a base class, there are placeholders in the BoxClassTransformer that
delegate to these methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectassign(IClassRunnable thisClass, IBoxContext context, Key key, Object value) Assign a value to a keystatic ObjectassignStatic(DynamicObject targetClass, IBoxContext context, Key name, Object value) static ObjectassignStatic(StaticScope staticScope, IBoxContext context, Key name, Object value) Assign a value to a key in the static scopestatic StringasString(IClassRunnable thisClass) Represent as string, or throw exception if not possiblestatic BooleancanInvokeImplicitAccessor(IClassRunnable thisClass, IBoxContext context) A helper to look at the "InvokeImplicitAccessor" annotation and application settings, caching the resultstatic BooleancanOutput(IBoxContext context, DynamicObject targetClass) A helper to look at the "output" annotation from a static context By default in BoxLang this is falsestatic BooleancanOutput(IClassRunnable thisClass) A helper to look at the "output" annotation, caching the resultstatic voiddefaultProperties(IClassRunnable thisClass, IBoxContext context) I handle creating default values for all properties definedstatic Objectdereference(IClassRunnable thisClass, IBoxContext context, Key key, Boolean safe) Dereference this object by a key and return the value, or throw exceptionstatic ObjectdereferenceAndInvoke(IClassRunnable thisClass, IBoxContext context, Key name, Object[] positionalArguments, Boolean safe) Dereference this object by a key and invoke the result as an invokable (UDF, java method) using positional argumentsstatic ObjectdereferenceAndInvoke(IClassRunnable thisClass, IBoxContext context, Key name, Map<Key, Object> namedArguments, Boolean safe) Dereference this object by a key and invoke the result as an invokable (UDF, java method)static ObjectdereferenceAndInvokeStatic(DynamicObject targetClass, IBoxContext context, Key name, Object[] positionalArguments, Boolean safe) static ObjectdereferenceAndInvokeStatic(DynamicObject targetClass, IBoxContext context, Key name, Map<Key, Object> namedArguments, Boolean safe) static ObjectdereferenceAndInvokeStatic(DynamicObject targetClass, StaticScope staticScope, IBoxContext context, Key name, Object[] positionalArguments, Boolean safe) static ObjectdereferenceAndInvokeStatic(DynamicObject targetClass, StaticScope staticScope, IBoxContext context, Key name, Map<Key, Object> namedArguments, Boolean safe) static ObjectdereferenceStatic(DynamicObject targetClass, IBoxContext context, Key name, Boolean safe) static ObjectdereferenceStatic(StaticScope staticScope, IBoxContext context, Key name, Boolean safe) Dereference this object by a key and return the value, or throw exception This is a static version of the dereference methodstatic DynamicObjectensureClass(IBoxContext context, Object obj, List<ImportDefinition> imports) Take an object and check if it is a dynamic object already or a string, in which case, load the class.static IStructgetAnnotations(IBoxContext context, DynamicObject targetClass) Get the annotations from a static contextstatic IClassRunnablegetBottomClass(IClassRunnable thisClass) Get the bottom class in the inheritance chainstatic BoxMetagetBoxMeta(IClassRunnable thisClass) Get the class metadatastatic IStructgetMetaData(IClassRunnable thisClass) Get the combined metadata for this function and all it's parameters This follows the format of Lucee and Adobe's "combined" metadata This is to keep compatibility for CFML enginesstatic StaticScopegetStaticScope(IBoxContext context, DynamicObject targetClass) Get the static scope from a static contextstatic BooleanhasAccessors(IClassRunnable targetClass) A helper to look at the "accessors" annotation By default in BoxLang this is truestatic voidpseudoConstructor(IClassRunnable thisClass, IBoxContext context) Call the pseudo constructorstatic voidregisterInterface(IClassRunnable thisClass, BoxInterface _interface) Register an interface with a classstatic IClassRunnableresolveClassForUDF(IClassRunnable thisClass, Function udf) Given a UDF instance, resolve the actual class it was declared in.static voidsetSuper(IClassRunnable thisClass, IClassRunnable _super) Set the super class.static voidvalidateAbstractMethods(IClassRunnable thisClass, Map<Key, AbstractFunction> abstractMethods) Vailidate if a given class instance satisfies the interface.
-
Constructor Details
-
BoxClassSupport
public BoxClassSupport()
-
-
Method Details
-
pseudoConstructor
Call the pseudo constructor- Parameters:
thisClass- The class to call the pseudo constructor oncontext- The context to use
-
defaultProperties
I handle creating default values for all properties defined- Parameters:
thisClass- The class to create default properties forcontext- The context to use
-
getBoxMeta
Get the class metadata- Parameters:
thisClass- The class to get the metadata for- Returns:
- The metadata Box object
-
asString
Represent as string, or throw exception if not possible- Parameters:
thisClass- The class to represent- Returns:
- The string representation
-
canOutput
A helper to look at the "output" annotation, caching the result- Parameters:
thisClass- The class to check- Returns:
- Whether the function can output
-
canInvokeImplicitAccessor
A helper to look at the "InvokeImplicitAccessor" annotation and application settings, caching the result- Parameters:
thisClass- The class to checkcontext- The context to use- Returns:
- Whether the function can invoke implicit accessors
-
setSuper
Set the super class. This method is called by the BoxClassTransformer- Parameters:
thisClass- The class to set the super class on_super- The super class
-
getBottomClass
Get the bottom class in the inheritance chain- Parameters:
thisClass- The class to start from- Returns:
- The bottom class if any, otherwise the class itself
-
assign
Assign a value to a key- Parameters:
thisClass- The class to assign the value tocontext- The context to usekey- The key to assignvalue- The value to assign- Returns:
- The assigned value
-
dereference
public static Object dereference(IClassRunnable thisClass, IBoxContext context, Key key, Boolean safe) Dereference this object by a key and return the value, or throw exception- Parameters:
thisClass- The class to dereferencecontext- The context to usekey- The key to dereferencesafe- Whether to throw an exception if the key is not found- Returns:
- The requested object
-
dereferenceAndInvoke
public static Object dereferenceAndInvoke(IClassRunnable thisClass, IBoxContext context, Key name, Object[] positionalArguments, Boolean safe) Dereference this object by a key and invoke the result as an invokable (UDF, java method) using positional arguments- Parameters:
thisClass- The class to dereferencecontext- The context to usename- The key to dereferencepositionalArguments- The positional arguments to pass to the invokablesafe- Whether to throw an exception if the key is not found- Returns:
- The requested object
-
dereferenceAndInvoke
public static Object dereferenceAndInvoke(IClassRunnable thisClass, IBoxContext context, Key name, Map<Key, Object> namedArguments, Boolean safe) Dereference this object by a key and invoke the result as an invokable (UDF, java method)- Parameters:
thisClass- The class to dereferencecontext- The context to usename- The name of the key to dereference, which becomes the method namenamedArguments- The arguments to pass to the invokablesafe- If true, return null if the method is not found, otherwise throw an exception- Returns:
- The requested return value or null
-
getMetaData
Get the combined metadata for this function and all it's parameters This follows the format of Lucee and Adobe's "combined" metadata This is to keep compatibility for CFML engines- Parameters:
thisClass- The class to get the metadata for- Returns:
- The metadata as a struct
-
registerInterface
Register an interface with a class- Parameters:
thisClass- The class to register the interface with_interface- The interface to register
-
dereferenceAndInvokeStatic
public static Object dereferenceAndInvokeStatic(DynamicObject targetClass, IBoxContext context, Key name, Map<Key, Object> namedArguments, Boolean safe) -
dereferenceAndInvokeStatic
public static Object dereferenceAndInvokeStatic(DynamicObject targetClass, IBoxContext context, Key name, Object[] positionalArguments, Boolean safe) -
assignStatic
public static Object assignStatic(DynamicObject targetClass, IBoxContext context, Key name, Object value) -
dereferenceStatic
public static Object dereferenceStatic(DynamicObject targetClass, IBoxContext context, Key name, Boolean safe) -
dereferenceAndInvokeStatic
public static Object dereferenceAndInvokeStatic(DynamicObject targetClass, StaticScope staticScope, IBoxContext context, Key name, Map<Key, Object> namedArguments, Boolean safe) -
dereferenceAndInvokeStatic
public static Object dereferenceAndInvokeStatic(DynamicObject targetClass, StaticScope staticScope, IBoxContext context, Key name, Object[] positionalArguments, Boolean safe) -
assignStatic
public static Object assignStatic(StaticScope staticScope, IBoxContext context, Key name, Object value) Assign a value to a key in the static scope- Parameters:
staticScope- The static scope to assign the value tocontext- The context to usename- The key to assignvalue- The value to assign- Returns:
- The assigned value
-
dereferenceStatic
public static Object dereferenceStatic(StaticScope staticScope, IBoxContext context, Key name, Boolean safe) Dereference this object by a key and return the value, or throw exception This is a static version of the dereference method- Parameters:
staticScope- The static scope to dereferencecontext- The context to usename- The key to dereferencesafe- Whether to throw an exception if the key is not found- Returns:
- The requested object
-
getStaticScope
Get the static scope from a static context- Parameters:
context- The context to usetargetClass- The class to get the static scope from- Returns:
- The static scope
-
getAnnotations
Get the annotations from a static context- Parameters:
context- The context to usetargetClass- The class to get the annotations from- Returns:
- The annotations
-
canOutput
A helper to look at the "output" annotation from a static context By default in BoxLang this is false- Parameters:
context- The context to usetargetClass- The class to check- Returns:
- Whether the function can output
-
hasAccessors
A helper to look at the "accessors" annotation By default in BoxLang this is true- Parameters:
targetClass- The class to check- Returns:
- Whether the class has accessors
-
ensureClass
public static DynamicObject ensureClass(IBoxContext context, Object obj, List<ImportDefinition> imports) Take an object and check if it is a dynamic object already or a string, in which case, load the class.- Parameters:
context- The context to useobj- The object to checkimports- The imports to use- Returns:
- The dynamic object of the class
-
validateAbstractMethods
public static void validateAbstractMethods(IClassRunnable thisClass, Map<Key, AbstractFunction> abstractMethods) Vailidate if a given class instance satisfies the interface. Throws a BoxValidationException if not.- Parameters:
thisClass- The class to validateabstractMethods- The abstract methods for which to check the class for existence- Throws:
BoxValidationException- If the class does not satisfy the interface
-
resolveClassForUDF
Given a UDF instance, resolve the actual class it was declared in. A method may be inherited by a child class, and copied down into the child class's variables scope, but at runtime, the class it uses as `super` needs to be relative to the current location.
-