|
From: xiaomei j. <xia...@gm...> - 2008-07-11 01:05:25
|
This is a porting from Java (#6311). Mark posted the design at http://bugs.icu-project.org/trac/ticket/6303 Attached is his email about Java API. Following are C++ API proposals: http://source.icu-project.org/repos/icu/icu/branches/xji/simpleDurationFormat/source/i18n/unicode/tmunit.h http://source.icu-project.org/repos/icu/icu/branches/xji/simpleDurationFormat/source/i18n/unicode/tmutamt.h http://source.icu-project.org/repos/icu/icu/branches/xji/simpleDurationFormat/source/i18n/unicode/tmutfmt.h Please let me know if there is any problems. Thanks, Xiaomei ---------- Forwarded message ---------- From: Mark Davis <mar...@ic...> Date: Wed, May 28, 2008 at 12:12 AM Subject: [icu-design] API proposal for simple duration formats To: icu...@li..., xj...@go... Here's what I ended up with, along the lines of what I discussed earlier. I have checked in draft code and tests (#6303). It uses stubbed data for now, until the CLDR data is available. Comments welcome. com.ibm.icu.text Class TimeUnitFormat java.lang.Object [image: extended by]java.text.Format [image: extended by]com.ibm.icu.text.UFormat [image: extended by]com.ibm.icu.text.MeasureFormat [image: extended by]*com.ibm.icu.text.TimeUnitFormat* *All Implemented Interfaces:*java.io.Serializable, java.lang.Cloneable ------------------------------ public class *TimeUnitFormat*extends com.ibm.icu.text.MeasureFormat Format or parse a TimeUnitAmount, using plural rules for the units where available. *Author:* markdavis*See Also:*TimeUnitAmount, TimeUnitFormat, Serialized Form ------------------------------ *Nested Class Summary* *Nested classes/interfaces inherited from class java.text.Format* java.text.Format.Field *Constructor Summary* * TimeUnitFormat*() Create empty format. *Method Summary* java.lang.StringBuffer* format*(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos) Format a TimeUnitAmount. java.lang.Object*parseObject*(java.lang.String source, java.text.ParsePosition pos) Parse a TimeUnitAmount. TimeUnitFormat *setLocale* (java.util.Locale locale) Set the locale used for formatting or parsing. TimeUnitFormat * setLocale*(com.ibm.icu.util.ULocale locale) Set the locale used for formatting or parsing. TimeUnitFormat * setNumberFormat*(com.ibm.icu.text.NumberFormat format) Set the format used for formatting or parsing. *Methods inherited from class com.ibm.icu.text.MeasureFormat* getCurrencyFormat, getCurrencyFormat *Methods inherited from class com.ibm.icu.text.UFormat* getLocale *Methods inherited from class java.text.Format* clone, format, formatToCharacterIterator, parseObject *Methods inherited from class java.lang.Object* equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait *Constructor Detail* TimeUnitFormat public *TimeUnitFormat*() Create empty format. Use setLocale and/or setFormat to modify. *Method Detail* setLocale public TimeUnitFormat *setLocale*(com.ibm.icu.util.ULocale locale) Set the locale used for formatting or parsing. *Returns:* this, for chaining. ------------------------------ setLocale public TimeUnitFormat *setLocale*(java.util.Locale locale) Set the locale used for formatting or parsing. *Returns:* this, for chaining. ------------------------------ setNumberFormat public TimeUnitFormat *setNumberFormat*(com.ibm.icu.text.NumberFormat format) Set the format used for formatting or parsing. If null or not available, use the getNumberInstance(locale). *Returns:* this, for chaining. ------------------------------ format public java.lang.StringBuffer *format*(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos) Format a TimeUnitAmount. *Specified by:* format in class java.text.Format *See Also:*Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) ------------------------------ parseObject public java.lang.Object *parseObject*(java.lang.String source, java.text.ParsePosition pos) Parse a TimeUnitAmount. *Specified by:* parseObject in class java.text.Format com.ibm.icu.util Class TimeUnitAmount java.lang.Object [image: extended by]com.ibm.icu.util.Measure [image: extended by]*com.ibm.icu.util.TimeUnitAmount* ------------------------------ public class *TimeUnitAmount*extends com.ibm.icu.util.Measure Express a duration as a time unit and number. Patterned after Currency. Immutable. *Author:*markdavis*See Also:* TimeUnitAmount, TimeUnitFormat ------------------------------ *Constructor Summary* *TimeUnitAmount*(double number, TimeUnit unit) Create from a number and unit. *TimeUnitAmount* (java.lang.Number number, TimeUnit unit) Create from a number and unit. *Method Summary* TimeUnit * getTimeUnit*() Get the unit (convenience to avoid cast). *Methods inherited from class com.ibm.icu.util.Measure* equals, getNumber, getUnit, hashCode, numbersEqual, toString *Methods inherited from class java.lang.Object* getClass, notify, notifyAll, wait, wait, wait *Constructor Detail* TimeUnitAmount public *TimeUnitAmount*(java.lang.Number number, TimeUnit unit) Create from a number and unit. ------------------------------ TimeUnitAmount public *TimeUnitAmount*(double number, TimeUnit unit) Create from a number and unit. *Method Detail* getTimeUnit public TimeUnit *getTimeUnit*() Get the unit (convenience to avoid cast). com.ibm.icu.util Class TimeUnit java.lang.Object [image: extended by]com.ibm.icu.util.MeasureUnit [image: extended by]*com.ibm.icu.util.TimeUnit* ------------------------------ public class *TimeUnit*extends com.ibm.icu.util.MeasureUnit Measurement unit for time units. *Author:* markdavis*See Also:*TimeUnitAmount, TimeUnit ------------------------------ *Field Summary* static TimeUnit *DAY* Constant value for supported time unit. static TimeUnit *HOUR* Constant value for supported time unit. static TimeUnit *MINUTE* Constant value for supported time unit. static TimeUnit *MONTH* Constant value for supported time unit. static TimeUnit *SECOND* Constant value for supported time unit. static TimeUnit *WEEK* Constant value for supported time unit. static TimeUnit *YEAR* Constant value for supported time unit. *Method Summary* java.lang.String*toString*() A string representation for debugging. static TimeUnit[] *values* () *Methods inherited from class java.lang.Object* equals, getClass, hashCode, notify, notifyAll, wait, wait, wait *Field Detail* SECOND public static TimeUnit *SECOND* Constant value for supported time unit. ------------------------------ MINUTE public static TimeUnit *MINUTE* Constant value for supported time unit. ------------------------------ HOUR public static TimeUnit *HOUR* Constant value for supported time unit. ------------------------------ DAY public static TimeUnit *DAY* Constant value for supported time unit. ------------------------------ WEEK public static TimeUnit *WEEK* Constant value for supported time unit. ------------------------------ MONTH public static TimeUnit *MONTH* Constant value for supported time unit. ------------------------------ YEAR public static TimeUnit *YEAR* Constant value for supported time unit. *Method Detail* values public static TimeUnit[] *values*() *Returns:*the available values ------------------------------ toString public java.lang.String *toString*() A string representation for debugging. *Overrides:* toString in class java.lang.Object -- Mark ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ icu-design mailing list icu...@li... To Un/Subscribe: https://lists.sourceforge.net/lists/listinfo/icu-design |