//
        // 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);
            });
        }
 //
 // 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);
     });
 }
        //
        // 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?hl=en#set(int,%20E)
        //
        public virtual Java.Lang.Object Set(int location, Java.Lang.Object item)
        {
            if (id_set == IntPtr.Zero)
            {
                id_set = JNIEnv.GetMethodID(arraylist_class, "set", "(ILjava/lang/Object;)Ljava/lang/Object;");
            }
            IntPtr obj;

            try {
                obj = JNIEnv.CallObjectMethod(Handle, id_set, new JValue(location), new JValue(item));
            } 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(Java.Lang.Object.GetObject <Java.Lang.Object> (
                       obj,
                       JniHandleOwnership.TransferLocalRef));
        }
        //
        // 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(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 => {
                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);
        }
        //
        // 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.io.InputStream.close()` throws an exception, see:
 //
 //     https://developer.android.com/reference/java/io/InputStream?hl=en
 //
 public override void Close()
 {
     try {
         BaseInputStream.Close();
     } catch (Java.IO.IOException ex) when(JNIEnv.ShouldWrapJavaException(ex))
     {
         throw new IOException(ex.Message, ex);
     }
 }
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping required
 //
 //  Rationale
 //    Java code may throw URISyntaxException which we map to the managed UriFormatException
 //
 static URI CreateJavaUri(Uri destination)
 {
     try {
         return(new URI(destination.Scheme, destination.UserInfo, destination.Host, destination.Port, destination.AbsolutePath, destination.Query, destination.Fragment));
     } catch (Java.Lang.Throwable ex) when(JNIEnv.ShouldWrapJavaException(ex))
     {
         throw new UriFormatException(ex.Message, ex);
     }
 }
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.io.OutputStream.write(byte[],int,int)` throws an exception, see:
 //
 //     https://developer.android.com/reference/java/io/OutputStream?hl=en#write(byte%5B%5D)
 //
 public override void Write(byte[] buffer, int offset, int count)
 {
     try {
         BaseOutputStream.Write(buffer, offset, count);
     } catch (Java.IO.IOException ex) when(JNIEnv.ShouldWrapJavaException(ex))
     {
         throw new IOException(ex.Message, ex);
     }
 }
		//
		// Exception audit:
		//
		//  Verdict
		//    Exception wrapping is required.
		//
		//  Rationale
		//    `java.util.Map.clear()` throws an exceptions, see:
		//
		//     https://developer.android.com/reference/java/util/Map.html?hl=en#clear()
		//
		public void Clear ()
		{
			if (id_clear == IntPtr.Zero)
				id_clear = JNIEnv.GetMethodID (map_class, "clear", "()V");
			try {
				JNIEnv.CallVoidMethod (Handle, id_clear);
			} catch (Java.Lang.UnsupportedOperationException ex) when (JNIEnv.ShouldWrapJavaException (ex)) {
				throw new NotSupportedException (ex.Message, ex);
			}
		}
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.io.OutputStream.close()` throws an exception, see:
 //
 //     https://developer.android.com/reference/java/io/OutputStream?hl=en#close()
 //
 protected override void Dispose(bool disposing)
 {
     if (disposing && BaseOutputStream != null)
     {
         try {
             BaseOutputStream.Close();
             BaseOutputStream.Dispose();
         } catch (Java.IO.IOException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new IOException(ex.Message, ex);
         }
     }
 }
		//
		// 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);
				}
			});
		}
		//
		// 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);
		}
Beispiel #13
0
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.util.List.remove(int)` throws a number of exceptions, see:
 //
 //     https://developer.android.com/reference/java/util/List?hl=en#remove(int)
 //
 public void RemoveAt(int index)
 {
     if (id_remove == IntPtr.Zero)
     {
         id_remove = JNIEnv.GetMethodID(arraylist_class, "remove", "(I)Ljava/lang/Object;");
     }
     try {
         IntPtr r = JNIEnv.CallObjectMethod(Handle, id_remove, new JValue(index));
         JNIEnv.DeleteLocalRef(r);
     } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
     {
         throw new NotSupportedException(ex.Message, ex);
     } catch (Java.Lang.IndexOutOfBoundsException ex) when(JNIEnv.ShouldWrapJavaException(ex))
     {
         throw new ArgumentOutOfRangeException(ex.Message, ex);
     }
 }
		//
		// 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 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 => {
				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);
		}
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.io.InputStream.read(byte[], int, int)` throws an exception, see:
        //
        //     https://developer.android.com/reference/java/io/InputStream?hl=en#read(byte%5B%5D,%20int,%20int)
        //
        public override int Read(byte[] buffer, int offset, int count)
        {
            int res;

            try {
                res = BaseInputStream.Read(buffer, offset, count);
            } catch (Java.IO.IOException ex) when(JNIEnv.ShouldWrapJavaException(ex))
            {
                throw new IOException(ex.Message, ex);
            }

            if (res == -1)
            {
                return(0);
            }
            return(res);
        }
Beispiel #16
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);
         }
     }));
 }
Beispiel #17
0
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.util.List.get(int)` throws an exceptions, see:
        //
        //     https://developer.android.com/reference/java/util/List.html?hl=en#get(int)
        //
        internal object InternalGet(int location, Type targetType = null)
        {
            if (id_get == IntPtr.Zero)
            {
                id_get = JNIEnv.GetMethodID(arraylist_class, "get", "(I)Ljava/lang/Object;");
            }

            IntPtr obj;

            try {
                obj = JNIEnv.CallObjectMethod(Handle, id_get, new JValue(location));
            } catch (Java.Lang.IndexOutOfBoundsException ex) when(JNIEnv.ShouldWrapJavaException(ex))
            {
                throw new ArgumentOutOfRangeException(ex.Message, ex);
            }

            return(JavaConvert.FromJniHandle(
                       obj,
                       JniHandleOwnership.TransferLocalRef,
                       targetType));
        }
Beispiel #18
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);
         }
     });
 }
Beispiel #19
0
        //
        // Exception audit:
        //
        //  Verdict
        //    Exception wrapping is required.
        //
        //  Rationale
        //    `java.util.List.subList(int, int)` throws a number of exceptions, see:
        //
        //     https://developer.android.com/reference/java/util/List?hl=en#subList(int,%20int)
        //     https://developer.android.com/reference/java/util/ArrayList?hl=en#subList(int,%20int)
        //
        public virtual JavaList SubList(int start, int end)
        {
            if (id_subList == IntPtr.Zero)
            {
                id_subList = JNIEnv.GetMethodID(arraylist_class, "subList", "(II;)Ljava/util/List;");
            }

            IntPtr obj;

            try {
                obj = JNIEnv.CallObjectMethod(Handle, id_subList, new JValue(start), new JValue(end));
            } 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(new JavaList(
                       obj,
                       JniHandleOwnership.TransferLocalRef));
        }