Class JCOBridgeExtensions
General class with helpers for JVM initialization
public static class JCOBridgeExtensions
- Inheritance
-
JCOBridgeExtensions
- Inherited Members
Remarks
Do not use it directly. Shall be public, but it is used internally from other classes
Methods
Cast<TObject>(IJVMBridgeBase, bool)
Casts the input object implemeneting IJVMBridgeBase into TObject
public static TObject Cast<TObject>(this 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(this 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(this 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(this 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 Exception Convert<TException>(this JavaException jException) where TException : JVMBridgeException<TException>
Parameters
jExceptionJavaExceptionThe JavaException to be converted
Returns
- Exception
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>(this 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
Dyn<TClass>(TClass)
Returns the dynamic accessor of an instance of TClass
public static dynamic Dyn<TClass>(this TClass bridgeCoreInstance) where TClass : IJVMBridgeBase
Parameters
bridgeCoreInstanceTClassReference to IJVMBridgeBase instantiated class
Returns
- dynamic
The JVM instance of the instantiated
TClass
Type Parameters
TClassThe class to be instantiated
FilterJCOBridgeArguments<T>(T[])
Filters arguments related to JCOBridge
public static T[] FilterJCOBridgeArguments<T>(this T[] args)
Parameters
argsT[]The argument to filter
Returns
- T[]
The filtered arguments
Type Parameters
TThe argument type, generally it is a string
GetListener(IJavaObject)
Returns the IJVMBridgeBase associated to the JVM reference
public static IJVMBridgeBase GetListener(this IJavaObject eventListener)
Parameters
eventListenerIJavaObjectThe JVM reference associated to the IJVMBridgeBase
Returns
InitializeListener(IJVMBridgeBase)
Request the initialization of the Listener from the JVM. The listener is a new class which inherits from JVMBridgeListener
public static IJVMBridgeBase InitializeListener(this IJVMBridgeBase listener)
Parameters
listenerIJVMBridgeBaseThe IJVMBridgeBase to be initialized
Returns
- IJVMBridgeBase
The initialized
listenerfor subsequent operations
IsPrimitiveConvertible(IJavaType)
Returns true if the class represents a primitive type
public static bool IsPrimitiveConvertible(this IJavaType jniClass)
Parameters
Returns
IsPrimitiveConvertible(string)
Returns true if the class represents a primitive type
public static bool IsPrimitiveConvertible(this string jniClass)
Parameters
jniClassstringThe class name to check
Returns
IsRawPrimitive(IJavaType)
Returns true if the class represents a primitive type
public static bool IsRawPrimitive(this IJavaType jniClass)
Parameters
Returns
IsRawPrimitive(string)
Returns true if the class represents a primitive type
public static bool IsRawPrimitive(this string jniClass)
Parameters
jniClassstringThe class name to check
Returns
ReleaseListener(IJVMBridgeBase)
Release a IJVMBridgeBase from the JVM
public static IJVMBridgeBase ReleaseListener(this IJVMBridgeBase listener)
Parameters
listenerIJVMBridgeBaseThe IJVMBridgeBase to be released
Returns
- IJVMBridgeBase
The released
listenerfor subsequent operations
ToNative(IJVMBridgeBase)
Converts a IJVMBridgeBase input to an object manageable from the JVM
public static object ToNative(this IJVMBridgeBase arg)
Parameters
argIJVMBridgeBaseAny IJVMBridgeBase object
Returns
- object
The object expected from the JVM
ToNative(object)
Converts a generic input to an object manageable from the JVM
public static object ToNative(this object arg)
Parameters
argobjectAny IJVMBridgeBase or generic objects
Returns
- object
The expected object from the JVM
ToNative(object[])
Converts a generic input array to an array manageable from the JVM. This extension is usable when there is an input like
params object[] args with a mixed CLR types.
public static object[] ToNative(this object[] args)
Parameters
argsobject[]Any mixed array of IJVMBridgeBase or generic objects
Returns
- object[]
The array elements expected from the JVM
To<TObject>(CLREventData)
Converts data associated to CLREventData into TObject
public static TObject To<TObject>(this 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>(this 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
WithConvert<TClass, TJava, TNet>(JVMBridgeBaseEnumerable<TClass, TJava>, Func<TJava, TNet>)
Creates a new instance of enumerable, adding the converter in the execution chain
public static JVMBridgeBaseEnumerable<TClass, TNet> WithConvert<TClass, TJava, TNet>(this JVMBridgeBaseEnumerable<TClass, TJava> enumerable, Func<TJava, TNet> converter) where TClass : JVMBridgeBase, IEnumerableExtension, new()
Parameters
enumerableJVMBridgeBaseEnumerable<TClass, TJava>The class inherited from JVMBridgeBaseEnumerable<TClass, TObject> implementing IEnumerableExtension
converterFunc<TJava, TNet>Set the Func<T, TResult> used to convert from
TJavatoTNetwhile ieration is done
Returns
- JVMBridgeBaseEnumerable<TClass, TNet>
The
enumerablewithconverteradded in the execution chain
Type Parameters
TClassThe class implementing IJVMBridgeBase
TJavaThe type of objects to enumerate in Java space
TNetThe new converted object after enumeration reported from Current
WithPrefetch<TEnumerable>(TEnumerable, bool)
Enable or disable prefetch on enumerable, default is with prefetch disabled
public static TEnumerable WithPrefetch<TEnumerable>(this TEnumerable enumerable, bool prefetch = true) where TEnumerable : IEnumerableExtension
Parameters
enumerableTEnumerableThe
TEnumerableimplementing IEnumerableExtensionprefetchboolSet to true to allocate a JVMBridgeBasePrefetchableEnumerator, false for the standard JVMBridgeBaseEnumerator
Returns
- TEnumerable
The
enumerablewith prefetch enabled/disabled
Type Parameters
TEnumerableA type implementing IEnumerableExtension
WithThread<TEnumerable>(TEnumerable, bool, ThreadPriority)
Enable or disable use of a Thread on enumerable, default is to use ThreadPool
public static TEnumerable WithThread<TEnumerable>(this TEnumerable enumerable, bool useThread = true, ThreadPriority threadPriority = ThreadPriority.AboveNormal) where TEnumerable : IEnumerableExtension
Parameters
enumerableTEnumerableThe
TEnumerableimplementing IEnumerableExtensionuseThreadboolSet to true to allocate a Thread, false to use ThreadPool
threadPriorityThreadPriorityThe ThreadPriority to use, default is AboveNormal to give more priority to prefetch operation based on thread
Returns
- TEnumerable
The
enumerablewith Thread enabled
Type Parameters
TEnumerableA type implementing IEnumerableExtension
Remarks
This option is take into account only if prefetch is enabled