1 /* 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 package org.webrtc; 12 13 import java.io.UnsupportedEncodingException; 14 import java.util.Map; 15 16 /** 17 * This class is only used from jni_helper.cc to give some Java functionality that were not possible 18 * to generate in other ways due to bugs.webrtc.org/8606 and bugs.webrtc.org/8632. 19 */ 20 class JniHelper { 21 // TODO(bugs.webrtc.org/8632): Remove. 22 @CalledByNative getStringBytes(String s)23 static byte[] getStringBytes(String s) { 24 try { 25 return s.getBytes("ISO-8859-1"); 26 } catch (UnsupportedEncodingException e) { 27 throw new RuntimeException("ISO-8859-1 is unsupported"); 28 } 29 } 30 31 // TODO(bugs.webrtc.org/8632): Remove. 32 @CalledByNative getStringClass()33 static Object getStringClass() { 34 return String.class; 35 } 36 37 // TODO(bugs.webrtc.org/8606): Remove. 38 @CalledByNative getKey(Map.Entry entry)39 static Object getKey(Map.Entry entry) { 40 return entry.getKey(); 41 } 42 43 // TODO(bugs.webrtc.org/8606): Remove. 44 @CalledByNative getValue(Map.Entry entry)45 static Object getValue(Map.Entry entry) { 46 return entry.getValue(); 47 } 48 } 49