Class JCOBridge
General helper class
public static class JCOBridge
- Inheritance
-
JCOBridge
- Inherited Members
Properties
Global
The global instance pointer set with Globalize(IJVMBridgeCore, bool)
public static IJVMBridgeCore Global { get; }
Property Value
IsCLRHostingProcess
public static bool IsCLRHostingProcess { get; }
Property Value
LastBindingException
Reports last Exception raised from JCOBridge subsystem
public static Exception LastBindingException { get; }
Property Value
Methods
BiThrow<TException>(params object[])
Initialize and throw an instance of TException in JVM and then in CLR
public static void BiThrow<TException>(params object[] args) where TException : JVMBridgeException
Parameters
argsobject[]The arguments of the
TExceptionconstructor
Type Parameters
TExceptionA Type extending JVMBridgeException
Cast<TObject>(IJVMBridgeBase, bool)
Casts the input object implemeneting IJVMBridgeBase into TObject
public static TObject Cast<TObject>(IJVMBridgeBase obj, bool checkTypes = false)
Parameters
objIJVMBridgeBaseIJVMBridgeBase to convert to
TObjectcheckTypesboolIf true executes a check using IsInstanceOf<T>() before cast, default is false
Returns
- TObject
The return value converted to
TObject
Type Parameters
TObjectThe return type expected which implements IJVMBridgeBase
CheckForPrimitive(Type)
Check if type is one of string, bool, byte, char, double, float, int, long, short or array of previous types
public static bool CheckForPrimitive(Type type)
Parameters
Returns
- bool
true if
typeis one of string, bool, byte, char, double, float, int, long, short or array of previous types
CheckForPrimitive<TType>()
Check if TType is one of string, bool, byte, char, double, float, int, long, short
public static bool CheckForPrimitive<TType>()
Returns
Type Parameters
TTypePrimitive types or array of primitives types
CheckForRawPrimitive(Type)
Check if type is one of bool, byte, char, double, float, int, long, short or array of previous types
public static bool CheckForRawPrimitive(Type type)
Parameters
Returns
- bool
true if
typeis one of bool, byte, char, double, float, int, long, short or array of previous types
CheckForRawPrimitive<TType>()
Check if TType is one of bool, byte, char, double, float, int, long, short
public static bool CheckForRawPrimitive<TType>()
Returns
Type Parameters
TTypePrimitive types or array of primitives types
Convert(JavaException)
Converts a generic JavaException into a known exception
public static Exception Convert(JavaException jException)
Parameters
jExceptionJavaExceptionThe JavaException to be converted
Returns
- Exception
The exception converted into an instance of JVMBridgeException or JavaException if it is not convertible
Convert<TException>(JavaException)
Converts a generic JavaException into a known exception
public static TException Convert<TException>(JavaException jException) where TException : JVMBridgeException
Parameters
jExceptionJavaExceptionThe JavaException to be converted
Returns
- TException
The exception converted into
TExceptionor JavaException if it is not convertible
Type Parameters
TExceptionExpected JVMBridgeException class of the exception
Convert<TReturn>(object)
Converts a generic object
public static TReturn Convert<TReturn>(object obj)
Parameters
objobjectThe value to be converted
Returns
- TReturn
The return value converted to
TReturn, or null
Type Parameters
TReturnThe return type expected: a class inherited from IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
GetMainClasses(Assembly)
Retrieve all Main-Class from the assembly
public static IDictionary<string, Type> GetMainClasses(Assembly assembly)
Parameters
Returns
- IDictionary<string, Type>
A IDictionary<TKey, TValue> containing the name of the Main-Class and its Type
Globalize(IJVMBridgeCore, bool)
Creates a new global instance pointer
public static void Globalize(this IJVMBridgeCore wrapper, bool thrownOnError = true)
Parameters
wrapperIJVMBridgeCoreThe IJVMBridgeCore instance to be globalized
thrownOnErrorboolRaise exception if an instance was previously globalized
Launch(Type, params string[])
Launch the type with the args arguments
public static void Launch(Type type, params string[] args)
Parameters
typeTypeThe Type extending IJVMBridgeMain
argsstring[]The arguments of the main method
Launch<TClass>(params string[])
Launch the TClass class with the args arguments
public static void Launch<TClass>(params string[] args) where TClass : IJVMBridgeMain
Parameters
argsstring[]The arguments of the main method
Type Parameters
TClassA type which is defined as Main-Class
RaiseEventOrException(Exception)
Public method to publish e into logging chain
public static void RaiseEventOrException(Exception e)
Parameters
RaiseEventOrException(string, params object[])
Public method to publish a message into logging chain
public static void RaiseEventOrException(string messageFormat, params object[] args)
Parameters
RegisterException(Type)
Registers a generic Type, which inherit from JVMBridgeException, to be used in Convert<TException>(JavaException)
public static void RegisterException(Type jException)
Parameters
jExceptionTypeThe Type, which inherit from JVMBridgeException, to be registered
RegisterException<TException>()
Registers a generic TException, which inherit from JVMBridgeException, to be used in Convert<TException>(JavaException)
public static void RegisterException<TException>() where TException : JVMBridgeException
Type Parameters
TExceptionExpected a type inherited from JVMBridgeException class of the exception
RegisterExceptions(IEnumerable<Type>)
Registers a generic Type, which inherit from JVMBridgeException, to be used in Convert<TException>(JavaException)
public static void RegisterExceptions(IEnumerable<Type> jExceptions)
Parameters
jExceptionsIEnumerable<Type>The Types, which inherit from JVMBridgeException, to be registered
RegisterExceptions(Assembly)
Registers a set of JVMBridgeException to be used in Convert<TException>(JavaException)
public static void RegisterExceptions(this Assembly assembly)
Parameters
assemblyAssemblyThe Assembly to scan for type inherited from JVMBridgeException
RegisterWrapper(Type, Type)
Registers a wrapper class to be used when generics has interfaces
public static void RegisterWrapper(Type tInterface, Type tWrapper)
Parameters
tInterfaceTypeThe Type extending IJVMBridgeBase
tWrapperTypeThe Type implementing
tInterface
RegisterWrapper<TWrapper, TInterface>()
Registers a wrapper class to be used when generics has interfaces
public static void RegisterWrapper<TWrapper, TInterface>() where TWrapper : TInterface where TInterface : IJVMBridgeBase
Type Parameters
TWrapperThe wrapper implementing
TInterfaceTInterfaceThe interface to be associated to the
TWrapper
SetEventOrExceptionHandler(EventHandler<EventOrExceptionEventArgs>)
Set a user defined EventHandler<TEventArgs> to receive info from JCOBridge
public static void SetEventOrExceptionHandler(EventHandler<EventOrExceptionEventArgs> handler)
Parameters
handlerEventHandler<EventOrExceptionEventArgs>An handler in the form of EventHandler<TEventArgs>, null to set back the default
Throw<TException>(params object[])
Initialize and throw an instance of TException in JVM
public static void Throw<TException>(params object[] args) where TException : JVMBridgeException
Parameters
argsobject[]The arguments of the
TExceptionconstructor
Type Parameters
TExceptionA Type extending JVMBridgeException
To<TObject>(CLREventData)
Converts data associated to CLREventData into TObject
public static TObject To<TObject>(CLREventData data)
Parameters
dataCLREventDataCLREventData to convert
Returns
- TObject
The return value converted to
TObject, or null
Type Parameters
TObjectThe return type expected: IJavaObject, Enum, primitive types or array of primitives types
To<TObject>(CLREventData, int)
Converts extra data associated to CLREventData into TObject
public static TObject To<TObject>(CLREventData data, int index)
Parameters
dataCLREventDataCLREventData to convert
indexintThe index within ExtraData to be converted
Returns
- TObject
The return value converted to
TObject, or null
Type Parameters
TObjectThe return type expected: IJavaObject, Enum, primitive types or array of primitives types