JavaTM 2
Platform
Std.  Ed.  v1. 4.0

java.text
Ŭ·¡½º MessageFormat

java.lang.Object 
  |
  +--java.text.Format 
        |
        +--java.text.MessageFormat
¸ðµç ±¸Çö ÀÎÅÍÆäÀ̽º:
Cloneable , Serializable

public class MessageFormat
extends Format

MessageFormat ´Â ¿¬°áµÈ ¸Þ¼¼Áö¸¦, ¾ð¾î¿¡ ÀÇÁ¸ÇÏÁö ¾Ê´Â ¹æ¹ýÀ¸·Î ±¸ÃàÇϱâ À§ÇÑÀÇ °ÍÀÔ´Ï´Ù. ÃÖÁ¾ »ç¿ëÀÚ¿ëÀ¸·Î Ç¥½ÃÇÏ´Â ¸Þ¼¼Áö´Â ÀÌ ¹æ¹ýÀ¸·Î ±¸ÃàÇØ ÁÖ¼¼¿ä.

MessageFormat ´Â 1 Á¶ÀÇ ¿ÀºêÁ§Æ®¸¦ Æ÷¸Ë ÇØ, Æ÷¸Ë ÇÑ Ä³¸¯ÅÍ ¶óÀÎÀ» ÆÐÅÏÀÇ ÀûÀýÇÑ Àå¼Ò¿¡ »ðÀÔÇÕ´Ï´Ù.

ÁÖ: MessageFormat °¡ ´Ù¸¥ Format Ŭ·¡½º¿Í ´Ù¸¥ Á¡Àº MessageFormat ¿ÀºêÁ§Æ®¸¦ (getInstance ½ºÅ¸ÀÏÀÇ ÆÑÅ丮 ¸Þ¼Òµå´Â ¾Æ´Ï°í) ±× constructor ÀÇ 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" ´Â ¹«È¿ÀÔ´Ï´Ù.

°æ°í:
¸Þ¼¼Áö Æ÷¸Ë ÆÐÅϳ»¿¡¼­ÀÇ ÀοëºÎÈ£ÀÇ »ç¿ë ±ÔÄ¢Àº º°·Î ¸íÄèÇÏÁö´Â ¾Ê½À´Ï´Ù. ƯÈ÷, ´ÜÀÏ ÀοëºÎÈ£¸¦ ½Ö²¨Ç® ¼ö¼úÀ» ÇÒ ÇÊ¿äÀÇ À¯¹«°¡ ·ÎÄöóÀÌÀú¿¡ À־´Â ºÐ¸íÇÏÁö ¾ÊÀº °Íµµ ÀÖ½À´Ï´Ù. ·ÎÄöóÀÌÀú¿¡ ±ÔÄ¢¿¡ ´ëÇØ Á¤º¸¸¦ Á¦°øÇØ, ¸®¼Ò½º¿¡ ¹øµé µÇ´Â ¿ø½Ã ÆÄÀϳ»ÀÇ ÄÚ¸àÆ®µî¿¡ ÀÇÇØ, ¾î´À ij¸¯ÅÍ ¶óÀÎÀÌ MessageFormat ·Î 󸮵ǴÂÁö¸¦ ³ªÅ¸³»µµ·Ï ÇØ ÁÖ¼¼¿ä. ·ÎÄöóÀÌÀú´Â º¯È¯ÇÑ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î ¿À¸®Áö³¯ÀÇ ¹öÁ¯¿¡´Â ¾ø´Â ´ÜÀÏ ÀοëºÎÈ£¸¦ »ç¿ëÇØ¾ß ÇÏ´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù.

ArgumentIndex Ä¡´Â ¼ýÀÚ 0 ~ 9 ¸¦ »ç¿ëÇØ ±â¼úÇÑ 0 ÀÌ»óÀÇ Á¤¼öÀÔ´Ï´Ù. format ¸Þ¼Òµå¿¡°Ô °Ç³×Áø arguments ¹è¿­ ¶Ç´Â parse ¸Þ¼Òµå¿¡ ÀÇÇØ µ¹·ÁÁÖ¾îÁø °á°úÀÇ ¹è¿­ÀÇ À妽º¸¦ ³ªÅ¸³À´Ï´Ù.

FormatType ¹× FormatStyle Ä¡´Â Æ÷¸Ë ¿ä¼ÒÀÇ Format ÀνºÅϽºÀÇ »ý¼º¿¡ »ç¿ëÇÕ´Ï´Ù. ´ÙÀ½ÀÇ °Ñ(Ç¥)¿¡, Format ÀνºÅϽº¿¡ÀÇ °ªÀÇ MAP¿¡ ´ëÇØ °¡¸®Åµ´Ï´Ù. °Ñ(Ç¥)¿¡ ¾ø´Â Æí¼ºÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. 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())
time (¾øÀ½) DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale())
short DateFormat.getTimeInstance(DateFormat.SHORT, getLocale())
medium DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale())
long DateFormat.getTimeInstance(DateFormat.LONG, getLocale())
full DateFormat.getTimeInstance(DateFormat.FULL, getLocale())
SubformatPattern new SimpleDateFormat(subformatPattern, getLocale())
choice SubformatPattern new ChoiceFormat(subformatPattern)

