|
JavaTM 2 Platform Std. Ed. v1. 4.0 |
||||||||||
ÀüÀÇ Å¬·¡½º ´ÙÀ½ÀÇ Å¬·¡½º | ÇÁ·¹ÀÓ ÀÖ¾î ÇÁ·¹ÀÓ ¾øÀ½ | ||||||||||
°³¿ä: »óÀÚ | Çʵå | constructor | ¸Þ¼Òµå | »ó¼¼: Çʵå | constructor | ¸Þ¼Òµå |
java.lang.Object | +--java.text.Format | +--java.text.NumberFormat | +--java.text.ChoiceFormat
ChoiceFormat
¸¦ »ç¿ëÇϸé(ÀÚ), ¾î´À ¹üÀ§ÀÇ ¼öÄ¡¿¡ Æ÷¸ËÀ» Ãß°¡ÇÒ ¼ö°¡ ÀÖ½À´Ï´Ù. À̰ÍÀº Åë»ó, º¹¼ö¸¦ ó¸®ÇÒ °æ¿ì¿¡ MessageFormat
·Î »ç¿ëµË´Ï´Ù. ÀÌ ¼±Åà Ç׸ñÀº double ÀÇ ½Â¼ø ¸®½ºÆ®·Î ÁöÁ¤µÇ¾î °¢°¢ÀÇ Ç׸ñÀº ´ÙÀ½ÀÇ Ç׸ñ±îÁöÀÇ ÇÑÆíÀÌ ¿¸° °£°ÝÀ» ÁöÁ¤ÇÕ´Ï´Ù.
ÀÏÄ¡ÇÏ´Â °ÍÀÌ ¾ø´Â °æ¿ì, ¼öÄ¡ (X)°¡ ³Ê¹« ÀÛÀºÁö ³Ê¹« Å«Áö¿¡ ÀÇÇØ, ÃÖÃÊ ¶Ç´Â ¸¶Áö¸· À妽º°¡ »ç¿ëµË´Ï´Ù. ¸®¹ÔÆ® ¹è¿ÀÌ ½Â¼øÀÌ ¾Æ´Ñ °æ¿ì, Æ÷¸ËÀÇ °á°ú´Â ¿Ã¹Ù¸£Áö´Â ¾Ê½À´Ï´Ù. ChoiceFormat ´Â ¶Ç,X ´Â limit[j] <= X < limit[j+1] ÀÇ °æ¿ì¿¡¸¸ j ¿¡ ÀÏÄ¡ÇÑ´Ù
\u221E
¸¦ infinity(INF)¿Í µ¿µîÇÑ °ÍÀ¸·Î ÇØ ¹Þ¾ÆµéÀÔ´Ï´Ù.
ÁÖ:
ChoiceFormat
´Â ´Ù¸¥ Format
Ŭ·¡½º¿Í´Â ´ÙÀ½ÀÇ Á¡À¸·Î½á ´Ù¸¨´Ï´Ù. ChoiceFormat
¿ÀºêÁ§Æ®´Â getInstance
½ºÅ¸ÀÏ ÆÑÅ丮 ¸Þ¼Òµå´Â ¾Æ´Ï°í, constructor À¸·Î ÀÛ¼ºÇÕ´Ï´Ù. ChoiceFormat
¿¡¼´Â ÁöÁ¤µÈ ·ÎÄÉÀÏ¿¡ ´ëÇØ¼ º¹ÀâÇÑ ¼Â¾÷Àº ÇÊ¿ä¾ø±â ¶§¹®¿¡, ÆÑÅ丮 ¸Þ¼Òµå´Â ºÒÇÊ¿äÇÕ´Ï´Ù. ½ÇÁ¦,ChoiceFormat
¿¡´Â ·ÎÄÉÀÏ °íÀ¯ÀÇ µ¿ÀÛÀº ±¸ÇöµÇÁö ¾Ê½À´Ï´Ù.
ChoiceFormat
¸¦ ÀÛ¼ºÇÏ´Â °æ¿ì¿¡´Â Æ÷¸ËÀÇ ¹è¿°ú ¸®¹ÔÆ®ÀÇ ¹è¿À» ÁöÁ¤ÇÒ Çʿ䰡 ÀÖ½À´Ï´Ù. ÀÌ·¯ÇÑ ¹è¿ÀÇ ±æÀÌ´Â °°Áö ¾ÊÀ¸¸é ¾ÈµË´Ï´Ù. ´ÙÀ½¿¡ ¿¹¸¦ ³ªÅ¸³À´Ï´Ù.
nextDouble
´Â ´ÙÀ½¿¡ Å« double ¸¦ ÃëµæÇØ, ÇÑÆíÀÌ ¿¸° °£°ÝÀ» ¸¸µå´Âµ¥ »ç¿ëÇÑ´Ù)
´ÙÀ½¿¡, Æ÷¸Ë°ú ÇØ¼®À» ½Ç½ÃÇÏ´Â °£´ÜÇÑ ¿¹¸¦ ³ªÅ¸³À´Ï´Ù.
´ÙÀ½¿¡, ÆÐÅÏ Æ÷¸ËÀ» »ç¿ëÇÏ°í ¸»À̾ߵ鿡°Ô º¹ÀâÇÑ ¿¹¸¦ ³ªÅ¸³À´Ï´Ù.double[] limits = {1,2,3,4,5,6,7}; String[] monthNames = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}; ChoiceFormat form = new ChoiceFormat(limits, monthNames); ParsePosition status = new ParsePosition(0); for (double i = 0.0; i <= 8.0; ++i) { status.setIndex(0); System.out.println(i + " -> " + form.format(i) + " -> " + form.parse(form.format(i), status)); }
double[] filelimits = {0,1,2}; String[] filepart = {"are no files","is one file","are {2} files"}; ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart); Format[] testFormats = {fileform, null, NumberFormat.getInstance()}; MessageFormat pattform = new MessageFormat("There {0} on {1}"); pattform.setFormats(testFormats); Object[] testArgs = {null, "ADisk", null}; for (int i = 0; i < 4; ++i) { testArgs[0] = new Integer(i); testArgs[2] = testArgs[0]; System.out.println(pattform.format(testArgs)); }
ChoiceFormat ¿ÀºêÁ§Æ®ÀÇ ÆÐÅÏ ÁöÁ¤Àº ¸Å¿ì °£´ÜÇÕ´Ï´Ù. ´ÙÀ½¿¡ ¿¹¸¦ ³ªÅ¸³À´Ï´Ù.
Ãâ·Â °á°ú´Â ´ÙÀ½°ú °°ÀÌ µË´Ï´Ù.ChoiceFormat fmt = new ChoiceFormat( "-1#is negative| 0#is zero or fraction | 1#is one |1. 0<is 1+ |2#is two |2<is more than 2. "); System.out.println("Formatter Pattern : " + fmt.toPattern()); System.out.println("Format with -INF : " + fmt.format(Double.NEGATIVE_INFINITY)); System.out.println("Format with -1. 0 : " + fmt.format(-1. 0)); System.out.println("Format with 0 : " + fmt.format(0)); System.out.println("Format with 0.9 : " + fmt.format(0.9)); System.out.println("Format with 1.0 : " + fmt.format(1)); System.out.println("Format with 1.5 : " + fmt.format(1.5)); System.out.println("Format with 2 : " + fmt.format(2)); System.out.println("Format with 2.1 : " + fmt.format(2.1)); System.out.println("Format with NaN : " + fmt.format(Double.NaN)); System.out.println("Format with +INF : " + fmt.format(Double.POSITIVE_INFINITY));
Format with -INF : is negative Format with -1. 0 : is negative Format with 0 : is zero or fraction Format with 0.9 : is zero or fraction Format with 1.0 : is one Format with 1.5 : is 1+ Format with 2 : is two Format with 2.1 : is more than 2. Format with NaN : is negative Format with +INF : is more than 2.
choice Æ÷¸ËÀº µ¿±âÈ µÇÁö ¾Ê½À´Ï´Ù. thread ¸¶´Ù ´Ù¸¥ Æ÷¸Ë ÀνºÅϽº¸¦ ÀÛ¼ºÇÏ´Â °ÍÀ» ÃßõÇÕ´Ï´Ù. º¹¼öÀÇ thread°¡ Æ÷¸Ë¿¡ µ¿½Ã¿¡ ¾×¼¼½º ÇÏ´Â °æ¿ì´Â ¿ÜºÎÀûÀ¸·Î µ¿±âÈÇÒ Çʿ䰡 ÀÖ½À´Ï´Ù.
DecimalFormat
,
MessageFormat
,
Á÷·ÄÈ µÈ Çü½Ä ÁßøµÈ Ŭ·¡½ºÀÇ °³¿ä |
Ŭ·¡½º java.text. NumberFormat À» »ó¼Ó¹ÞÀº ÁßøµÈ Ŭ·¡½º |
NumberFormat.Field |
Ŭ·¡½º java.text. Format À» »ó¼Ó¹ÞÀº ÁßøµÈ Ŭ·¡½º |
Format.Field |
ÇʵåÀÇ °³¿ä |
Ŭ·¡½º java.text. NumberFormat ¿¡¼ »ó¼Ó¹ÞÀº Çʵå |
FRACTION_FIELD , INTEGER_FIELD |
»ý¼ºÀÚÀÇ °³¿ä | |
ChoiceFormat (double[] limits,
String [] formats)
ÁöÁ¤µÈ ¸®¹ÔÆ®¿Í °Å±â¿¡ ´ëÀÀÇÏ´Â Æ÷¸Ë¿¡ ÀÇÇØ ¿ÀºêÁ§Æ®¸¦ ±¸ÃàÇÕ´Ï´Ù. |
|
ChoiceFormat (String newPattern)
ÁöÁ¤µÈ ÆÐÅÏ¿¡ ±Ù°ÅÇÏ´Â ¸®¹ÔÆ®¿Í °Å±â¿¡ ´ëÀÀÇÏ´Â Æ÷¸Ë¿¡ ÀÇÇØ ¿ÀºêÁ§Æ®¸¦ ±¸ÃàÇÕ´Ï´Ù. |
¸Þ¼ÒµåÀÇ °³¿ä | |
void |
applyPattern (String newPattern)
ÆÐÅÏÀ» ¼³Á¤ÇÕ´Ï´Ù. |
Object |
clone ()
Cloneable ¸¦ ¿À¹ö¶óÀ̵å(override) ÇÕ´Ï´Ù. |
boolean |
equals (Object obj)
2 °³°¡ µ¿ÀÏÇÑÁö ¾î¶²Áö¸¦ ºñ±³ÇÕ´Ï´Ù. |
StringBuffer |
format (double number,
StringBuffer toAppendTo,
FieldPosition status)
Æ÷¸Ë µÈ double ·Î ÆÐÅÏÀ» µ¹·ÁÁÝ´Ï´Ù. |
StringBuffer |
format (long number,
StringBuffer toAppendTo,
FieldPosition status)
Æ÷¸ËÀÇ Æ¯¼öÈÀÔ´Ï´Ù. |
Object [] |
getFormats ()
constructor Áß(¾È)¿¡¼ °Ç³×¹Þ´Â Æ÷¸ËÀ» ÃëµæÇÕ´Ï´Ù. |
double[] |
getLimits ()
constructor Áß(¾È)¿¡¼ °Ç³×¹Þ´Â ¸®¹ÔÆ®¸¦ ÃëµæÇÕ´Ï´Ù. |
int |
hashCode ()
¸Þ¼¼Áö Æ÷¸Ë ¿ÀºêÁ§Æ®ÀÇ ÇØ½Ã Äڵ带 »ý¼ºÇÕ´Ï´Ù. |
static double |
nextDouble (double d)
d º¸´Ù Å« ÃÖ¼ÒÀÇ double ¸¦ ã¾Æ³À´Ï´Ù. |
static double |
nextDouble (double d,
boolean positive)
d (if positive == true)º¸´Ù Å« ÃÖ¼ÒÀÇ double, ¶Ç´Â d (if positive == false)º¸´Ù ÀÛÀº ÃÖ´ëÀÇ double ¸¦ ã¾Æ³À´Ï´Ù. |
Number |
parse (String text,
ParsePosition status)
ÀÔ·Â ÅØ½ºÆ®·ÎºÎÅÍ Number ¸¦ ÇØ¼®ÇÕ´Ï´Ù. |
static double |
previousDouble (double d)
d º¸´Ù ÀÛÀº ÃÖ´ëÀÇ double ¸¦ ã¾Æ³À´Ï´Ù. |
void |
setChoices (double[] limits,
String [] formats)
Æ÷¸Ë ½Ã¿¡ »ç¿ëÇÏ´Â ¼±Åà Ç׸ñÀ» ¼³Á¤ÇÕ´Ï´Ù. |
String |
toPattern ()
ÆÐÅÏÀ» ÃëµæÇÕ´Ï´Ù. |
Ŭ·¡½º java.text. NumberFormat ¿¡¼ »ó¼Ó¹ÞÀº ¸Þ¼Òµå |
format , format , format , getAvailableLocales , getCurrency , getCurrencyInstance , getCurrencyInstance , getInstance , getInstance , getIntegerInstance , getIntegerInstance , getMaximumFractionDigits , getMaximumIntegerDigits , getMinimumFractionDigits , getMinimumIntegerDigits , getNumberInstance , getNumberInstance , getPercentInstance , getPercentInstance , isGroupingUsed , isParseIntegerOnly , parse , parseObject , setCurrency , setGroupingUsed , setMaximumFractionDigits , setMaximumIntegerDigits , setMinimumFractionDigits , setMinimumIntegerDigits , setParseIntegerOnly |
Ŭ·¡½º java.text. Format ¿¡¼ »ó¼Ó¹ÞÀº ¸Þ¼Òµå |
format , formatToCharacterIterator , parseObject |
Ŭ·¡½º java.lang. Object ¿¡¼ »ó¼Ó¹ÞÀº ¸Þ¼Òµå |
finalize , getClass , notify , notifyAll , toString , wait , wait , wait |
»ý¼ºÀÚÀÇ »ó¼¼ |
public ChoiceFormat(String newPattern)
applyPattern(java.lang.String)
public ChoiceFormat(double[] limits, String [] formats)
setChoices(double[], java.lang.String[])
¸Þ¼ÒµåÀÇ »ó¼¼ |
public void applyPattern(String newPattern)
newPattern
- Ŭ·¡½ºÀÇ ¼³¸íÀ» ÂüÁ¶public String toPattern()
public void setChoices(double[] limits, String [] formats)
limits
- ±× Æ÷¸ËÀ¸·Î ÇØ¼®ÇÏ´Â 1 ¹ø Å« °ª. À̰ÍÀº ½Â¼øÀÌ ¾Æ´Ï¸é ¾ÈµÈ´Ù. X ¸¦ Æ÷¸Ë ÇÏ´Â °æ¿ì, limit[i] <= X < limit[i+1] À̸é, ¼±Åà Ç׸ñÀº i °¡ µÈ´Ù. ¸®¹ÔÆ® ¹è¿ÀÌ ½Â¼øÀÌ ¾Æ´Ñ °æ¿ì, Æ÷¸ËÀÇ °á°ú´Â ¿Ã¹Ù¸£°Ô ¾È µÇ´Âformats
- °¢°¢ÀÇ ¸®¹ÔÆ®¿¡ ´ëÇØ¼ »ç¿ëÇÏ´Â Æ÷¸Ë. À̰ÍÀº Format ¿ÀºêÁ§Æ®³ª ij¸¯ÅÍ ¶óÀÎÀÌ´Ù. ¿ÀºêÁ§Æ® Y ·Î Æ÷¸Ë ÇÏ´Â °æ¿ì, ¿ÀºêÁ§Æ®°¡ NumberFormat À̸é, ((NumberFormat) Y). format(X)°¡ ºÒ·Á °£´Ù. ±×·¸Áö ¾ÊÀ¸¸é, Y.toString()°¡ ºÒ·Á °£´Ùpublic double[] getLimits()
public Object [] getFormats()
public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition status)
format(double, StringBuffer, FieldPosition)
¸¦ È£ÃâÇÕ´Ï´Ù. µû¶ó¼, ¼Æ÷Æ®µÇ´Â long ÀÇ ¹üÀ§´Â double ·Î ÀúÀåÇÒ ¼ö ÀÖ´Â ¹üÀ§¿¡ ÇÑÁ¤µË´Ï´Ù. À̰ÍÀÌ ½ÇÁ¦ÀÇ Á¦ÇÑÀÌ µÉ °ÍÀº ¾ø½À´Ï´Ù.
NumberFormat
³»ÀÇ format
Format.format(java.lang.Object)
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition status)
NumberFormat
³»ÀÇ format
number
- Æ÷¸Ë ¹× ġȯµÇ´Â ¼öÄ¡toAppendTo
- ÅØ½ºÆ®°¡ Ãß°¡µÇ´Â À§Ä¡status
- »ç¿ëÇÒ ¼ö ÀÖ´Â »óŰ¡ µ¹·ÁÁÖ¾îÁöÁö ¾ÊÀº °ÍÀº ¹«½ÃÇÏ´ÂFormat.format(java.lang.Object)
public Number parse(String text, ParsePosition status)
NumberFormat
³»ÀÇ parse
text
- ¼Ò½º ÅØ½ºÆ®status
- ÀÔÃâ·Â ÆÄ¶ó¹ÌÅÍ. ÀԷ½ÿ¡´Â status.index Çʵå´Â ÇØ¼®µÇ´Â ¼Ò½º ÅØ½ºÆ®ÀÇ ÃÖÃÊÀÇ Ä³¸¯Å͸¦ ³ªÅ¸³À´Ï´Ù. Ãⱸ¿¡¼ ¿¡·¯°¡ ¹ß»ýÇÏÁö ¾Ê¾Ò´ø °æ¿ì´Â status.index ´Â ¼Ò½º ÅØ½ºÆ®³»ÀÇ ÇØ¼®µÇ¾î ÀÖÁö ¾ÊÀº ÃÖÃÊÀÇ Ä³¸¯ÅÍ·Î ¼³Á¤µË´Ï´Ù. Ãⱸ¿¡¼ ¿¡·¯°¡ ¹ß»ýÇßÀ» °æ¿ì´Â status.index ´Â º¯°æµÇÁö ¾Ê°í status.errorIndex ´Â ÇØ¼®ÀÌ ½ÇÆÐÇÑ ¿øÀÎÀÌ µÈ ij¸¯ÅÍÀÇ ÃÖÃÊÀÇ À妽º·Î ¼³Á¤µË´Ï´Ù.
NumberFormat.isParseIntegerOnly()
,
Format.parseObject(java.lang.String, java.text.ParsePosition)
public static final double nextDouble(double d)
ÇÑÆíÀÌ ¿¸° °£°ÝÀ» ¸¸µå´Âµ¥ »ç¿ëÇÕ´Ï´Ù.
previousDouble(double)
public static final double previousDouble(double d)
nextDouble(double)
public Object clone()
NumberFormat
³»ÀÇ clone
public int hashCode()
NumberFormat
³»ÀÇ hashCode
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
NumberFormat
³»ÀÇ equals
obj
- ºñ±³ ´ë»óÀÇ ÂüÁ¶ ¿ÀºêÁ§Æ®
true
, ±×·¸Áö ¾ÊÀº °æ¿ì´Â false
Object.hashCode()
,
Hashtable
public static double nextDouble(double d, boolean positive)
|
JavaTM 2 Platform Std. Ed. v1. 4.0 |
||||||||||
ÀüÀÇ Å¬·¡½º ´ÙÀ½ÀÇ Å¬·¡½º | ÇÁ·¹ÀÓ ÀÖ¾î ÇÁ·¹ÀÓ ¾øÀ½ | ||||||||||
°³¿ä: »óÀÚ | Çʵå | constructor | ¸Þ¼Òµå | »ó¼¼: Çʵå | constructor | ¸Þ¼Òµå |
Java, Java 2 D, ¹× JDBC ´Â ¹Ì±¹ ¹× ±× ¿ÜÀÇ ³ª¶ó¿¡ ÀÖ¾î¼ÀÇ ¹Ì±¹ Sun Microsystems, Inc. ÀÇ »óÇ¥ ȤÀº µî·Ï»óÇ¥ÀÔ´Ï´Ù.
Copyright 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.