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