»ç¿ë¿¹

ÀÌ »ç¿ë¿¹¸¦ ´ÙÀ½¿¡ ³ªÅ¸³À´Ï´Ù.

 Object[] arguments = {
     new Integer(7),
     new Date(System.currentTimeMillis()),
     "a disturbance in the Force"
 };

 String result = MessageFormat.format(
     "At {1, time} on {1, date}, there was {2} on planet {0, number, integer}. ",
     arguments);

 output: At 12:30 PM on Jul 3, 2053, there was a disturbance
           in the Force on planet 7.

 
ÀϹÝÀûÀ¸·Î, ¸Þ¼¼Áö Æ÷¸ËÀº ¸®¼Ò½º·ÎºÎÅÍ ÁÖ¾îÁ® Àμö´Â ½ÇÇà½Ã¿¡ µ¿ÀûÀ¸·Î ¼³Á¤µË´Ï´Ù.

·Ê 2:

 Object[] testArgs = {new Long(3), "MyDisk"};

 MessageFormat form = new MessageFormat(
     "The disk \"{1}\" contains {0} file(s). ");

 System.out.println(form.format(testArgs));

 // output, with different testArgs
 output: The disk "MyDisk" contains 0 file(s).
 output: The disk "MyDisk" contains 1 file(s).
 output: 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);

 Object[] testArgs = {new Long(12373), "MyDisk"};

 System.out.println(form.format(testArgs));

 // output, with different testArgs
 output: The disk "MyDisk" contains no files.
 output: The disk "MyDisk" contains one file.
 output: The disk "MyDisk" contains 1,273 files.
 
À̰ÍÀº À§ÀÇ ¿¹ÀÇ °°°Ô ÇÁ·Î±×·¥ÀûÀ¸·Î ½Ç½ÃÇÏ´ÂÁö ´ÙÀ½°ú °°ÀÌ ÆÐÅÏ (ÀÚ¼¼ÇÑ °ÍÀº 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 , Á÷·ÄÈ­ µÈ Çü½Ä

ÁßøµÈ Ŭ·¡½ºÀÇ °³¿ä
static class MessageFormat.Field
          MessageFormat.formatToCharacterIterator ·ÎºÎÅÍ µ¹·ÁÁÖ¾îÁø AttributedCharacterIterator ³»ÀÇ ¼Ó¼º Ű·Î¼­ »ç¿ëÇÏ´Â Á¤¼ö¸¦ Á¤ÀÇÇÕ´Ï´Ù.
 
Ŭ·¡½º java.text. Format À» »ó¼Ó¹ÞÀº ÁßøµÈ Ŭ·¡½º
 
»ý¼ºÀÚÀÇ °³¿ä
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)
          Ä³¸¯ÅÍ ¶óÀÎÀ» ÇØ¼®ÇÕ´Ï´Ù.
 Object parseObject (String  source, ParsePosition  pos)
          Ä³¸¯ÅÍ ¶óÀÎÀ¸·ÎºÎÅÍ ÅØ½ºÆ®¸¦ ÇØ¼®ÇØ ¿ÀºêÁ§Æ® ¹è¿­À» »ý¼ºÇÕ´Ï´Ù.
 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
 

»ý¼ºÀÚÀÇ »ó¼¼

MessageFormat

public MessageFormat(String  pattern)
µðÆúÆ® ·ÎÄÉÀϰú ÁöÁ¤µÈ ÆÐÅÏÀ» À§ÇÑ MessageFormat ¸¦ ±¸ÃàÇÕ´Ï´Ù. constructor Àº ·ÎÄÉÀÏÀ» ¼³Á¤ÇÏ°í ³ª¼­ ÆÐÅÏÀ» ÇØ¼®ÇØ, Æ÷ÇԵǾî ÀÖ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ´ëÇØ ¼­ºê Æ÷¸ËÀÇ ¸®½ºÆ®¸¦ ÀÛ¼ºÇÕ´Ï´Ù. ÆÐÅϰú ±× ÇØ¼®ÀºÅ¬·¡½ºÀÇ °³¿ä·Î ÁöÁ¤µÇ°í ÀÖ½À´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
pattern - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ÆÐÅÏ
¿¹¿Ü:
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÎ °æ¿ì

MessageFormat

public MessageFormat(String  pattern,
                     Locale  locale)
