Esempio n. 1
0
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.util.Map.put(K, V)` throws a number of exceptions, see:
        //
        //     https://developer.android.com/reference/java/util/Map#put(K,%20V)
        //
        internal void Put(K key, V value)
        {
            if (id_put == IntPtr.Zero)
            {
                id_put = JNIEnv.GetMethodID(map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr r = JavaConvert.WithLocalJniHandle(key,
                                                      lrefKey => JavaConvert.WithLocalJniHandle(value,
                                                                                                lrefValue => {
                try {
                    return(JNIEnv.CallObjectMethod(Handle, id_put, new JValue(lrefKey), new JValue(lrefValue)));
                } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NotSupportedException(ex.Message, ex);
                } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new InvalidCastException(ex.Message, ex);
                } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NullReferenceException(ex.Message, ex);
                } catch (Java.Lang.IllegalArgumentException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new ArgumentException(ex.Message, ex);
                }
            }
                                                                                                )
                                                      );

            JNIEnv.DeleteLocalRef(r);
        }
Esempio n. 2
0
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.util.List.add(int, Object)` throws a number of exceptions, see:
        //
        //     https://developer.android.com/reference/java/util/List?hl=en#add(int,%20E)
        //
        public void Insert(int index, object item)
        {
            if (id_insert == IntPtr.Zero)
            {
                id_insert = JNIEnv.GetMethodID(arraylist_class, "add", "(ILjava/lang/Object;)V");
            }

            JavaConvert.WithLocalJniHandle(item, lref => {
                try {
                    JNIEnv.CallVoidMethod(Handle, id_insert, new JValue(index), new JValue(lref));
                } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NotSupportedException(ex.Message, ex);
                } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new InvalidCastException(ex.Message, ex);
                } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NullReferenceException(ex.Message, ex);
                } catch (Java.Lang.IllegalArgumentException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new ArgumentException(ex.Message, ex);
                } catch (Java.Lang.IndexOutOfBoundsException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new ArgumentOutOfRangeException(ex.Message, ex);
                }

                return(IntPtr.Zero);
            });
        }
