1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html#License 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2012-2015, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9 package com.ibm.icu.text; 10 11 /** 12 * Display context settings. 13 * Note, the specific numeric values are internal and may change. 14 * @stable ICU 51 15 */ 16 public enum DisplayContext { 17 /** 18 * ================================ 19 * Settings for DIALECT_HANDLING (use one) 20 */ 21 /** 22 * A possible setting for DIALECT_HANDLING: 23 * use standard names when generating a locale name, 24 * e.g. en_GB displays as 'English (United Kingdom)'. 25 * @stable ICU 51 26 */ 27 STANDARD_NAMES(Type.DIALECT_HANDLING, 0), 28 /** 29 * A possible setting for DIALECT_HANDLING: 30 * use dialect names, when generating a locale name, 31 * e.g. en_GB displays as 'British English'. 32 * @stable ICU 51 33 */ 34 DIALECT_NAMES(Type.DIALECT_HANDLING, 1), 35 /** 36 * ================================ 37 * Settings for CAPITALIZATION (use one) 38 */ 39 /** 40 * A possible setting for CAPITALIZATION: 41 * The capitalization context to be used is unknown (this is the default value). 42 * @stable ICU 51 43 */ 44 CAPITALIZATION_NONE(Type.CAPITALIZATION, 0), 45 /** 46 * A possible setting for CAPITALIZATION: 47 * The capitalization context if a date, date symbol or display name is to be 48 * formatted with capitalization appropriate for the middle of a sentence. 49 * @stable ICU 51 50 */ 51 CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE(Type.CAPITALIZATION, 1), 52 /** 53 * A possible setting for CAPITALIZATION: 54 * The capitalization context if a date, date symbol or display name is to be 55 * formatted with capitalization appropriate for the beginning of a sentence. 56 * @stable ICU 51 57 */ 58 CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE(Type.CAPITALIZATION, 2), 59 /** 60 * A possible setting for CAPITALIZATION: 61 * The capitalization context if a date, date symbol or display name is to be 62 * formatted with capitalization appropriate for a user-interface list or menu item. 63 * @stable ICU 51 64 */ 65 CAPITALIZATION_FOR_UI_LIST_OR_MENU(Type.CAPITALIZATION, 3), 66 /** 67 * A possible setting for CAPITALIZATION: 68 * The capitalization context if a date, date symbol or display name is to be 69 * formatted with capitalization appropriate for stand-alone usage such as an 70 * isolated name on a calendar page. 71 * @stable ICU 51 72 */ 73 CAPITALIZATION_FOR_STANDALONE(Type.CAPITALIZATION, 4), 74 /** 75 * ================================ 76 * Settings for DISPLAY_LENGTH (use one) 77 */ 78 /** 79 * A possible setting for DISPLAY_LENGTH: 80 * use full names when generating a locale name, 81 * e.g. "United States" for US. 82 * @stable ICU 54 83 */ 84 LENGTH_FULL(Type.DISPLAY_LENGTH, 0), 85 /** 86 * A possible setting for DISPLAY_LENGTH: 87 * use short names when generating a locale name, 88 * e.g. "U.S." for US. 89 * @stable ICU 54 90 */ 91 LENGTH_SHORT(Type.DISPLAY_LENGTH, 1), 92 /** 93 * ================================ 94 * Settings for SUBSTITUTE_HANDLING (choose one) 95 */ 96 /** 97 * A possible setting for SUBSTITUTE_HANDLING: 98 * Returns a fallback value (e.g., the input code) when no data is available. 99 * This is the default behavior. 100 * @stable ICU 58 101 */ 102 SUBSTITUTE(Type.SUBSTITUTE_HANDLING, 0), 103 /** 104 * A possible setting for SUBSTITUTE_HANDLING: 105 * Returns a null value when no data is available. 106 * @stable ICU 58 107 */ 108 NO_SUBSTITUTE(Type.SUBSTITUTE_HANDLING, 1); 109 110 /** 111 * Type values for DisplayContext 112 * @stable ICU 51 113 */ 114 public enum Type { 115 /** 116 * DIALECT_HANDLING can be set to STANDARD_NAMES or DIALECT_NAMES. 117 * @stable ICU 51 118 */ 119 DIALECT_HANDLING, 120 /** 121 * CAPITALIZATION can be set to one of CAPITALIZATION_NONE through 122 * CAPITALIZATION_FOR_STANDALONE. 123 * @stable ICU 51 124 */ 125 CAPITALIZATION, 126 /** 127 * DISPLAY_LENGTH can be set to LENGTH_FULL or LENGTH_SHORT. 128 * @stable ICU 54 129 */ 130 DISPLAY_LENGTH, 131 /** 132 * SUBSTITUTE_HANDLING can be set to SUBSTITUTE or NO_SUBSTITUTE. 133 * @stable ICU 58 134 */ 135 SUBSTITUTE_HANDLING 136 } 137 138 private final Type type; 139 private final int value; DisplayContext(Type type, int value)140 private DisplayContext(Type type, int value) { 141 this.type = type; 142 this.value = value; 143 } 144 /** 145 * Get the Type part of the enum item 146 * (e.g. CAPITALIZATION) 147 * @stable ICU 51 148 */ type()149 public Type type() { 150 return type; 151 } 152 /** 153 * Get the value part of the enum item 154 * (e.g. CAPITALIZATION_FOR_STANDALONE) 155 * @stable ICU 51 156 */ value()157 public int value() { 158 return value; 159 } 160 } 161