ÁöÁ¤µÈ ·ÎÄÉÀϰú ÆÐÅÏÀ» À§ÇÑ MessageFormat ¸¦ ±¸ÃàÇÕ´Ï´Ù. constructor Àº ·ÎÄÉÀÏÀ» ¼³Á¤ÇÏ°í ³ª¼­ ÆÐÅÏÀ» ÇØ¼®ÇØ, Æ÷ÇԵǾî ÀÖ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ´ëÇØ ¼­ºê Æ÷¸ËÀÇ ¸®½ºÆ®¸¦ ÀÛ¼ºÇÕ´Ï´Ù. ÆÐÅϰú ±× ÇØ¼®ÀºÅ¬·¡½ºÀÇ °³¿ä·Î ÁöÁ¤µÇ°í ÀÖ½À´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
pattern - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ÆÐÅÏ
locale - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ·ÎÄÉÀÏ
¿¹¿Ü:
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÎ °æ¿ì
µµÀÔµÈ ¹öÁ¯:
1.4
¸Þ¼ÒµåÀÇ »ó¼¼

setLocale

public void setLocale(Locale  locale)
¼­ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÏ´Â ·ÎÄÉÀÏÀ» ¼³Á¤ÇÕ´Ï´Ù. À̰ÍÀº ÈÄ¿¡ ÇàÇØÁö´Â applyPattern ¹× toPattern ¸Þ¼Òµå¿Í format ¹× formatToCharacterIterator ¸Þ¼Òµå¿¡ÀÇ È£Ãâ¿¡ ¿µÇâÀ» ÁÝ´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
locale - ¼­ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÏ´Â ·ÎÄÉÀÏ

getLocale

public Locale  getLocale()
¼­ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëµÇ´Â ·ÎÄÉÀÏÀ» ÃëµæÇÕ´Ï´Ù.

¹Ýȯ°ª:
¼­ºê Æ÷¸ËÀ» ÀÛ¼º ¶Ç´Â ºñ±³ÇÏ´Â °æ¿ì¿¡ »ç¿ëµÇ´Â ·ÎÄÉÀÏ

applyPattern

public void applyPattern(String  pattern)
ÀÌ ¸Þ¼¼Áö Æ÷¸Ë¿¡ ÀÇÇØ »ç¿ëµÇ´Â ÆÐÅÏÀ» ¼³Á¤ÇÕ´Ï´Ù. ¸Þ¼Òµå´Â ÆÐÅÏÀ» ÇØ¼®ÇØ, Æ÷ÇԵǾî ÀÖ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ´ëÇØ ¼­ºê Æ÷¸ËÀÇ ¸®½ºÆ®¸¦ ÀÛ¼ºÇÕ´Ï´Ù. ÆÐÅϰú ±× ÇØ¼®ÀºÅ¬·¡½ºÀÇ °³¿ä·Î ÁöÁ¤µÇ°í ÀÖ½À´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
pattern - ÀÌ ¸Þ¼¼Áö Æ÷¸ËÀ» À§ÇÑ ÆÐÅÏ
¿¹¿Ü:
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÎ °æ¿ì

toPattern

public String  toPattern()
¸Þ¼¼Áö Æ÷¸ËÀÇ ÇöÀç »óŸ¦ ³ªÅ¸³»´Â ÆÐÅÏÀ» µ¹·ÁÁÝ´Ï´Ù. ij¸¯ÅÍ ¶óÀÎÀº ³»ºÎ Á¤º¸·ÎºÎÅÍ ±¸ÃàµÇ¹Ç·Î, ÀÌÀü¿¡ Àû¿ëµÈ ÆÐÅϰú µ¿ÀÏÇØÁø´Ù°í´Â ÇÒ ¼ö ¾ø½À´Ï´Ù.

¹Ýȯ°ª:
¸Þ¼¼Áö Æ÷¸ËÀÇ ÇöÀç »óŸ¦ ³ªÅ¸³»´Â ÆÐÅÏ

setFormatsByArgumentIndex

public void setFormatsByArgumentIndex(Format [] newFormats)
format ¸Þ¼Òµå¿¡°Ô °Ç³×Áö´Â °ª ¶Ç´Â parse ¸Þ¼Òµå·ÎºÎÅÍ µ¹·ÁÁÖ¾îÁø °ª¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. newFormats ³»ÀÇ ¿ä¼ÒÀÇ À妽º´Â ¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î »ç¿ëµÇ´Â Àμö À妽º¿¡ ´ëÀÀÇÕ´Ï´Ù. µû¶ó¼­,newFormats ³»ÀÇ Æ÷¸ËÀÇ ¼ø¼­´Â format ¸Þ¼Òµå¿¡°Ô °Ç³×Áø arguments ¹è¿­ ¶Ç´Â parse ¸Þ¼Òµå¿¡ ÀÇÇØ µ¹·ÁÁÖ¾îÁø °á°úÀÇ ¹è¿­³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼­¿¡ ´ëÀÀÇÕ´Ï´Ù.

