From 217c4a6faca388b4799f77383c34b9cb3491992e Mon Sep 17 00:00:00 2001 From: John Emmons Date: Tue, 25 Oct 2005 20:11:35 +0000 Subject: [PATCH] ICU-4643 Add setters by context/width, eraNames X-SVN-Rev: 18716 --- .../com/ibm/icu/text/DateFormatSymbols.java | 93 ++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java b/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java index 0c8f7594d6e..ea37daf82b0 100755 --- a/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java +++ b/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java @@ -365,10 +365,17 @@ public class DateFormatSymbols implements Serializable, Cloneable { * @deprecated This is a draft API and might change in a future release of ICU. */ public String[] getEraNames() { - // TODO: Fill the era names in appropriately. Just a placeholder right now. return duplicate(eraNames); } + /** + * Sets era name strings. For example: "Anno Domini" and "Before Christ". + * @param newEras the new era strings. + * @draft ICU 3.6 + */ + public void setEraNames(String[] newEraNames) { + eraNames = duplicate(newEraNames); + } /** * Gets month strings. For example: "January", "February", etc. * @return the month strings. @@ -430,6 +437,47 @@ public class DateFormatSymbols implements Serializable, Cloneable { months = duplicate(newMonths); } + /** + * Sets month strings. For example: "January", "February", etc. + * @param newMonths the new month strings. + * @param context The formatting context, FORMAT or STANDALONE. + * @param width The width of the month string, + * either WIDE, ABBREVIATED, or NARROW. + * @draft ICU 3.6 + * @deprecated This is a draft API and might change in a future release of ICU. + */ + + public void setMonths(String[] newMonths, int context, int width) { + switch (context) { + case FORMAT : + switch(width) { + case WIDE : + months = duplicate(newMonths); + break; + case ABBREVIATED : + shortMonths = duplicate(newMonths); + break; + case NARROW : + narrowMonths = duplicate(newMonths); + break; + } + break; + case STANDALONE : + switch(width) { + case WIDE : + standaloneMonths = duplicate(newMonths); + break; + case ABBREVIATED : + standaloneShortMonths = duplicate(newMonths); + break; + case NARROW : + standaloneNarrowMonths = duplicate(newMonths); + break; + } + break; + } + } + /** * Gets short month strings. For example: "Jan", "Feb", etc. * @return the short month strings. @@ -462,7 +510,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { * Gets weekday strings. For example: "Sunday", "Monday", etc. * @return the weekday strings. Use Calendar.SUNDAY, * Calendar.MONDAY, etc. to index the result array. - * @param context Weekday context, either FORMAT or STANDALONE. + * @param context Formatting context, either FORMAT or STANDALONE. * @param width Width of strings to be returned, either * WIDE, ABBREVIATED, or NARROW * @draft ICU 3.4 @@ -501,6 +549,47 @@ public class DateFormatSymbols implements Serializable, Cloneable { return duplicate(returnValue); } + /** + * Sets weekday strings. For example: "Sunday", "Monday", etc. + * @param newWeekdays The new weekday strings. + * @param context The formatting context, FORMAT or STANDALONE. + * @param width The width of the strings, + * either WIDE, ABBREVIATED, or NARROW. + * @draft ICU 3.6 + * @deprecated This is a draft API and might change in a future release of ICU. + */ + + public void setWeekdays(String[] newWeekdays, int context, int width) { + switch (context) { + case FORMAT : + switch(width) { + case WIDE : + months = duplicate(newWeekdays); + break; + case ABBREVIATED : + shortWeekdays = duplicate(newWeekdays); + break; + case NARROW : + narrowWeekdays = duplicate(newWeekdays); + break; + } + break; + case STANDALONE : + switch(width) { + case WIDE : + standaloneWeekdays = duplicate(newWeekdays); + break; + case ABBREVIATED : + standaloneShortWeekdays = duplicate(newWeekdays); + break; + case NARROW : + standaloneNarrowWeekdays = duplicate(newWeekdays); + break; + } + break; + } + } + /** * Sets weekday strings. For example: "Sunday", "Monday", etc. * @param newWeekdays the new weekday strings. The array should