예제 #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);
        }
예제 #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);
            });
        }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
 //
 // 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);
     });
 }
예제 #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)));
 }
예제 #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))));
 }
예제 #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))));
 }
예제 #9
0
 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))));
 }
예제 #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))));
 }
예제 #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))));
 }
예제 #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);
 }
예제 #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);
     });
 }
예제 #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);
        }
예제 #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));
 }
예제 #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);
     });
 }
예제 #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);
     });
 }
예제 #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);
        }
예제 #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);
     });
 }
예제 #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) !);
        }
예제 #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);
     });
 }
예제 #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);
        }
예제 #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);
            });
        }
예제 #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);
				}
			});
		}
예제 #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);
		}
예제 #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);
         }
     }));
 }
예제 #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);
         }
     });
 }