Àμö À妽º°¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»¿¡¼­ º¹¼öÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â °æ¿ì, ´ëÀÀÇÏ´Â »õ·Î¿î Æ÷¸ËÀÌ ±× ¸ðµç Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµË´Ï´Ù. Àμö À妽º°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼­ ¾î´À Æ÷¸Ë ¿ä¼Ò¿¡µµ »ç¿ëµÇÁö ¾Ê´Â °æ¿ì´Â ´ëÀÀÇÏ´Â »õ·Î¿î Æ÷¸ËÀº ¹«½ÃµË´Ï´Ù. Á¦°øµÈ Æ÷¸ËÀÌ ÇÊ¿ä¼ö¿¡ ¸ø ¹ÌÄ£ °æ¿ì,newFormats.length º¸´Ù ÀûÀº Àμö À妽º¿¡ ´ëÇÑ Æ÷¸Ë¸¸ÀÌ ¿Å°Ü³õÀ» ¼ö ÀÖ½À´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
newFormats - »ç¿ëÇÏ´Â »õ·Î¿î Æ÷¸Ë
¿¹¿Ü:
NullPointerException - newFormats °¡ null ÀÇ °æ¿ì
µµÀÔµÈ ¹öÁ¯:
1.4

setFormats

public void setFormats(Format [] newFormats)
¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. newFormats ³»ÀÇ Æ÷¸ËÀÇ ¼ø¼­´Â ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼­¿¡ ´ëÀÀÇÕ´Ï´Ù.

ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î ÇÊ¿ä·Î ÇÏ´Â °Íº¸´Ùµµ ¸¹Àº Æ÷¸ËÀÌ Á¦°øµÇ¾úÀ» °æ¿ì, ³²Àº Æ÷¸ËÀº ¹«½ÃµË´Ï´Ù. ÇÊ¿ä¼ö¿¡ ¸ø ¹ÌÄ£ °æ¿ì´Â ÃÖÃÊÀÇ newFormats.length ¸¸ÀÌ ¿Å°Ü³õÀ» ¼ö ÀÖ½À´Ï´Ù.

ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼­´Â Áö¿ª ´ëÀÀÈ­ÀÇ Ã³¸® °úÁ¤¿¡¼­ º¯°æµÇ´Â °ÍÀÌ ¸¹±â ¶§¹®¿¡, Åë»óÀº setFormatsByArgumentIndex ¸Þ¼Òµå¸¦ »ç¿ëÇÏ´Â (ºÐ)ÆíÀÌ È¿À²ÀûÀÔ´Ï´Ù. ÀÌ ¸Þ¼Òµå´Â Æ÷¸ËÀÇ ¼ø¼­¸¦ format ¸Þ¼Òµå¿¡°Ô °Ç³×Áø arguments ¹è¿­ ¶Ç´Â parse ¸Þ¼Òµå¿¡ ÀÇÇØ µ¹·ÁÁÖ¾îÁø °á°úÀÇ ¹è¿­³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼­¿¡ ´ëÀÀÇÏ´Â °ÍÀ̶ó°í º¾´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
newFormats - »ç¿ëÇÏ´Â »õ·Î¿î Æ÷¸Ë
¿¹¿Ü:
NullPointerException - newFormats °¡ null ÀÇ °æ¿ì

setFormatByArgumentIndex

public void setFormatByArgumentIndex(int argumentIndex,
                                     Format  newFormat)
ÁöÁ¤µÈ Àμö À妽º¸¦ »ç¿ëÇÑ´Ù, ¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. Àμö À妽º´Â Æ÷¸Ë ¿ä¼Ò Á¤ÀÇÀÇ ºÎºÐ¿¡¼­,format ¸Þ¼Òµå¿¡°Ô °Ç³×Áø arguments ¹è¿­ ¶Ç´Â parse ¸Þ¼Òµå¿¡ ÀÇÇØ µ¹·ÁÁÖ¾îÁø °á°úÀÇ ¹è¿­ÀÇ À妽º¸¦ ³ªÅ¸³À´Ï´Ù.

Àμö À妽º°¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»¿¡¼­ º¹¼öÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â °æ¿ì, »õ·Î¿î Æ÷¸ËÀÌ ±× ¸ðµç Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµË´Ï´Ù. Àμö À妽º°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼­ ¾î´À Æ÷¸Ë ¿ä¼Ò¿¡µµ »ç¿ëµÇÁö ¾Ê´Â °æ¿ì´Â »õ·Î¿î Æ÷¸ËÀº ¹«½ÃµË´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
argumentIndex - »õ·Î¿î Æ÷¸Ë¿¡ »ç¿ëÇϱâ À§ÇÑ Àμö À妽º
newFormat - »ç¿ëÇÏ´Â »õ·Î¿î Æ÷¸Ë
µµÀÔµÈ ¹öÁ¯:
1.4

setFormat

public void setFormat(int formatElementIndex,
                      Format  newFormat)
¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ ÁöÁ¤µÈ Æ÷¸Ë ¿ä¼Ò À妽º·Î, Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸ËÀ» ¼³Á¤ÇÕ´Ï´Ù. Æ÷¸Ë ¿ä¼Ò À妽º´Â ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀÇ ¼±µÎ·ÎºÎÅÍ Ä«¿îÆ® ÇÑ, Æ÷¸Ë ¿ä¼ÒÀÇ Á¦·Î·ÎºÎÅÍ ½ÃÀ۵Ǵ ¼ýÀÚÀÔ´Ï´Ù.

ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼­´Â Áö¿ª ´ëÀÀÈ­ÀÇ Ã³¸® °úÁ¤¿¡¼­ º¯°æµÇ´Â °ÍÀÌ ¸¹±â ¶§¹®¿¡, Åë»óÀº setFormatByArgumentIndex ¸Þ¼Òµå¸¦ »ç¿ëÇÏ´Â (ºÐ)ÆíÀÌ È¿À²ÀûÀÔ´Ï´Ù. ÀÌ ¸Þ¼Òµå´Â Æ÷¸Ë ¿ä¼Ò°¡ ÁöÁ¤ÇÏ´Â Àμö À妽º¸¦ ±âº»À¸·Î, Æ÷¸Ë ¿ä¼Ò¿¡ ¾×¼¼½º ÇÕ´Ï´Ù.

ÆÄ¶ó¹ÌÅÍ:
formatElementIndex - ÆÐÅϳ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ À妽º
newFormat - ÁöÁ¤µÈ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëÇÏ´Â Æ÷¸Ë
¿¹¿Ü:
ArrayIndexOutOfBoundsException - formatElementIndex °¡, ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼öÀÌ»óÀÇ °æ¿ì

getFormatsByArgumentIndex

public Format [] getFormatsByArgumentIndex()
format ¸Þ¼Òµå¿¡°Ô °Ç³×Áö´Â °ª ¶Ç´Â parse ¸Þ¼Òµå·ÎºÎÅÍ µ¹·ÁÁÖ¾îÁø °ª¿¡ »ç¿ëµÇ´Â Æ÷¸ËÀ» ÃëµæÇÕ´Ï´Ù. µ¹·ÁÁÖ¾îÁø ¹è¿­³»ÀÇ ¿ä¼ÒÀÇ À妽º´Â ¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀÎÀ¸·Î »ç¿ëµÇ´Â Àμö À妽º¿¡ ´ëÀÀÇÕ´Ï´Ù. µû¶ó¼­, µ¹·ÁÁÖ¾îÁø ¹è¿­³»ÀÇ Æ÷¸ËÀÇ ¼ø¼­´Â format ¸Þ¼Òµå¿¡°Ô °Ç³×Áø arguments ¹è¿­ ¶Ç´Â parse ¸Þ¼Òµå¿¡ ÀÇÇØ µ¹·ÁÁÖ¾îÁø °á°úÀÇ ¹è¿­³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼­¿¡ ´ëÀÀÇÕ´Ï´Ù.

Àμö À妽º°¡ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»¿¡¼­ º¹¼öÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â °æ¿ì, ±× ¸¶Áö¸· Æ÷¸Ë ¿ä¼Ò·Î »ç¿ëµÇ´Â Æ÷¸ËÀÌ ¹è¿­¿¡ µ¹·ÁÁÖ¾îÁý´Ï´Ù. Àμö À妽º°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼­ ¾î´À Æ÷¸Ë ¿ä¼Ò¿¡µµ »ç¿ëµÇÁö ¾Ê´Â °æ¿ì´Â null °¡ ¹è¿­¿¡ µ¹·ÁÁÖ¾îÁý´Ï´Ù.

¹Ýȯ°ª:
ÆÐÅϳ»ÀÇ Àμö¿¡ »ç¿ëµÇ´Â Æ÷¸Ë
µµÀÔµÈ ¹öÁ¯:
1.4

getFormats

public Format [] getFormats()
¹Ì¸® ¼³Á¤µÈ ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â Æ÷¸ËÀ» ÃëµæÇÕ´Ï´Ù. µ¹·ÁÁÖ¾îÁö´Â ¹è¿­³»ÀÇ Æ÷¸ËÀÇ ¼ø¼­´Â ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼­¿¡ ´ëÀÀÇÕ´Ï´Ù.

ÆÐÅÏ Ä³¸¯ÅÍ ¶óÀγ»ÀÇ Æ÷¸Ë ¿ä¼ÒÀÇ ¼ø¼­´Â Áö¿ª ´ëÀÀÈ­ÀÇ Ã³¸® °úÁ¤¿¡¼­ º¯°æµÇ´Â °ÍÀÌ ¸¹±â ¶§¹®¿¡, Åë»óÀº getFormatsByArgumentIndex ¸Þ¼Òµå¸¦ »ç¿ëÇÏ´Â (ºÐ)ÆíÀÌ È¿À²ÀûÀÔ´Ï´Ù. ÀÌ ¸Þ¼Òµå´Â Æ÷¸ËÀÇ ¼ø¼­¸¦ format ¸Þ¼Òµå¿¡°Ô °Ç³×Áø arguments ¹è¿­ ¶Ç´Â parse ¸Þ¼Òµå¿¡ ÀÇÇØ µ¹·ÁÁÖ¾îÁø °á°úÀÇ ¹è¿­³»ÀÇ ¿ä¼ÒÀÇ ¼ø¼­¿¡ ´ëÀÀÇÏ´Â °ÍÀ̶ó°í º¾´Ï´Ù.

