1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ******************************************************************************* 6 * Copyright (C) 2007, International Business Machines Corporation and * 7 * others. All Rights Reserved. * 8 ******************************************************************************* 9 */ 10 package ohos.global.icu.dev.test.util; 11 12 13 14 /** 15 * @author srl 16 * 17 */ 18 19 20 public class DebugUtilities { 21 22 /** 23 * Count enum types 24 * @return the number of enum types available, starting at 0 25 */ typeCount()26 public static int typeCount() { 27 return DebugUtilitiesData.TYPES.length; 28 } 29 30 /** 31 * Fetch the name of a particular type of enum 32 * @param type the enum type 33 * @return the name of the enum 34 */ typeString(int type)35 public static String typeString(int type) { 36 return enumString(DebugUtilitiesData.UDebugEnumType, type); 37 } 38 39 /** 40 * Count the number of available enum values for an item, from 0 41 * @param type which enum to look up, such as DebugUtilitiesData.UCalendarDateFields 42 * @return the number of available enum values 43 */ enumCount(int type)44 public static int enumCount(int type) { 45 return DebugUtilitiesData.NAMES[type].length; 46 } 47 48 /** 49 * Fetch the name of an enum 50 * @param type which enum to look up, such as DebugUtilitiesData.UCalendarDateFields 51 * @param field which enum value to look up 52 * @return the found name. Will throw an exception on out of bounds. 53 */ enumString(int type, int field)54 public static String enumString(int type, int field) { 55 return DebugUtilitiesData.NAMES[type][field]; 56 } 57 58 /** 59 * Lookup an enum by string 60 * @param type which enum to look up, such as DebugUtilitiesData.UCalendarDateFields 61 * @param string the string to search for 62 * @return the found enum value, or -1 if not found 63 */ enumByString(int type, String string)64 public static int enumByString(int type, String string) { 65 for(int j=0;j<DebugUtilitiesData.NAMES[type].length;j++) { 66 if(string.equals(DebugUtilitiesData.NAMES[type][j])) { 67 return j; 68 } 69 } 70 return -1; 71 } 72 73 /** 74 * for consistency checking 75 * @param type the type of enum 76 * @return the expected ordinal value (should be equal to "field") 77 * @internal 78 */ enumArrayValue(int type, int field)79 public static int enumArrayValue(int type, int field) { 80 return DebugUtilitiesData.VALUES[type][field]; 81 } 82 83 } 84