Esempio n. 3
0
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.util.Map.remove(Object, Object)` throws a number of exceptions, see:
        //
        //     https://developer.android.com/reference/java/util/Map.html?hl=en#remove(java.lang.Object,%20java.lang.Object)
        //
        public bool Remove(K key)
        {
            bool contains = ContainsKey(key);

            if (id_remove == IntPtr.Zero)
            {
                id_remove = JNIEnv.GetMethodID(map_class, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr r = JavaConvert.WithLocalJniHandle(key, lref => {
                try {
                    return(JNIEnv.CallObjectMethod(Handle, id_remove, new JValue(lref)));
                } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NotSupportedException(ex.Message, ex);
                } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new InvalidCastException(ex.Message, ex);
                } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NullReferenceException(ex.Message, ex);
                }
            });

            JNIEnv.DeleteLocalRef(r);
            return(contains);
        }
Esempio n. 4
0
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.util.List.set(int, Object)` throws a number of exceptions, see:
        //
        //     https://developer.android.com/reference/java/util/List.html?hl=en#set(int,%20E)
        //
        internal void InternalSet(int location, object value)
        {
            if (id_set == IntPtr.Zero)
            {
                id_set = JNIEnv.GetMethodID(arraylist_class, "set", "(ILjava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr r = JavaConvert.WithLocalJniHandle(value, lref => {
                try {
                    return(JNIEnv.CallObjectMethod(Handle, id_set, new JValue(location), new JValue(lref)));
                } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NotSupportedException(ex.Message, ex);
                } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new InvalidCastException(ex.Message, ex);
                } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new NullReferenceException(ex.Message, ex);
                } catch (Java.Lang.IllegalArgumentException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new ArgumentException(ex.Message, ex);
                } catch (Java.Lang.IndexOutOfBoundsException ex) when(JNIEnv.ShouldWrapJavaException(ex))
                {
                    throw new ArgumentOutOfRangeException(ex.Message, ex);
                }
            });

            JNIEnv.DeleteLocalRef(r);
        }
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.util.Collection.add(E)` throws a number of exceptions, see:
 //
 //     https://developer.android.com/reference/java/util/Collection?hl=en#add(E)
 //
 internal void Add(object item)
 {
     if (id_add == IntPtr.Zero)
     {
         id_add = JNIEnv.GetMethodID(collection_class, "add", "(Ljava/lang/Object;)Z");
     }
     JavaConvert.WithLocalJniHandle(item, lref => {
         try {
             JNIEnv.CallBooleanMethod(Handle, id_add, new JValue(lref));
         } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NotSupportedException(ex.Message, ex);
         } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new InvalidCastException(ex.Message, ex);
         } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NullReferenceException(ex.Message, ex);
         } catch (Java.Lang.IllegalArgumentException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new ArgumentException(ex.Message, ex);
         } catch (Java.Lang.IllegalStateException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new InvalidOperationException(ex.Message, ex);
         }
         return(IntPtr.Zero);
     });
 }
Esempio n. 6
0
 public void Remove(object item)
 {
     if (id_remove == IntPtr.Zero)
     {
         id_remove = JNIEnv.GetMethodID(set_class, "remove", "(Ljava/lang/Object;)Z");
     }
     JavaConvert.WithLocalJniHandle(item,
                                    lref => JNIEnv.CallBooleanMethod(Handle, id_remove, new JValue(lref)));
 }
Esempio n. 7
0
 public int GetPosition(T item)
 {
     if (id_getPosition_Ljava_lang_Object_ == IntPtr.Zero)
     {
         id_getPosition_Ljava_lang_Object_ = JNIEnv.GetMethodID(class_ref, "getPosition", "(Ljava/lang/Object;)I");
     }
     return(JavaConvert.WithLocalJniHandle(item,
                                           lref => JNIEnv.CallNonvirtualIntMethod(Handle, class_ref, id_getPosition_Ljava_lang_Object_, new JValue(lref))));
 }
Esempio n. 8
0
 public virtual int IndexOfValue(E value)
 {
     if (id_indexOfValue_Ljava_lang_Object_ == IntPtr.Zero)
     {
         id_indexOfValue_Ljava_lang_Object_ = JNIEnv.GetMethodID(class_ref, "indexOfValue", "(Ljava/lang/Object;)I");
     }
     return(JavaConvert.WithLocalJniHandle(value,
                                           lref => JNIEnv.CallNonvirtualIntMethod(Handle, class_ref, id_indexOfValue_Ljava_lang_Object_, new JValue(lref))));
 }
 public bool Contains(object key)
 {
     if (id_containsKey == IntPtr.Zero)
     {
         id_containsKey = JNIEnv.GetMethodID(map_class, "containsKey", "(Ljava/lang/Object;)Z");
     }
     return(JavaConvert.WithLocalJniHandle(key,
                                           lref => JNIEnv.CallBooleanMethod(Handle, id_containsKey, new JValue(lref))));
 }
Esempio n. 10
0
 public bool Contains(object item)
 {
     if (id_contains == IntPtr.Zero)
     {
         id_contains = JNIEnv.GetMethodID(set_class, "contains", "(Ljava/lang/Object;)Z");
     }
     return(JavaConvert.WithLocalJniHandle(item,
                                           lref => JNIEnv.CallBooleanMethod(Handle, id_contains, new JValue(lref))));
 }
Esempio n. 11
0
 public virtual int LastIndexOf(object item)
 {
     if (id_lastIndexOf == IntPtr.Zero)
     {
         id_lastIndexOf = JNIEnv.GetMethodID(arraylist_class, "lastIndexOf", "(Ljava/lang/Object;)I");
     }
     return(JavaConvert.WithLocalJniHandle(item,
                                           lref => JNIEnv.CallIntMethod(Handle, id_lastIndexOf, new JValue(lref))));
 }
Esempio n. 12
0
 public int Add(object item)
 {
     if (id_add == IntPtr.Zero)
     {
         id_add = JNIEnv.GetMethodID(arraylist_class, "add", "(Ljava/lang/Object;)Z");
     }
     JavaConvert.WithLocalJniHandle(item,
                                    lref => JNIEnv.CallBooleanMethod(Handle, id_add, new JValue(lref)));
     return(Count - 1);
 }
Esempio n. 13
0
 public void Insert(T @object, int index)
 {
     if (id_insert_Ljava_lang_Object_I == IntPtr.Zero)
     {
         id_insert_Ljava_lang_Object_I = JNIEnv.GetMethodID(class_ref, "insert", "(Ljava/lang/Object;I)V");
     }
     JavaConvert.WithLocalJniHandle(@object, lref => {
         JNIEnv.CallNonvirtualVoidMethod(Handle, class_ref, id_insert_Ljava_lang_Object_I, new JValue(lref), new JValue(index));
         return(IntPtr.Zero);
     });
 }
Esempio n. 14
0
        public void Remove(object key)
        {
            if (id_remove == IntPtr.Zero)
            {
                id_remove = JNIEnv.GetMethodID(map_class, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr r = JavaConvert.WithLocalJniHandle(key,
                                                      lref => JNIEnv.CallObjectMethod(Handle, id_remove, new JValue(lref)));

            JNIEnv.DeleteLocalRef(r);
        }
Esempio n. 15
0
 internal object Get(object key)
 {
     if (id_get == IntPtr.Zero)
     {
         id_get = JNIEnv.GetMethodID(map_class, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
     }
     return(JavaConvert.FromJniHandle(
                JavaConvert.WithLocalJniHandle(key,
                                               lref => JNIEnv.CallObjectMethod(Handle, id_get, new JValue(lref))),
                JniHandleOwnership.TransferLocalRef));
 }
Esempio n. 16
0
 internal void Add(object item)
 {
     if (id_add == IntPtr.Zero)
     {
         id_add = JNIEnv.GetMethodID(collection_class, "add", "(Ljava/lang/Object;)Z");
     }
     JavaConvert.WithLocalJniHandle(item, lref => {
         JNIEnv.CallBooleanMethod(Handle, id_add, new JValue(lref));
         return(IntPtr.Zero);
     });
 }
Esempio n. 17
0
 public void Remove(T @object)
 {
     if (id_remove_Ljava_lang_Object_ == IntPtr.Zero)
     {
         id_remove_Ljava_lang_Object_ = JNIEnv.GetMethodID(class_ref, "remove", "(Ljava/lang/Object;)V");
     }
     JavaConvert.WithLocalJniHandle(@object, lref => {
         JNIEnv.CallNonvirtualVoidMethod(Handle, class_ref, id_remove_Ljava_lang_Object_, new JValue(lref));
         return(IntPtr.Zero);
     });
 }
Esempio n. 18
0
        internal void InternalSet(int location, object value)
        {
            if (id_set == IntPtr.Zero)
            {
                id_set = JNIEnv.GetMethodID(arraylist_class, "set", "(ILjava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr r = JavaConvert.WithLocalJniHandle(value,
                                                      lref => JNIEnv.CallObjectMethod(Handle, id_set, new JValue(location), new JValue(lref)));

            JNIEnv.DeleteLocalRef(r);
        }
Esempio n. 19
0
 public virtual void SetValueAt(int index, E value)
 {
     if (id_setValueAt_ILjava_lang_Object_ == IntPtr.Zero)
     {
         id_setValueAt_ILjava_lang_Object_ = JNIEnv.GetMethodID(class_ref, "setValueAt", "(ILjava/lang/Object;)V");
     }
     JavaConvert.WithLocalJniHandle(value, lref => {
         JNIEnv.CallNonvirtualVoidMethod(Handle, class_ref, id_setValueAt_ILjava_lang_Object_, new JValue(index), new JValue(lref));
         return(IntPtr.Zero);
     });
 }
Esempio n. 20
0
        public virtual E Get(int key, E valueIfKeyNotFound)
        {
            if (id_get_ILjava_lang_Object_ == IntPtr.Zero)
            {
                id_get_ILjava_lang_Object_ = JNIEnv.GetMethodID(class_ref, "get", "(ILjava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr value = JavaConvert.WithLocalJniHandle(valueIfKeyNotFound,
                                                          lref => JNIEnv.CallNonvirtualObjectMethod(Handle, class_ref, id_get_ILjava_lang_Object_, new JValue(key), new JValue(lref)));

            return(JavaConvert.FromJniHandle <E> (value, JniHandleOwnership.TransferLocalRef) !);
        }
Esempio n. 21
0
 public virtual void Append(int key, E value)
 {
     if (id_append_ILjava_lang_Object_ == IntPtr.Zero)
     {
         id_append_ILjava_lang_Object_ = JNIEnv.GetMethodID(class_ref, "put", "(ILjava/lang/Object;)V");
     }
     JavaConvert.WithLocalJniHandle(value, lref => {
         JNIEnv.CallNonvirtualVoidMethod(Handle, class_ref, id_append_ILjava_lang_Object_, new JValue(key), new JValue(lref));
         return(IntPtr.Zero);
     });
 }
Esempio n. 22
0
        internal void Put(object key, object value)
        {
            if (id_put == IntPtr.Zero)
            {
                id_put = JNIEnv.GetMethodID(map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr r = JavaConvert.WithLocalJniHandle(key,
                                                      lrefKey => JavaConvert.WithLocalJniHandle(value,
                                                                                                lrefValue => JNIEnv.CallObjectMethod(Handle, id_put, new JValue(lrefKey), new JValue(lrefValue))));

            JNIEnv.DeleteLocalRef(r);
        }
Esempio n. 23
0
        public void Insert(int index, object item)
        {
            if (id_insert == IntPtr.Zero)
            {
                id_insert = JNIEnv.GetMethodID(arraylist_class, "add", "(ILjava/lang/Object;)V");
            }

            JavaConvert.WithLocalJniHandle(item, lref => {
                JNIEnv.CallVoidMethod(Handle, id_insert, new JValue(index), new JValue(lref));
                return(IntPtr.Zero);
            });
        }
Esempio n. 24
0
		//
		// Exception audit:
		//
		//  Verdict
		//    Exception wrapping is required.
		//
		//  Rationale
		//    `java.util.Map.containsKey(Object)` throws a number of exceptions, see:
		//
		//     https://developer.android.com/reference/java/util/Map.html?hl=en#containsKey(java.lang.Object)
		//
		public bool Contains (object key)
		{
			if (id_containsKey == IntPtr.Zero)
				id_containsKey = JNIEnv.GetMethodID (map_class, "containsKey", "(Ljava/lang/Object;)Z");
			return JavaConvert.WithLocalJniHandle (key, lref => {
				try {
					return JNIEnv.CallBooleanMethod (Handle, id_containsKey, new JValue (lref));
				} catch (Java.Lang.ClassCastException ex) when (JNIEnv.ShouldWrapJavaException (ex)) {
					throw new InvalidCastException (ex.Message, ex);
				} catch (Java.Lang.NullPointerException ex) when (JNIEnv.ShouldWrapJavaException (ex)) {
					throw new NullReferenceException (ex.Message, ex);
				}
			});
		}
Esempio n. 25
0
		//
		// Exception audit:
		//
		//  Verdict
		//    Exception wrapping is required.
		//
		//  Rationale
		//    `java.util.Collection.get(Object, Object)` throws a number of exceptions, see:
		//
		//     https://developer.android.com/reference/java/util/Map#get(java.lang.Object)
		//
		internal object Get (object key)
		{
			if (id_get == IntPtr.Zero)
				id_get = JNIEnv.GetMethodID (map_class, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
			return JavaConvert.FromJniHandle (
				JavaConvert.WithLocalJniHandle (key, lref => {
					try {
						return JNIEnv.CallObjectMethod (Handle, id_get, new JValue (lref));
					} catch (Java.Lang.ClassCastException ex) when (JNIEnv.ShouldWrapJavaException (ex)) {
						throw new InvalidCastException (ex.Message, ex);
					} catch (Java.Lang.NullPointerException ex) when (JNIEnv.ShouldWrapJavaException (ex)) {
						throw new NullReferenceException (ex.Message, ex);
					}
				}), JniHandleOwnership.TransferLocalRef);
		}
Esempio n. 26
0
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.util.List.lastIndexOf(Object)` throws a number of exceptions, see:
 //
 //     https://developer.android.com/reference/java/util/List?hl=en#lastIndexOf(java.lang.Object)
 //
 public virtual int LastIndexOf(object item)
 {
     if (id_lastIndexOf == IntPtr.Zero)
     {
         id_lastIndexOf = JNIEnv.GetMethodID(arraylist_class, "lastIndexOf", "(Ljava/lang/Object;)I");
     }
     return(JavaConvert.WithLocalJniHandle(item, lref => {
         try {
             return JNIEnv.CallIntMethod(Handle, id_lastIndexOf, new JValue(lref));
         } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new InvalidCastException(ex.Message, ex);
         } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NullReferenceException(ex.Message, ex);
         }
     }));
 }
Esempio n. 27
0
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.util.Set.remove(Object)` throws a number of exceptions, see:
 //
 //     https://developer.android.com/reference/java/util/Set?hl=en#remove(java.lang.Object)
 //
 public void Remove(object item)
 {
     if (id_remove == IntPtr.Zero)
     {
         id_remove = JNIEnv.GetMethodID(set_class, "remove", "(Ljava/lang/Object;)Z");
     }
     JavaConvert.WithLocalJniHandle(item, lref => {
         try {
             return(JNIEnv.CallBooleanMethod(Handle, id_remove, new JValue(lref)));
         } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NotSupportedException(ex.Message, ex);
         } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new InvalidCastException(ex.Message, ex);
         } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NullReferenceException(ex.Message, ex);
         }
     });
 }