¹Ýȯ°ª:
ÆÐÅϳ»ÀÇ Æ÷¸Ë ¿ä¼Ò¿¡ »ç¿ëµÇ´Â Æ÷¸Ë

format

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 ?
(new MessageFormat(subformat.format(argument), getLocale())). format(argument) : subformat.format(argument)
! = 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 ¹è¿­³»ÀÇ Àμö°¡, ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ŸÀÔÀÌ ¾Æ´Ñ °æ¿ì

format

public static String  format(String  pattern,
                            Object [] arguments)
ÁöÁ¤µÈ ÆÐÅÏÀ» »ç¿ëÇØ MessageFormat ¸¦ ÀÛ¼ºÇØ, ±×°ÍÀ» »ç¿ëÇØ ÁöÁ¤µÈ Àμö¸¦ Æ÷¸Ë ÇÕ´Ï´Ù. À̰ÍÀº ÀÌÇÏÀÇ ±â¼ú°ú µ¿µîÇÕ´Ï´Ù.
(new MessageFormat (pattern)). format (arguments, new StringBuffer(), null). toString()

¿¹¿Ü:
IllegalArgumentException - ÆÐÅÏÀÌ ¹«È¿ÀÇ °æ¿ì, ¶Ç´Â arguments ¹è¿­³»ÀÇ Àμö°¡, ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ŸÀÔÀÌ ¾Æ´Ñ °æ¿ì

format

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 ¹è¿­³»ÀÇ Àμö°¡, ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ŸÀÔÀÌ ¾Æ´Ñ °æ¿ì

formatToCharacterIterator

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 ³»ÀÇ ÀμöÀÇ À§Ä¡¸¦ ¾Ë ¼ö ÀÖÀ» »Ó¸¸ ¾Æ´Ï¶ó, ±× Àμö°¡ ¾î´À Çʵ忡 Æ÷ÇԵǾî ÀÖÀ»Áöµµ ¾Ð´Ï´Ù.

¿À¹ö¶óÀ̵å(override):
Ŭ·¡½º Format ³»ÀÇ formatToCharacterIterator
ÆÄ¶ó¹ÌÅÍ:
arguments - Æ÷¸Ë Çϵ簡 ¶Ç´Â ¿Å°Ü³õ´Â ¿ÀºêÁ§Æ®·ÎºÎÅÍ µÇ´Â ¹è¿­
¹Ýȯ°ª:
Æ÷¸Ë µÈ °ªÀ» ±â¼úÇÏ´Â AttributedCharacterIterator
¿¹¿Ü:
NullPointerException - arguments °¡ null ÀÇ °æ¿ì
IllegalArgumentException - arguments ¹è¿­³»ÀÇ Àμö°¡, ±×°ÍÀ» »ç¿ëÇÏ´Â Æ÷¸Ë ¿ä¼Ò¿¡ ÀÇÇØ ¿¹ÃøµÈ ŸÀÔÀÌ ¾Æ´Ñ °æ¿ì
µµÀÔµÈ ¹öÁ¯:
1.4

parse

public Object [] parse(String  source,
                      ParsePosition  pos)
ij¸¯ÅÍ ¶óÀÎÀ» ÇØ¼®ÇÕ´Ï´Ù.

ÁÖÀÇ: ÇØ¼®Àº ´Ù¾çÇÑ ¿øÀÎÀ» À§Çؼ­(¶§¹®¿¡), Àß µ¿ÀÛÇÏÁö ¾Ê´Â °ÍÀÌ ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, ´ÙÀ½°ú °°Àº °æ¿ìÀÔ´Ï´Ù.

  • ÀμöÀÇ 1 °³°¡ ÆÐÅÏ¿¡ ¾ø´Ù
  • Å« ¼ýÀÚ°¡ "many" ¿¡ Æ÷¸Ë µÇ´Â °Í °°Àº choice Æ÷¸ËµîÀ¸·Î, ÀμöÀÇ Æ÷¸ËÀÌ Á¤º¸¸¦ ÀҴ´Ù
  • ¹Ýº¹À» ¾ÆÁ÷ ó¸®ÇÏÁö ¾Ê´Â´Ù (¿Å°Ü³õ´Â ij¸¯ÅÍ ¶óÀο¡ {n} °³ÀÇ ÂüÁ¶°¡ ÀÖ´Â °æ¿ì)
  • ÇØ¼®ÀÇ ÀϺΰ¡ ¾Ö¸ÅÇÑ ¶§, ÀÏÄ¡ (¶Ç´Â ¿Ã¹Ù¸¥ ÀÏÄ¡)°¡ ¹Ýµå½Ã ¹ß°ßµÇÁö ¾Ê´Â´Ù. ¿¹¸¦ µé¾î, ÆÐÅÏ "{1},{2}" ¸¦ ij¸¯ÅÍ ¶óÀÎ Àμö {"a, b", "c"} ·Î »ç¿ëÇÏ´Â °æ¿ì´Â "a, b, c" ¿Í Æ÷¸Ë µÈ´Ù. ±× °á°ú°¡ ÇØ¼®µÇ¸é(ÀÚ),{"a", "b, c"} °¡ µ¹·ÁÁÖ¾îÁø´Ù
  • 1 °³ÀÇ Àμö°¡ ij¸¯ÅÍ ¶óÀγ»¿¡¼­ ¿©·¯ Â÷·Ê ÇØ¼®µÇ¸é(ÀÚ), ³ª¸ÓÁöÀÇ ÇØ¼®ÀÌ ¿ìÀ§°¡ µÈ´Ù
