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
obj
IJVMBridgeBaseIJVMBridgeBase to convert to
TObject
checkTypes
boolIf true executes a check using IsInstanceOf<T>() before cast, default is false
Returns
- TObject
The return value converted to
TObject
Type Parameters
TObject
The 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
type
is 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
TType
Primitive 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
type
is 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
TType
Primitive types or array of primitives types
Convert(JavaException)
Converts a generic JavaException into a known exception
public static Exception Convert(this JavaException jException)
Parameters
jException
JavaExceptionThe 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
jException
JavaExceptionThe JavaException to be converted
Returns
- Exception
The exception converted into
TException
or JavaException if it is not convertible
Type Parameters
TException
Expected JVMBridgeException class of the exception
Convert<TReturn>(object)
Converts a generic object
public static TReturn Convert<TReturn>(this object obj)
Parameters
obj
objectThe value to be converted
Returns
- TReturn
The return value converted to
TReturn
, or null
Type Parameters
TReturn
The 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
bridgeCoreInstance
TClassReference to IJVMBridgeBase instantiated class
Returns
- dynamic
The JVM instance of the instantiated
TClass
Type Parameters
TClass
The class to be instantiated
FilterJCOBridgeArguments<T>(T[])
Filters arguments related to JCOBridge
public static T[] FilterJCOBridgeArguments<T>(this T[] args)
Parameters
args
T[]The argument to filter
Returns
- T[]
The filtered arguments
Type Parameters
T
The 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
eventListener
IJavaObjectThe 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
listener
IJVMBridgeBaseThe IJVMBridgeBase to be initialized
Returns
- IJVMBridgeBase
The initialized
listener
for 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
jniClass
stringThe 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
jniClass
stringThe class name to check
Returns
ReleaseListener(IJVMBridgeBase)
Release a IJVMBridgeBase from the JVM
public static IJVMBridgeBase ReleaseListener(this IJVMBridgeBase listener)
Parameters
listener
IJVMBridgeBaseThe IJVMBridgeBase to be released
Returns
- IJVMBridgeBase
The released
listener
for subsequent operations
ToNative(IJVMBridgeBase)
Converts a IJVMBridgeBase input to an object manageable from the JVM
public static object ToNative(this IJVMBridgeBase arg)
Parameters
arg
IJVMBridgeBaseAny 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
arg
objectAny 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
args
object[]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
data
CLREventDataCLREventData to convert
Returns
- TObject
The return value converted to
TObject
, or null
Type Parameters
TObject
The 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
data
CLREventDataCLREventData to convert
index
intThe index within ExtraData to be converted
Returns
- TObject
The return value converted to
TObject
, or null
Type Parameters
TObject
The 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
enumerable
JVMBridgeBaseEnumerable<TClass, TJava>The class inherited from JVMBridgeBaseEnumerable<TClass, TObject> implementing IEnumerableExtension
converter
Func<TJava, TNet>Set the Func<T, TResult> used to convert from
TJava
toTNet
while ieration is done
Returns
- JVMBridgeBaseEnumerable<TClass, TNet>
The
enumerable
withconverter
added in the execution chain
Type Parameters
TClass
The class implementing IJVMBridgeBase
TJava
The type of objects to enumerate in Java space
TNet
The 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
enumerable
TEnumerableThe
TEnumerable
implementing IEnumerableExtensionprefetch
boolSet to true to allocate a JVMBridgeBasePrefetchableEnumerator, false for the standard JVMBridgeBaseEnumerator
Returns
- TEnumerable
The
enumerable
with prefetch enabled/disabled
Type Parameters
TEnumerable
A 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
enumerable
TEnumerableThe
TEnumerable
implementing IEnumerableExtensionuseThread
boolSet to true to allocate a Thread, false to use ThreadPool
threadPriority
ThreadPriorityThe ThreadPriority to use, default is AboveNormal to give more priority to prefetch operation based on thread
Returns
- TEnumerable
The
enumerable
with Thread enabled
Type Parameters
TEnumerable
A type implementing IEnumerableExtension
Remarks
This option is take into account only if prefetch is enabled