2 *******************************************************************************
3 * Copyright (C) 2007, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 package com.ibm.icu.dev.test.util;
14 public class DebugUtilities {
18 * @return the number of enum types available, starting at 0
20 public static int typeCount() {
21 return DebugUtilitiesData.TYPES.length;
25 * Fetch the name of a particular type of enum
26 * @param type the enum type
27 * @return the name of the enum
29 public static String typeString(int type) {
30 return enumString(DebugUtilitiesData.UDebugEnumType, type);
34 * Count the number of available enum values for an item, from 0
35 * @param type which enum to look up, such as DebugUtilitiesData.UCalendarDateFields
36 * @return the number of available enum values
38 public static int enumCount(int type) {
39 return DebugUtilitiesData.NAMES[type].length;
43 * Fetch the name of an enum
44 * @param type which enum to look up, such as DebugUtilitiesData.UCalendarDateFields
45 * @param field which enum value to look up
46 * @return the found name. Will throw an exception on out of bounds.
48 public static String enumString(int type, int field) {
49 return DebugUtilitiesData.NAMES[type][field];
53 * Lookup an enum by string
54 * @param type which enum to look up, such as DebugUtilitiesData.UCalendarDateFields
55 * @param string the string to search for
56 * @return the found enum value, or -1 if not found
58 public static int enumByString(int type, String string) {
59 for(int j=0;j<DebugUtilitiesData.NAMES[type].length;j++) {
60 if(string.equals(DebugUtilitiesData.NAMES[type][j])) {
68 * for consistency checking
69 * @param type the type of enum
70 * @return the expected ordinal value (should be equal to "field")
73 public static int enumArrayValue(int type, int field) {
74 return DebugUtilitiesData.VALUES[type][field];