ÇØ¼®ÀÌ ½ÇÆÐÇßÀ» ¶§´Â ParsePosition.getErrorIndex()¸¦ »ç¿ëÇØ, ij¸¯ÅÍ ¶óÀÎÀÇ ¾îµð¼­ ÇØ¼®ÀÌ ½ÇÆÐÇß´ÂÁö¸¦ Á¶»çÇÕ´Ï´Ù. µ¹·ÁÁÖ¾îÁö´Â ¿¡·¯ À妽º´Â ij¸¯ÅÍ ¶óÀÎÀÇ ºñ±³ ´ë»óÀÎ ¼­ºê ÆÐÅÏÀÇ °³½Ã ¿ÀÇÁ¼Â(offset)ÀÔ´Ï´Ù. ¿¹¸¦ µé¾î, ÇØ¼® ij¸¯ÅÍ ¶óÀÎ "AAA {0} BBB" °¡ ÆÐÅÏ "AAD {0} BBB" ¶ó°í ºñ±³µÇ°í ÀÖ´Â °æ¿ì, ¿¡·¯ À妽º´Â 0 ÀÔ´Ï´Ù. ¿¡·¯°¡ ¹ß»ýÇϸé(ÀÚ), ÀÌ ¸Þ¼Òµå¿¡ÀÇ È£ÃâÀÌ null ¸¦ µ¹·ÁÁÝ´Ï´Ù. ¼Ò½º°¡ null ÀÇ °æ¿ì, ÇÏ´ÃÀÇ ¹è¿­À» µ¹·ÁÁÝ´Ï´Ù.


parse

public Object [] parse(String  source)
               throws ParseException 
ÁöÁ¤µÈ ij¸¯ÅÍ ¶óÀÎÀÇ ¼±µÎ·ÎºÎÅÍ ÅØ½ºÆ®¸¦ ÇØ¼®ÇØ ¿ÀºêÁ§Æ® ¹è¿­À» »ý¼ºÇÕ´Ï´Ù. ¸Þ¼Òµå´Â ÁöÁ¤µÈ ij¸¯ÅÍ ¶óÀÎÀÇ ÅØ½ºÆ® Àüü¸¦ »ç¿ëÇÏÁö ¾Ê´Â °æ¿ìµµ ÀÖ½À´Ï´Ù.

¸Þ¼¼ÁöÀÇ ÇØ¼®¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ °ÍÀº parse(String, ParsePosition) ¸¦ ÂüÁ¶ÇØ ÁÖ¼¼¿ä.

ÆÄ¶ó¹ÌÅÍ:
source - ¼±µÎ°¡ ÇØ¼®µÇ´Â String
¹Ýȯ°ª:
ij¸¯ÅÍ ¶óÀÎÀ¸·ÎºÎÅÍ ÇØ¼®µÇ´Â Object ¹è¿­
¿¹¿Ü:
ParseException - ÁöÁ¤µÈ ij¸¯ÅÍ ¶óÀÎÀÇ ¼±µÎ¸¦ ÇØ¼®ÇÒ ¼ö ¾ø´Â °æ¿ì

parseObject

public Object  parseObject(String  source,
                          ParsePosition  pos)
ij¸¯ÅÍ ¶óÀÎÀ¸·ÎºÎÅÍ ÅØ½ºÆ®¸¦ ÇØ¼®ÇØ ¿ÀºêÁ§Æ® ¹è¿­À» »ý¼ºÇÕ´Ï´Ù.

