|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
| °³¿ä: »óÀÚ | Çʵå | constructor | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå | |||||||||
java.lang.Objectjava.text.Format
java.text.MessageFormat
public class MessageFormat
MessageFormat´Â
¿¬°áµÈ ¸Þ¼¼Áö¸¦, ¾ð¾î¿¡
Á¸ÇÏÁö ¾Ê´Â ¹æ¹ýÀ¸·Î ±¸ÃàÇϱâ À§ÇÑ
°ÍÀÔ´Ï´Ù. ÃÖÁ¾ »ç¿ëÀÚ¿ëÀ¸·Î Ç¥½ÃÇÏ´Â ¸Þ¼¼Áö´Â ÀÌ ¹æ¹ýÀ¸·Î ±¸ÃàÇØ ÁÖ¼¼¿ä.
MessageFormat´Â
1 Á¶ÀÇ °´Ã¼¸¦ Æ÷¸Ë ÇØ, Æ÷¸Ë ÇÑ Ä³¸¯ÅÍ ¶óÀÎÀ» ÆÐÅÏÀÇ ÀûÀýÇÑ Àå¼Ò¿¡ »ðÀÔÇÕ´Ï´Ù.
ÁÖ: MessageFormatÀÌ ´Ù¸¥ Format Ŭ·¡½º¿Í ´Ù¸¥ Á¡Àº, MessageFormat °´Ã¼¸¦ (getInstance ½ºÅ¸ÀÏÀÇ ÆÑÅ丮 ¸Þ¼µå°¡ ¾Æ´Ï°í) ±× »ý¼ºÀÚ 1°³
·Î ÀÛ¼ºÇÑ´Ù°í ÇÏ´Â °ÍÀÔ´Ï´Ù. MessageFormat¿¡
¼´Â ·ÎÄÉÀÏ °íÀ¯ÀÇ µ¿ÀÛÀº ±¸ÇöµÇ¾î ÀÖÁö ¾Ê±â ¶§¹®¿¡
ÆÑÅ丮 ¸Þ¼µå´Â ÇÊ¿ä ¾ø½À´Ï´Ù. ·ÎÄÉÀÏ °íÀ¯ÀÇ µ¿ÀÛÀº Á¦°øÇÏ´Â ÆÐÅÏ ¹× »ðÀÔµÈ Àμö¿¡ »ç¿ëÇÏ´Â ¼ºê Æ÷¸Ë¿¡ ÀÇÇØ Á¤Àǵ˴ϴÙ.
MessageFormat´Â ´ÙÀ½ÀÇ ÆÐÅÏÀ» »ç¿ëÇÕ´Ï´Ù.
MessageFormatPattern: String MessageFormatPattern FormatElement String
FormatElement: { ArgumentIndex } { ArgumentIndex,
FormatType } { ArgumentIndex,
FormatType,
FormatStyle }
FormatType: one of number date time choice
FormatStyle: short medium long full integer currency percent SubformatPattern
String: StringPartopt String StringPart
StringPart: '' ' QuotedString ' UnquotedString
SubformatPattern: SubformatPatternPartopt SubformatPattern SubformatPatternPart
SubFormatPatternPart: ' QuotedPattern ' UnquotedPattern
String ³»¿¡¼´Â ¡¸''¡¹´Â ´ÜÀÏ ÀοëºÎÈ£¸¦ ³ªÅ¸³À´Ï´Ù. QuotedString´Â ´ÜÀÏ ÀοëºÎÈ£¸¦ Á¦¿ÜÇÑ ÀÓÀÇÀÇ ¹®ÀÚ¸¦ Æ÷ÇÔÇÕ´Ï´Ù. µÑ·¯½Î°í ÀÖ´Â ´ÜÀÏ ÀοëºÎÈ£´Â »èÁ¦µË´Ï´Ù. UnquotedString´Â
´ÜÀÏ ÀοëºÎÈ£¿Í ¿ÞÂÊ´ë°ýÈ£¸¦ Á¦¿ÜÇÑ ÀÓÀÇÀÇ ¹®ÀÚ¸¦ Æ÷ÇÔÇÕ´Ï´Ù. µû¶ó¼, Æ÷¸ËµÈ
¸Þ¼¼Áö·Î ¡¸'{0}'¡¹°¡ µÇ´Â ij¸¯ÅÍ ¶óÀÎÀº ¡¸'''{'0}''¡¹¶Ç´Â ¡¸'''{0}'''¡¹(ÀÌ)¶ó°í ±â¼úÇÕ´Ï´Ù.
SubformatPattern ³»¿¡¼´Â ´Ù¸¥ ·êÀÌ Àû¿ëµË´Ï´Ù. QuotedPattern´Â ´ÜÀÏ ÀοëºÎÈ£ ÀÌ¿ÜÀÇ ÀÓÀÇÀÇ ¹®ÀÚ¸¦ Æ÷ÇÔÇÕ´Ï´Ù¸¸, µÑ·¯½Î°í ÀÖ´Â ´ÜÀÏ ÀοëºÎÈ£´Â »èÁ¦µÇÁö ¾Ê½À´Ï´Ù. ÀÌ ¶§¹®¿¡ ´ÜÀÏ ÀοëºÎÈ£´Â ¼ºê Æ÷¸Ë¿¡ ÀÇÇØ ÇØ¼®µË´Ï´Ù. ¿¹¸¦ µé¾î
¡¸{1, number,$'#',##}¡¹(ÀÌ)¶ó°í ÁöÁ¤Çϸé, ÇØ½Ã ±âÈ£ (#)°¡ ºÙÀº ¼öÄ¡ Æ÷¸ËÀÌ »ý¼ºµË´Ï´Ù. °á°ú´Â ¡¸$#31, 45¡¹¿Í °°ÀÌ µË´Ï´Ù. UnquotedPattern´Â
´ÜÀÏ ÀοëºÎÈ£ ÀÌ¿ÜÀÇ ÀÓÀÇÀÇ ¹®ÀÚ¸¦ Æ÷ÇÔÇÕ´Ï´Ù¸¸, ±× Á߾ȰýÈ£´Â Æä¾î°¡ µÇ¾î ÀÖÀ» Çʿ䰡 ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î
¡¸ab {0} de¡¹¿Í¡¸ab '}' de¡¹´Â À¯È¿ÇÑ ¼ºê Æ÷¸Ë ÆÐÅÏÀÔ´Ï´Ù¸¸, ¡¸ab {0'}' de¡¹¿Í¡¸ab } de¡¹´Â ¹«È¿ÀÔ´Ï´Ù.
ArgumentIndex Ä¡´Â ¼ýÀÚ 0 ~ 9¸¦ »ç¿ëÇØ ±â¼úÇÑ 0 ÀÌ»óÀÇ Á¤¼öÀÔ´Ï´Ù. format ¸Þ¼µå¿¡°Ô °Ç³×Áø arguments ¹è¿ ¶Ç´Â parse ¸Þ¼µå¿¡ ÀÇÇØ ¸®ÅÏµÈ °á°úÀÇ ¹è¿ÀÇ À妽º¸¦ ³ªÅ¸³À´Ï´Ù.
FormatType ¹× FormatStyle Ä¡´Â Æ÷¸Ë ¿ä¼ÒÀÇ FormatÀνºÅϽºÀÇ »ý¼º¿¡ »ç¿ëÇÕ´Ï´Ù. ´ÙÀ½ÀÇ °Ñ(Ç¥)¿¡
Format ÀνºÅϽº¿¡ÀÇ °ªÀÇ ¸Ê¿¡ ´ëÇØ °¡¸®Åµ´Ï´Ù. °Ñ(Ç¥)¿¡ ¾ø´Â Æí¼ºÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. SubformatPattern´Â
»ç¿ëÇÏ´Â Format ¼ºê Ŭ·¡½º¿¡ ´ëÇØ¼ À¯È¿ÇÑ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀÌ ¾Æ´Ï¸é ¾ÈµË´Ï´Ù.
| Æ÷¸ËÇü | Æ÷¸Ë ½ºÅ¸ÀÏ | »ý¼ºµÇ´Â ¼ºê Æ÷¸Ë | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| (¾øÀ½) | (¾øÀ½) | null | |||||||||||||||
number | (¾øÀ½) | NumberFormat.getInstance(getLocale()) | |||||||||||||||
integer | NumberFormat.getIntegerInstance(getLocale()) | ||||||||||||||||
currency | NumberFormat.getCurrencyInstance(getLocale()) | ||||||||||||||||
percent | NumberFormat.getPercentInstance(getLocale()) | ||||||||||||||||
| SubformatPattern | new DecimalFormat(subformatPattern, new DecimalFormatSymbols(getLocale())) | ||||||||||||||||
date | (¾øÀ½) | DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale()) | |||||||||||||||
short | DateFormat.getDateInstance(DateFormat.SHORT, getLocale()) | ||||||||||||||||
medium | DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale()) | ||||||||||||||||
long | DateFormat.getDateInstance(DateFormat.LONG, getLocale()) | ||||||||||||||||
full | DateFormat.getDateInstance(DateFormat.FULL, getLocale()) | ||||||||||||||||
| SubformatPattern | new SimpleDateFormat(subformatPattern, getLocale()) |
´ÙÀ½¿¡ ¸î°³ÀÇ »ç¿ë¿¹¸¦ ³ªÅ¸³À´Ï´Ù. ¹°·Ð ½ÇÁ¦ÀÇ ±¹Á¦È µÈ ÇÁ·Î±×·¥¿¡¼´Â ¸Þ¼¼Áö Æ÷¸Ë ÆÐÅÏÀ̳ª ±× ¿ÜÀÇ Á¤ÀûÀΠij¸¯ÅÍ ¶óÀÎÀº ÀÚ¿ø ¹øµé·ÎºÎÅÍ ÃëµæµË´Ï´Ù. ±× ¿ÜÀÇ ÆÄ¶ó¹ÌÅÍ´Â ½ÇÇà½Ã¿¡ µ¿ÀûÀ¸·Î °áÁ¤µË´Ï´Ù.
ÃÖÃÊÀÇ ¿¹¿¡¼´Â static ¸Þ¼µå MessageFormat.format¸¦ »ç¿ëÇϰí ÀÖ½À´Ï´Ù. ÀÌ ¸Þ¼µå´Â ³»ºÎÀûÀ¸·Î 1¹ø
ÇÑÁ¤ÀÇ »ç¿ë ¸ñÀûÀ¸·Î MessageFormatÀνºÅϽº¸¦ ÀÛ¼ºÇÕ´Ï´Ù.
int planet = 7;
String event = "a disturbance in the Force";
String result = MessageFormat.format( "At {1, time} on {1, date}, there was {2} on planet {0, number, integer}. ", planet, new Date(), event);
Ãâ·Â °á°ú´Â ´ÙÀ½°ú °°ÀÌ µË´Ï´Ù. At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7.
´ÙÀ½ÀÇ ¿¹¿¡¼´Â ¹Ýº¹ »ç¿ë °¡´ÉÇÑ MessageFormatÀνºÅϽº¸¦ ÀÛ¼ºÇÕ´Ï´Ù.
int fileCount = 1273;
String diskName = "MyDisk";
Object[] testArgs = {new Long(fileCount), diskName};
MessageFormat form = new MessageFormat( "The disk \"{1}\" contains {0} file(s). ");
System.out.println(form.format(testArgs)); fileCount¿¡ ´Ù¾çÇÑ °ªÀ» ¼³Á¤ÇßÀ» °æ¿ìÀÇ Ãâ·Â °á°ú¸¦ ´ÙÀ½¿¡ ³ªÅ¸³À´Ï´Ù. The disk "MyDisk" contains 0 file(s). The disk "MyDisk" contains 1 file(s). The disk "MyDisk" contains 1,273 file(s).
º¸´Ù °íµµÀÇ ÆÐÅÏÀ» ½ÇÇöÇÏ°í ½Í´Ù¸é, ChoiceFormat¸¦ »ç¿ëÇÏ´Â °ÍÀ¸·Î ´Ü¼ö¿Í º¹¼ö¿¡ ´ëÇØ¼ °¢°¢ ÀûÀýÇÑ Çü½ÄÀ» »ý¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù.
MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0}. ");
double[] filelimits = {0,1,2};
String[] filepart = {"no files","one file","{0, number} files"};
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
form.setFormatByArgumentIndex(0, fileform);
int fileCount = 1273; String diskName = "MyDisk"; Object[] testArgs = {new Long(fileCount), diskName};
System.out.println(form.format(testArgs)); fileCount¿¡ ´Ù¾çÇÑ °ªÀ» ¼³Á¤ÇßÀ» °æ¿ìÀÇ Ãâ·Â °á°ú¸¦ ´ÙÀ½¿¡ ³ªÅ¸³À´Ï´Ù. The disk "MyDisk" contains no files. The disk "MyDisk" contains one file. The disk "MyDisk" contains 1,273 files.
À§ÀÇ ¿¹ÀÇ °°°Ô ChoiceFormat¸¦ ÇÁ·Î±×·¥ÀûÀ¸·Î ÀÛ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù¸¸, ´ÙÀ½°ú °°ÀÌ ÆÐÅÏÀ» »ç¿ëÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ÀÚ¼¼ÇÑ °ÍÀº ChoiceFormat¸¦
ÂüÁ¶ÇϽʽÿÀ.
form.applyPattern( "There {0, choice, 0#are no files|1#is one file|1<are {0, number, integer} files}. ");
ÁÖ: »ó±â·ÎºÎÅÍ ¾Ë¼ö ÀÖµíÀÌ, MessageFormat
ChoiceFormat¿¡ ÀÇÇØ »ý¼ºµÇ´Â ij¸¯ÅÍ ¶óÀÎÀÇ Ãë±ÞÀº ²Ï Ư¼öÇÕ´Ï´Ù. ¡¸{¡¹ÀÇ Á¸Àç¿¡ ÀÇÇØ ¼ºê Æ÷¸ËÀÎ °ÍÀ» ³ªÅ¸³», Àç±Í 󸮸¦ ÇàÇϰí ÀÖ½À´Ï´Ù. MessageFormat¿Í
ChoiceFormat¸¦ ¾çÂÊ ¸ðµÎ (ij¸¯ÅÍ ¶óÀÎ ÆÐÅÏÀ¸·Î¼°¡ ¾Æ´Ï°Ô) ÇÁ·Î±×·¥ÀûÀ¸·Î ÀÛ¼ºÇÏ´Â °æ¿ì¿¡´Â Àç±ÍÀûÀ¸·Î ¹Ýº¹ÇÏ´Â Æ÷¸ËÀ» ÀÛ¼ºÇØ ¿µ±¸ ·çÇÁ¿¡ ºüÁöÁö ¾Ê°Ô ÁÖÀÇÇØ ÁÖ¼¼¿ä.
1°³ÀÇ Àμö°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼ ¿©·¯ Â÷·Ê ÇØ¼®µÇ¸é, ¸¶Áö¸·¿¡ ÀÏÄ¡ÇÏ´Â °ÍÀÌ ÇØ¼®ÀÇ ÃÖÁ¾ °á°ú°¡ µË´Ï´Ù. ´ÙÀ½¿¡ ¿¹¸¦ ³ªÅ¸³À´Ï´Ù.
MessageFormat mf = new MessageFormat("{0, number,#. ##}, {0, number,#. #}");
Object[] objs = {new Double(3.1415)};
String result = mf.format( objs );
// result now equals "3.14, 3.1" objs = null;
objs = mf.parse(result, new ParsePosition(0));
// objs now equals {new Double(3.1)}
°°ÀÌ °°Àº Àμö°¡ ¿©·¯ Â÷·Ê ³ª¿À´Â ÆÐÅÏÀ» »ç¿ëÇØ MessageFormat °´Ã¼¸¦ ÇØ¼®Çϸé, ¸¶Áö¸·¿¡ ÀÏÄ¡ÇÏ´Â °ÍÀÌ ¸®Åϵ˴ϴ٠. ´ÙÀ½¿¡ ¿¹¸¦ ³ªÅ¸³À´Ï´Ù.
MessageFormat mf = new MessageFormat("{0}, {0}, {0}");
String forParsing = "x, y, z";
Object[] objs = mf.parse(forParsing, new ParsePosition(0));
// result now equals {new String("z")}
¸Þ¼¼Áö Æ÷¸ËÀº µ¿±âÈ µÇÁö ¾Ê½À´Ï´Ù. thread ¸¶´Ù ´Ù¸¥ Æ÷¸Ë ÀνºÅϽº¸¦ ÀÛ¼ºÇÏ´Â °ÍÀ» ÃßõÇÕ´Ï´Ù. º¹¼öÀÇ thread°¡ Æ÷¸Ë¿¡ µ¿½Ã¿¡ ¾×¼¼½º ÇÏ´Â °æ¿ì´Â ¿ÜºÎÀûÀ¸·Î µ¿±âÈÇÒ Çʿ䰡 ÀÖ½À´Ï´Ù.
Locale,
Format,
NumberFormat,
DecimalFormat,
ChoiceFormat,
Á÷·ÄÈ µÈ Çü½Ä | Áßø(Nested) Ŭ·¡½º °³¿ä | |
|---|---|
static class |
MessageFormat.Field
MessageFormat.formatToCharacterIterator·Î
ºÎÅÍ ¸®ÅÏµÈ AttributedCharacterIterator ³»ÀÇ ¼Ó¼º Ű·Î¼ »ç¿ëÇÏ´Â Á¤¼ö¸¦ Á¤ÀÇÇÕ´Ï´Ù. |
| »ý¼ºÀÚ °³¿ä | |
|---|---|
MessageFormat (String pattern)
µðÆúÆ® ·ÎÄÉÀϰú ÁöÁ¤µÈ ÆÐÅÏÀ» À§ÇÑ MessageFormat¸¦ ±¸ÃàÇÕ´Ï´Ù. |
|
MessageFormat (String pattern,
Locale locale)
ÁöÁ¤µÈ ·ÎÄÉÀϰú ÆÐÅÏÀ» À§ÇÑ MessageFormat¸¦ ±¸ÃàÇÕ´Ï´Ù. |
|
| ¸Þ¼µå °³¿ä | |
|---|---|
void |
applyPattern (String pattern)
ÀÌ ¸Þ¼¼Áö Æ÷¸Ë¿¡ ÀÇÇØ »ç¿ëµÇ´Â ÆÐÅÏÀ» ¼³Á¤ÇÕ´Ï´Ù. |
Object |
clone ()
ÀÌ °´Ã¼ÀÇ º¹»çº»À» ÀÛ¼ºÇØ, ¸®ÅÏÇÕ´Ï´Ù. |
boolean |
equals (Object obj)
2°³ÀÇ ¸Þ¼¼Áö Æ÷¸Ë °´Ã¼ÀÇ »çÀÌÀÇ µîÈ£ ºñ±³ÀÔ´Ï´Ù. |
StringBuffer |
format (Object [] arguments,
StringBuffer result,
FieldPosition pos)
°´Ã¼ÀÇ ¹è¿À» Æ÷¸Ë ÇØ, Á¦°øµÈ StringBuffer¿¡
Æ÷¸Ë ¿ä¼Ò¸¦ Æ÷¸ËµÈ
°´Ã¼¿¡ ÀÇÇØ ¿Å°Ü³õ¾Æ MessageFormat
ÆÐÅÏÀ» Ãß°¡ÇÕ´Ï´Ù. |
StringBuffer |
format (Object arguments,
StringBuffer result,
FieldPosition pos)
°´Ã¼ÀÇ ¹è¿À» Æ÷¸Ë ÇØ, Á¦°øµÈ StringBuffer¿¡
Æ÷¸Ë ¿ä¼Ò¸¦ Æ÷¸ËµÈ
°´Ã¼·Î ¿Å°Ü³õ¾Æ, MessageFormat
ÆÐÅÏÀ» Ãß°¡ÇÕ´Ï´Ù. |
static String |
format (String pattern,
Object ... arguments)
ÁöÁ¤µÈ ÆÐÅÏÀ» »ç¿ëÇØ MessageFormat¸¦ ÀÛ¼ºÇØ, ±×°ÍÀ» »ç¿ëÇØ ÁöÁ¤µÈ Àμö¸¦ Æ÷¸Ë ÇÕ´Ï´Ù. |
AttributedCharacterIterator |
formatToCharacterIterator (Object arguments)
°´Ã¼ÀÇ ¹è¿À» Æ÷¸Ë ÇØ, ±×°ÍÀ» MessageFormat
ÆÐÅÏ¿¡ »ðÀÔÇØ, AttributedCharacterIterator¸¦ »ý¼ºÇÕ´Ï´Ù. |
Format [] |
getFormats ()
¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â Æ÷¸ËÀ» ÃëµæÇÕ´Ï´Ù. |
Format [] |
getFormatsByArgumentIndex ()
format ¸Þ¼µå¿¡°Ô °Ç³×Áö´Â °ª ¶Ç´Â parse ¸Þ¼µå·ÎºÎÅÍ ¸®ÅÏµÈ °ª¿¡ »ç¿ëµÇ´Â Æ÷¸ËÀ» ÃëµæÇÕ´Ï´Ù. |
Locale |
getLocale ()
¼ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëµÇ´Â ·ÎÄÉÀÏÀ» ÃëµæÇÕ´Ï´Ù. |
int |
hashCode ()
¸Þ¼¼Áö Æ÷¸Ë °´Ã¼ÀÇ ÇØ½Ã Äڵ带 »ý¼ºÇÕ´Ï´Ù. |
Object [] |
parse (String source)
ÁöÁ¤µÈ ij¸¯ÅÍ ¶óÀÎÀÇ ¼±µÎ·ÎºÎÅÍ ÅØ½ºÆ®¸¦ ÇØ¼®ÇØ °´Ã¼ ¹è¿À» »ý¼ºÇÕ´Ï´Ù. |
Object [] |
parse (String source,
ParsePosition pos)
ij¸¯ÅÍ ¶óÀÎÀ» ÇØ¼®ÇÕ´Ï´Ù. |
Object |
parseObject (String source,
ParsePosition pos)
ij¸¯ÅÍ ¶óÀÎÀ¸·ÎºÎÅÍ ÅØ½ºÆ®¸¦ ÇØ¼®ÇØ °´Ã¼ ¹è¿À» »ý¼ºÇÕ´Ï´Ù. |
void |
setFormat (int formatElementIndex,
Format newFormat)
¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ ÁöÁ¤µÈ Æ÷¸Ë ¿ä¼Ò À妽º·Î Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. |
void |
setFormatByArgumentIndex (int argumentIndex,
Format newFormat)
ÁöÁ¤µÈ Àμö À妽º¸¦ »ç¿ëÇÑ´Ù, ¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. |
void |
setFormats (Format [] newFormats)
¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. |
void |
setFormatsByArgumentIndex (Format [] newFormats)
format ¸Þ¼µå¿¡°Ô °Ç³×Áö´Â °ª ¶Ç´Â parse ¸Þ¼µå·ÎºÎÅÍ ¸®ÅÏµÈ °ª¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. |
void |
setLocale (Locale locale)
¼ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÏ´Â ·ÎÄÉÀÏÀ» ¼³Á¤ÇÕ´Ï´Ù. |
String |
toPattern ()
¸Þ¼¼Áö Æ÷¸ËÀÇ ÇöÀç »óŸ¦ ³ªÅ¸³»´Â ÆÐÅÏÀ» ¸®ÅÏÇÕ´Ï´Ù. |
| Ŭ·¡½º java.text. Format ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
|---|
format,
parseObject |
| Ŭ·¡½º java.lang. Object ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
|---|
finalize,
getClass,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| »ý¼ºÀÚ »ó¼¼ |
|---|
public MessageFormat(String pattern)
pattern - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ÆÐÅÏ
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÎ °æ¿ì
public MessageFormat(String pattern,
Locale locale)
pattern - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ÆÐÅÏlocale - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ·ÎÄÉÀÏ
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÎ °æ¿ì| ¸Þ¼µåÀÇ »ó¼¼ |
|---|
public void setLocale(Locale locale)
applyPattern ¹× toPattern ¸Þ¼µå¿Í format ¹× formatToCharacterIterator ¸Þ¼µå¿¡ÀÇ È£Ãâ¿¡ ¿µÇâÀ» ÁÝ´Ï´Ù.
locale - ¼ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÏ´Â ·ÎÄÉÀÏpublic Locale getLocale()
public void applyPattern(String pattern)
pattern - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ÆÐÅÏ
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÎ °æ¿ìpublic String toPattern()
public void setFormatsByArgumentIndex(Format [] newFormats)
format ¸Þ¼µå¿¡°Ô °Ç³×Áö´Â °ª ¶Ç´Â parse ¸Þ¼µå·ÎºÎÅÍ ¸®ÅÏµÈ °ª¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. newFormats ³»ÀÇ ¿ä¼ÒÀÇ À妽º´Â ¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î »ç¿ëµÇ´Â Àμö À妽º¿¡ ´ëÀÀÇÕ´Ï´Ù. µû¶ó¼, newFormats ³»ÀÇ Æ÷¸ËÀÇ ¼ø¼´Â format ¸Þ¼µå¿¡°Ô °Ç³×Áø arguments ¹è¿ ¶Ç´Â parse ¸Þ¼µå¿¡ ÀÇÇØ ¸®ÅÏµÈ °á°úÀÇ ¹è¿³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼¿¡ ´ëÀÀÇÕ´Ï´Ù.
Àμö À妽º°¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»¿¡¼ º¹¼öÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â °æ¿ì, ´ëÀÀÇÏ´Â »õ·Î¿î Æ÷¸ËÀÌ ±× ¸ðµç Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµË´Ï´Ù. Àμö À妽º°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼ ¾î´À Æ÷¸Ë ¿ä¼Ò¿¡µµ »ç¿ëµÇÁö ¾Ê´Â °æ¿ì´Â ´ëÀÀÇÏ´Â »õ·Î¿î Æ÷¸ËÀº ¹«½ÃµË´Ï´Ù. Á¦°øµÈ Æ÷¸ËÀÌ ÇÊ¿ä¼ö¿¡ ¸ø ¹ÌÄ£ °æ¿ì, newFormats.length º¸´Ù ÀûÀº Àμö À妽º¿¡ ´ëÇÑ Æ÷¸Ë¸¸ÀÌ ¿Å°Ü³õÀ» ¼ö ÀÖ½À´Ï´Ù.
newFormats - »ç¿ëÇÏ´Â »õ·Î¿î Æ÷¸Ë
NullPointerException - newFormats°¡ nullÀÎ °æ¿ìpublic void setFormats(Format [] newFormats)
newFormats ³»ÀÇ Æ÷¸ËÀÇ ¼ø¼´Â ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼¿¡ ´ëÀÀÇÕ´Ï´Ù.
ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î ÇÊ¿ä·Î ÇÏ´Â °Íº¸´Ùµµ ¸¹Àº Æ÷¸ËÀÌ Á¦°øµÇ¾úÀ» °æ¿ì, ³²Àº Æ÷¸ËÀº ¹«½ÃµË´Ï´Ù. ÇÊ¿ä¼ö¿¡ ¸ø ¹ÌÄ£ °æ¿ì´Â ÃÖÃÊÀÇ newFormats.length ¸¸ÀÌ ¿Å°Ü³õÀ» ¼ö ÀÖ½À´Ï´Ù.
ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼´Â Áö¿ª ´ëÀÀÈÀÇ Ã³¸® °úÁ¤¿¡¼ º¯°æµÇ´Â °ÍÀÌ ¸¹±â ¶§¹®¿¡
ÀϹÝÀûÀ¸·Î setFormatsByArgumentIndex ¸Þ¼µå¸¦ »ç¿ëÇÏ´Â ÆíÀÌ È¿À²ÀûÀÔ´Ï´Ù. ÀÌ ¸Þ¼µå´Â Æ÷¸ËÀÇ ¼ø¼¸¦ format ¸Þ¼µå¿¡°Ô °Ç³×Áø arguments ¹è¿ ¶Ç´Â parse ¸Þ¼µå¿¡ ÀÇÇØ ¸®ÅÏµÈ °á°úÀÇ ¹è¿³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼¿¡ ´ëÀÀÇÏ´Â °ÍÀ̶ó°í º¾´Ï´Ù.
newFormats - »ç¿ëÇÏ´Â »õ·Î¿î Æ÷¸Ë
NullPointerException - newFormats°¡ nullÀÎ °æ¿ì
public void setFormatByArgumentIndex(int argumentIndex,
Format newFormat)
format ¸Þ¼µå¿¡°Ô °Ç³×Áø arguments ¹è¿ ¶Ç´Â parse ¸Þ¼µå¿¡ ÀÇÇØ ¸®ÅÏµÈ °á°úÀÇ ¹è¿ÀÇ À妽º¸¦ ³ªÅ¸³À´Ï´Ù.
Àμö À妽º°¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»¿¡¼ º¹¼öÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â °æ¿ì, »õ·Î¿î Æ÷¸ËÀÌ ±× ¸ðµç Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµË´Ï´Ù. Àμö À妽º°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼ ¾î´À Æ÷¸Ë ¿ä¼Ò¿¡µµ »ç¿ëµÇÁö ¾Ê´Â °æ¿ì´Â »õ·Î¿î Æ÷¸ËÀº ¹«½ÃµË´Ï´Ù.
argumentIndex - »õ·Î¿î Æ÷¸Ë¿¡ »ç¿ëÇϱâ À§ÇÑ Àμö À妽ºnewFormat - »ç¿ëÇÏ´Â »õ·Î¿î Æ÷¸Ë
public void setFormat(int formatElementIndex,
Format newFormat)
ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼´Â Áö¿ª ´ëÀÀÈÀÇ Ã³¸® °úÁ¤¿¡¼ º¯°æµÇ´Â °ÍÀÌ ¸¹±â ¶§¹®¿¡
ÀϹÝÀûÀ¸·Î setFormatByArgumentIndex ¸Þ¼µå¸¦ »ç¿ëÇÏ´Â ÆíÀÌ È¿À²ÀûÀÔ´Ï´Ù. ÀÌ ¸Þ¼µå´Â Æ÷¸Ë ¿ä¼Ò°¡ ÁöÁ¤ÇÏ´Â Àμö À妽º¸¦ ±âº»À¸·Î Æ÷¸Ë ¿ä¼Ò¿¡ ¾×¼¼½º ÇÕ´Ï´Ù.
formatElementIndex - ÆÐÅϳ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ À妽ºnewFormat - ÁöÁ¤µÈ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸Ë
ArrayIndexOutOfBoundsException - formatElementIndex °¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼öÀÌ»óÀÇ °æ¿ìpublic Format [] getFormatsByArgumentIndex()
format ¸Þ¼µå¿¡°Ô °Ç³×Áö´Â °ª ¶Ç´Â parse ¸Þ¼µå·ÎºÎÅÍ ¸®ÅÏµÈ °ª¿¡ »ç¿ëµÇ´Â Æ÷¸ËÀ» ÃëµæÇÕ´Ï´Ù. ¸®ÅÏµÈ ¹è¿³»ÀÇ ¿ä¼ÒÀÇ À妽º´Â ¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î »ç¿ëµÇ´Â Àμö À妽º¿¡ ´ëÀÀÇÕ´Ï´Ù. µû¶ó¼, ¸®ÅÏµÈ ¹è¿³»ÀÇ Æ÷¸ËÀÇ ¼ø¼´Â format ¸Þ¼µå¿¡°Ô °Ç³×Áø arguments ¹è¿ ¶Ç´Â parse ¸Þ¼µå¿¡ ÀÇÇØ ¸®ÅÏµÈ °á°úÀÇ ¹è¿³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼¿¡ ´ëÀÀÇÕ´Ï´Ù.
Àμö À妽º°¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»¿¡¼ º¹¼öÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â °æ¿ì, ±× ¸¶Áö¸· Æ÷¸Ë ¿ä¼Ò·Î »ç¿ëµÇ´Â Æ÷¸ËÀÌ ¹è¿¿¡ ¸®Åϵ˴ϴ٠. Àμö À妽º°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼ ¾î´À Æ÷¸Ë ¿ä¼Ò¿¡µµ »ç¿ëµÇÁö ¾Ê´Â °æ¿ì´Â nullÀÌ ¹è¿¿¡ ¸®Åϵ˴ϴ٠.
public Format [] getFormats()
ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼´Â Áö¿ª ´ëÀÀÈÀÇ Ã³¸® °úÁ¤¿¡¼ º¯°æµÇ´Â °ÍÀÌ ¸¹±â ¶§¹®¿¡
ÀϹÝÀûÀ¸·Î getFormatsByArgumentIndex ¸Þ¼µå¸¦ »ç¿ëÇÏ´Â ÆíÀÌ È¿À²ÀûÀÔ´Ï´Ù. ÀÌ ¸Þ¼µå´Â Æ÷¸ËÀÇ ¼ø¼¸¦ format ¸Þ¼µå¿¡°Ô °Ç³×Áø arguments ¹è¿ ¶Ç´Â parse ¸Þ¼µå¿¡ ÀÇÇØ ¸®ÅÏµÈ °á°úÀÇ ¹è¿³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼¿¡ ´ëÀÀÇÏ´Â °ÍÀ̶ó°í º¾´Ï´Ù.
public final StringBuffer format(Object [] arguments,
StringBuffer result,
FieldPosition pos)
StringBuffer¿¡
Æ÷¸Ë ¿ä¼Ò¸¦ Æ÷¸ËµÈ
°´Ã¼¿¡ ÀÇÇØ ¿Å°Ü³õ¾Æ MessageFormat
ÆÐÅÏÀ» Ãß°¡ÇÕ´Ï´Ù.
°³°³ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ ġȯµÈ ÅØ½ºÆ®´Â ´ÙÀ½ÀÇ °Ñ(Ç¥)ÀÇ ÃÖÃÊ·Î ÀÏÄ¡ÇÏ´Â ÇàÀ¸·Î ³ªÅ¸³ªµµ·Ï, Æ÷¸Ë ¿ä¼ÒÀÇ ÇöÀçÀÇ ¼ºê Æ÷¸Ë°ú Æ÷¸Ë ¿ä¼ÒÀÇ Àμö À妽º¿¡ ÀÖ´Â arguments ¿ä¼Ò·ÎºÎÅÍ ¾òÀ» ¼ö ÀÖ½À´Ï´Ù. Àμö´Â arguments°¡ nullÀÎÁö, ¶Ç´Â ¿ä¼ÒÀÇ ¼ö°¡ argumentIndex+1°³
º¸´Ù ÀûÀº °æ¿ì, »ç¿ë ºÒ°¡ÀÔ´Ï´Ù.
| ¼ºê Æ÷¸Ë | Àμö | Æ÷¸ËµÈ ÅØ½ºÆ® |
|---|---|---|
| ÀÓÀÇ | »ç¿ë ºÒ°¡ | "{" + argumentIndex + "}" |
| ÀÓÀÇ | null | "null" |
instanceof ChoiceFormat | ÀÓÀÇ | subformat.format(argument). indexOf('{') >= 0 ? |
! = null | ÀÓÀÇ | subformat.format(argument) |
null | instanceof Number | NumberFormat.getInstance(getLocale()). format(argument) |
null | instanceof Date | DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()). format(argument) |
null | instanceof String | argument |
null | ÀÓÀÇ | argument.toString() |
pos°¡ nullÀÌ ¾Æ´Ï°í, ÇÑÆí Field.ARGUMENT¸¦ ÂüÁ¶Çϰí ÀÖ´Â °æ¿ì, ÃÖÃÊÀÇ Æ÷¸ËµÈ
ij¸¯ÅÍ ¶óÀÎÀÇ À§°ªÀÌ ¸®Åϵ˴ϴÙ
.
arguments - Æ÷¸Ë Çϵ簡 ¶Ç´Â ¿Å°Ü³õ´Â °´Ã¼·ÎºÎÅÍ µÇ´Â ¹è¿result - ÅØ½ºÆ®°¡ Ãß°¡µÇ´Â À§Ä¡pos - ÀÔ·ÂÀÇ °æ¿ì´Â À§Ä¡ ¸ÂÃã Çʵå (ÇÊ¿äÇÑ °æ¿ì). Ãâ·ÂÀÇ °æ¿ì´Â À§Ä¡ ¸ÂÃã ÇʵåÀÇ ¿ÀÇÁ¼Â(offset)
IllegalArgumentException - arguments ¹è¿³»ÀÇ Àμö°¡ ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ÇüŰ¡ ¾Æ´Ñ °æ¿ì
public static String format(String pattern,
Object ... arguments)
(new MessageFormat (pattern)). format (arguments, new StringBuffer(), null). toString()
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÇ °æ¿ì, ¶Ç´Â arguments ¹è¿³»ÀÇ Àμö°¡ ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ÇüŰ¡ ¾Æ´Ñ °æ¿ì
public final StringBuffer format(Object arguments,
StringBuffer result,
FieldPosition pos)
StringBuffer¿¡
Æ÷¸Ë ¿ä¼Ò¸¦ Æ÷¸ËµÈ
°´Ã¼·Î ¿Å°Ü³õ¾Æ, MessageFormat
ÆÐÅÏÀ» Ãß°¡ÇÕ´Ï´Ù. À̰ÍÀº ¾Æ·¡ÀÇ ±â¼ú°ú µ¿µîÇÕ´Ï´Ù. format ((Object[]) arguments, result, pos)
Format ³»ÀÇ format arguments - Æ÷¸Ë Çϵ簡 ¶Ç´Â ¿Å°Ü³õ´Â °´Ã¼·ÎºÎÅÍ µÇ´Â ¹è¿result - ÅØ½ºÆ®°¡ Ãß°¡µÇ´Â À§Ä¡pos - ÀÔ·ÂÀÇ °æ¿ì´Â À§Ä¡ ¸ÂÃã Çʵå (ÇÊ¿äÇÑ °æ¿ì). Ãâ·ÂÀÇ °æ¿ì´Â À§Ä¡ ¸ÂÃã ÇʵåÀÇ ¿ÀÇÁ¼Â(offset)
toAppendTo·Î
¼ °Ç³×¹Þ´Â ij¸¯ÅÍ ¶óÀÎ ¹öÆÛ. Æ÷¸ËµÈ
ÅØ½ºÆ®°¡ Ãß°¡µÈ´Ù
IllegalArgumentException - arguments ¹è¿³»ÀÇ Àμö°¡ ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ÇüŰ¡ ¾Æ´Ñ °æ¿ìpublic AttributedCharacterIterator formatToCharacterIterator(Object arguments)
MessageFormat
ÆÐÅÏ¿¡ »ðÀÔÇØ, AttributedCharacterIterator¸¦ »ý¼ºÇÕ´Ï´Ù. ¸®ÅÏµÈ AttributedCharacterIterator¸¦ »ç¿ëÇϸé, °á°úÀÇ String¸¦ ±¸ÃàÇÒ ¼ö ÀÖ´Â °Í°ú µ¿½Ã¿¡
°á°úÀÇ String¿¡ ´ëÇÑ Á¤º¸¸¦ ÆÇÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.
¸®ÅÏµÈ AttributedCharacterIterator
ÅØ½ºÆ®´Â ¾Æ·¡ÀÇ ±â¼ú¿¡ ÀÇÇØ ¸®ÅϵÈ
ÅØ½ºÆ®¿Í µ¿ÀÏÇÕ´Ï´Ù.
format (arguments, new StringBuffer(), null). toString()
°Ô´Ù°¡AttributedCharacterIterator´Â
Àû¾îµµ arguments ¹è¿³»ÀÇ Àμö·ÎºÎÅÍ ÅØ½ºÆ®°¡ »ý¼ºµÈ À§Ä¡¸¦ ³ªÅ¸³»´Â ¼Ó¼ºÀ» Æ÷ÇÔÇÕ´Ï´Ù. ÀÌ·¯ÇÑ ¼Ó¼ºÀÇ Å°´Â MessageFormat.Field ÇüÀÔ´Ï´Ù. ¼Ó¼ºÀÇ °ªÀº ÅØ½ºÆ®°¡ »ý¼ºµÈ ÀμöÀÇ arguments ¹è¿³»ÀÇ À妽º¸¦ ³ªÅ¸³»´Â Integer °´Ã¼ÀÔ´Ï´Ù.
MessageFormatÀÌ »ç¿ëÇÏ´Â ±âº»ÀÇ FormatÀνºÅϽº·ÎºÎÅÍÀÇ ¼Ó¼º/Ä¡µµ, °á°úÀÇ AttributedCharacterIterator¿¡ ¹èÄ¡µË´Ï´Ù. À̰Ϳ¡ ÀÇÇØ
°á°úÀÇ String ³»ÀÇ ÀμöÀÇ À§Ä¡¸¦ ¾Ë ¼ö ÀÖÀ» »Ó¸¸ ¾Æ´Ï¶ó, ±× Àμö°¡ ¾î´À Çʵ忡 Æ÷ÇԵǾî ÀÖÀ»Áöµµ ¾Ð´Ï´Ù.
Format ³»ÀÇ formatToCharacterIterator arguments - Æ÷¸Ë Çϵ簡 ¶Ç´Â ¿Å°Ü³õ´Â °´Ã¼·ÎºÎÅÍ µÇ´Â ¹è¿
NullPointerException - arguments°¡ nullÀÎ °æ¿ì
IllegalArgumentException - arguments ¹è¿³»ÀÇ Àμö°¡ ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ÇüŰ¡ ¾Æ´Ñ °æ¿ì
public Object [] parse(String source,
ParsePosition pos)
ÁÖÀÇ: ÇØ¼®Àº ´Ù¾çÇÑ ¿øÀÎÀ» À§Çؼ Àß µ¿ÀÛÇÏÁö ¾Ê´Â °ÍÀÌ ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î ´ÙÀ½°ú °°Àº °æ¿ìÀÔ´Ï´Ù.
public Object [] parse(String source)
throws ParseException
¸Þ¼¼ÁöÀÇ ÇØ¼®¿¡ ´ëÇÑÀÚ¼¼ÇÑ ³»¿ëÀº parse(String, ParsePosition) ¸Þ¼µå¸¦ ÂüÁ¶ÇϽʽÿÀ.
source - ¼±µÎ°¡ ÇØ¼®µÇ´Â String
Object ¹è¿
ParseException - ÁöÁ¤µÈ ij¸¯ÅÍ ¶óÀÎÀÇ ¼±µÎ¸¦ ÇØ¼®ÇÒ ¼ö ¾ø´Â °æ¿ì
public Object parseObject(String source,
ParsePosition pos)
¸Þ¼µå´Â pos¿¡ ÀÇÇØ ÁöÁ¤µÈ À妽º¸¦ °³½Ã À§°ªÀ¸·Î
ÅØ½ºÆ®ÀÇ ÇØ¼®À» ½ÃµµÇÕ´Ï´Ù. ÇØ¼®ÀÌ ¿Ï·áÇϸé, pos
À妽º´Â »ç¿ëµÈ ¸¶Áö¸· ¹®ÀÚ (ÇØ¼®¿¡¼´Â ij¸¯ÅÍ ¶óÀÎÀÇ ³¡±îÁöÀÇ ¸ðµç ¹®ÀÚ°¡ »ç¿ëµÈ´Ù°í´Â ÇÒ ¼ö ¾ø´Ù)ÀÇ µÚÀÇ À妽º¿¡ °»½ÅµÇ¾î ÇØ¼®µÈ °´Ã¼ ¹è¿ÀÌ ¸®Åϵ˴ϴÙ
. °»½ÅµÈ pos´Â
ÀÌ ¸Þ¼µåÀÇ ´ÙÀ½ÀÇ È£ÃâÀÇ °³½ÃÁ¡À» ³ªÅ¸³»±â À§Çؼ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¡·¯°¡ ¹ß»ýÇßÀ» °æ¿ì´Â pos
À妽º´Â º¯°æµÇÁö ¾Ê°í, ¿¡·¯°¡ ¹ß»ýÇÑ ¹®ÀÚÀÇ À妽º¿¡ pos
¿¡·¯ À妽º°¡ ¼³Á¤µÇ¾î nullÀÌ ¸®Åϵ˴ϴÙ
.
¸Þ¼¼ÁöÀÇ ÇØ¼®¿¡ ´ëÇÑÀÚ¼¼ÇÑ ³»¿ëÀº parse(String, ParsePosition) ¸Þ¼µå¸¦ ÂüÁ¶ÇϽʽÿÀ.
Format ³»ÀÇ parseObject source - ºÎºÐÀûÀ¸·Î ÇØ¼®µÇ´Â Stringpos - »ó±âÀÇ À妽º ¹× ¿¡·¯ À妽º Á¤º¸¸¦ °¡Áö´Â ParsePosition °´Ã¼
Object ¹è¿. ¿¡·¯ÀÇ °æ¿ì´Â nullÀ»
µ¹·ÁÁØ´Ù
NullPointerException - pos°¡ nullÀÎ °æ¿ìpublic Object clone()
Format ³»ÀÇ clone Cloneable public boolean equals(Object obj)
Object ³»ÀÇ equals obj - ºñ±³ ´ë»óÀÇ ÂüÁ¶ °´Ã¼
true, ±×·¸Áö ¾ÊÀº °æ¿ì´Â falseObject.hashCode(),
Hashtable public int hashCode()
Object ³»ÀÇ hashCode Object.equals(java.lang.Object),
Hashtable
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
| °³¿ä: »óÀÚ | Çʵå | constructor | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ ÂüÁ¶ÇϽʽÿÀ.