¸Þ¼Òµå´Â pos ¿¡ ÀÇÇØ ÁöÁ¤µÈ À妽º¸¦ °³½Ã À§Ä¡·Î¼­ ÅØ½ºÆ®ÀÇ ÇØ¼®À» ½ÃµµÇÕ´Ï´Ù. ÇØ¼®ÀÌ ¿Ï·áÇϸé(ÀÚ),pos ÀÇ À妽º´Â »ç¿ëµÈ ¸¶Áö¸· ij¸¯ÅÍ (ÇØ¼®¿¡¼­´Â ij¸¯ÅÍ ¶óÀÎÀÇ ³¡±îÁöÀÇ ¸ðµç ij¸¯ÅͰ¡ »ç¿ëµÈ´Ù°í´Â ÇÒ ¼ö ¾ø´Ù)ÀÇ µÚÀÇ À妽º¿¡ °»½ÅµÇ¾î ÇØ¼®µÈ ¿ÀºêÁ§Æ® ¹è¿­ÀÌ µ¹·ÁÁÖ¾îÁý´Ï´Ù. °»½ÅµÈ pos ´Â ÀÌ ¸Þ¼ÒµåÀÇ ´ÙÀ½ÀÇ È£ÃâÀÇ °³½ÃÁ¡À» ³ªÅ¸³»±â À§Çؼ­(¶§¹®¿¡) »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¡·¯°¡ ¹ß»ýÇßÀ» °æ¿ì´Â pos ÀÇ À妽º´Â º¯°æµÇÁö ¾Ê°í ¿¡·¯°¡ ¹ß»ýÇÑ Ä³¸¯ÅÍÀÇ À妽º¿¡ pos ÀÇ ¿¡·¯ À妽º°¡ ¼³Á¤µÇ¾î null °¡ µ¹·ÁÁÖ¾îÁý´Ï´Ù.

¸Þ¼¼ÁöÀÇ ÇØ¼®¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ °ÍÀº parse(String, ParsePosition) ¸¦ ÂüÁ¶ÇØ ÁÖ¼¼¿ä.

Á¤ÀÇ:
Ŭ·¡½º Format ³»ÀÇ parseObject
ÆÄ¶ó¹ÌÅÍ:
source - ºÎºÐÀûÀ¸·Î ÇØ¼®µÇ´Â String
pos - »ó±âÀÇ À妽º ¹× ¿¡·¯ À妽º Á¤º¸¸¦ °¡Áö´Â ParsePosition ¿ÀºêÁ§Æ®
¹Ýȯ°ª:
ij¸¯ÅÍ ¶óÀÎÀ¸·ÎºÎÅÍ ÇØ¼®µÈ Object ¹è¿­. ¿¡·¯ÀÇ °æ¿ì´Â null ¸¦ µ¹·ÁÁØ´Ù
¿¹¿Ü:
NullPointerException - pos °¡ null ÀÇ °æ¿ì

clone

public Object  clone()
ÀÌ ¿ÀºêÁ§Æ®ÀÇ Ä«ÇǸ¦ ÀÛ¼ºÇØ, µ¹·ÁÁÝ´Ï´Ù.

¿À¹ö¶óÀ̵å(override):
Ŭ·¡½º Format ³»ÀÇ clone
¹Ýȯ°ª:
ÀÌ ÀνºÅϽºÀÇ º¹Á¦

equals

public boolean equals(Object  obj)
2 °³ÀÇ ¸Þ¼¼Áö Æ÷¸Ë ¿ÀºêÁ§Æ®ÀÇ »çÀÌÀÇ µîÈ£ ºñ±³ÀÔ´Ï´Ù.

¿À¹ö¶óÀ̵å(override):
Ŭ·¡½º Object ³»ÀÇ equals
ÆÄ¶ó¹ÌÅÍ:
obj - ºñ±³ ´ë»óÀÇ ÂüÁ¶ ¿ÀºêÁ§Æ®
¹Ýȯ°ª:
obj Àμö·Î ÁöÁ¤µÈ ¿ÀºêÁ§Æ®¿Í ÀÌ ¿ÀºêÁ§Æ®°¡ µ¿ÀÏÇÑ °æ¿ì´Â true, ±×·¸Áö ¾ÊÀº °æ¿ì´Â false
°ü·Ã Ç׸ñ:
Object.hashCode() , Hashtable

hashCode

public int hashCode()
¸Þ¼¼Áö Æ÷¸Ë ¿ÀºêÁ§Æ®ÀÇ ÇØ½Ã Äڵ带 »ý¼ºÇÕ´Ï´Ù.

¿À¹ö¶óÀ̵å(override):
Ŭ·¡½º Object ³»ÀÇ hashCode
¹Ýȯ°ª:
ÀÌ ¿ÀºêÁ§Æ®ÀÇ ÇØ½Ã ÄÚµåÄ¡
°ü·Ã Ç׸ñ:
Object.equals(java.lang.Object) , Hashtable

JavaTM 2
Platform
Std.  Ed.  v1. 4.0

¹ö±×ÀÇ º¸°í¿Í ±â´ÉÀÇ ¸®Äù½ºÆ®
ÀÌ¿ÜÀÇ API ·¹ÆÛ·±½º ¹× °³¹ßÀÚ¿ë ¹®¼­¿¡ ´ëÇØ¼­´Â Java 2 SDK SE °³¹ßÀÚ¿ë ¹®¼­¸¦ ÂüÁ¶ÇØ ÁÖ¼¼¿ä. °³¹ßÀÚÀü¿ëÀÇ »ó¼¼ÇÑ ÇØ¼³, °³³äÀÇ °³¿ä, ¿ë¾îÀÇ Á¤ÀÇ, ¹ö±×ÀÇ È¸ÇÇÃ¥, ¹× ÄÚµå ½Ç·Ê°¡ Æ÷ÇԵǾî ÀÖ½À´Ï´Ù.

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.