|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
°³¿ä: NESTED | Çʵå | constructor | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå |
java.lang.Objectjava.text.Collator
java.text.RuleBasedCollator
public class RuleBasedCollator
RuleBasedCollator
Ŭ·¡½º´Â Collator
±¸»ó ¼ºê Ŭ·¡½º¿¡¼
°£´ÜÇÑ Á¶ÀÛÀ¸·Î µ¥ÀÌÅ͵帮ºìÀÇ Å×À̺í Collator¸¦ »ç¿ë °¡´ÉÇÏ°Ô ÇÕ´Ï´Ù. ÀÌ Å¬·¡½º¸¦ »ç¿ëÇϸé, Ä¿½ºÅ͸¶ÀÌÁî ÇÑ Å×ÀÌºí º£À̽ºÀÇ Collator
¸¦ ÀÛ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù
. RuleBasedCollator
´Â
¹®ÀÚ¸¦ ¼ÒÆ® Ű¿¡ ¸Ê ÇÕ´Ï´Ù.
È¿À²È¸¦ À§Çؼ
RuleBasedCollator
¿¡´Â ´ÙÀ½ÀÇ Á¦¾àÀÌ ÀÖ½À´Ï´Ù (¶ÇÇÑ
º¹ÀâÇÑ ¾ð¾î¿¡´Â ´Ù¸¥ ¼ºê Ŭ·¡½º°¡ »ç¿ëµÈ´Ù).
Á¶ÇÕ Å×À̺íÀº Á¶ÇÕ ·êÀÇ ¸®½ºÆ®·ÎºÎÅÍ µÇ¾î, °¢°¢ÀÇ ·êÀº ´ÙÀ½ÀÇ 3°³ÀÇ Çü½ÄÀÇ ¾î¶² °ÍÀÎÁö¸¦ ÃëÇÕ´Ï´Ù.
<modifier> <relation> <text-argument> <reset> <text-argument>·ê ¿ä¼ÒÀÇ Á¤ÀÇ´Â ´ÙÀ½°ú °°½À´Ï´Ù.
b c
´Â bc
·Î
¼ 󸮵˴ϴÙ.
'@' : ¿¢¼¾Æ®°¡ ÇÁ¶û½º¾î¿Í °°ÀÌ ¿ª¹æÇâÀ¸·Î ¼ÒÆ® µÇ´Â °ÍÀ» ³ªÅ¸³À´Ï´Ù.
'&' : ´ÙÀ½ÀÇ ·êÀÌ, ¸®¼Â ÅØ½ºÆ® Àμö°¡ ¼ÒÆ® µÇ´Â À§Ä¡¿¡ °è¼ÓµÇ´Â °ÍÀ» ³ªÅ¸³À´Ï´Ù.
À̰ÍÀº ½ÇÁ¦º¸´Ù º¹ÀâÇÏ°Ô ´À²¸Áý´Ï´Ù. ¿¹¸¦ µé¾î ´ÙÀ½ÀÇ ¿¹´Â °°Àº °ÍÀ» µ¿µîÀÇ ¹æ¹ýÀ¸·Î ³ªÅ¸³½ °ÍÀÔ´Ï´Ù.
ÅØ½ºÆ® ÀμöÀÇ ¹Ù·Î ÈÄ¿¡ ´ÙÀ½ÀÇ Ç׸ñÀÌ ¿À¹Ç·Î ¼ø¼°¡ Áß¿äÇÕ´Ï´Ù. ´ÙÀ½ÀÇ ¿¹´Â µ¿µîÇÏÁö´Â ¾Ê½À´Ï´Ù.a < b < c a < b & b < c a < c & a < b
¼ø¼¿¡´Â ÅØ½ºÆ® Àμö°¡ ÀÌ¹Ì Á¸ÀçÇÏ´ÂÁö, ±× ÅØ½ºÆ® ÀμöÀÇ ÃÖÃÊÀÇ ºÎºÐ ij¸¯ÅÍ ¶óÀÎÀÌ Á¸ÀçÇÏÁö ¾ÊÀ¸¸é ¾ÈµË´Ï´Ù (¿¹¸¦ µé¾î ¡¸a < b & ae < e¡¹´Â À¯È¿. ¼ø¼¿¡ ´ëÇØ ¡¸a¡¹´Â ¡¸ae¡¹°¡ ¸®¼Â µÇ±â Àü¿¡ Àֱ⠶§¹®¿¡). ÀÌ ÈÄÀÚÀÇ ÄÉÀ̽º·Î ¡¸ae¡¹´Â 1 ¹®Àڷμ ÀԷµÇÁö ¾Ê°í, ±×ó·³Àº ´Ù·ç¾îÁöÁö ¾Ê½À´Ï´Ù. ¡¸e¡¹´Â 2 ¹®ÀÚ ( ¡¸a¡¹¿¡ °è¼ÓµÇ´Â ¡¸e¡¹)¿¡ È®ÀåµÇ¾ú´ÂÁö¿Í °°ÀÌ ¼ÒÆ® µË´Ï´Ù. ÀÌ Â÷ÀÌ´Â ÀÚ¿¬ ¾ð¾î·Î º¸¿©Áý´Ï´Ù. Á¾·¡ÀÇ ½ºÆäÀξîÀÇ ¡¸ch¡¹´Â ´ÜÀÏ ¹®ÀÚ¿¡ ´ÜÃàµÇ¾ú´ÂÁö¿Í °°ÀÌ Ã³¸®µË´Ï´Ù ( ¡¸c < ch < d¡¹¶ó°í Ç¥ÇöµÈ´Ù). ÇÑÆí, Á¾·¡ÀÇ µ¶ÀϾîÀÇ a ¸ðÀ½ º¯ÀÌ´Â 2°³ÀÇ ¹®ÀÚ¿¡ È®ÀåµÇ¾ú´ÂÁö¿Í °°ÀÌ Ã³¸®µË´Ï´Ù ( ¡¸a, A < b, B ... &ae;\u00e3& AE;\u00c3¡¹¶ó°í Ç¥ÇöµÈ´Ù). \u00e3 ¹× \u00c3´Â a ¸ðÀ½ º¯ÀÌÀÇ escape sequenceÀÔ´Ï´Ù.a < b & a < c a < c & a < b
¹«½Ã °¡´ÉÇÑ ¹®ÀÚ
¹«½Ã °¡´ÉÇÑ ¹®ÀÚÀÇ °æ¿ì, ÃÖÃÊÀÇ ·êÀº °ü°è ¹®ÀÚ·Î ½ÃÀÛµÇÁö ¾ÊÀ¸¸é ¾ÈµË´Ï´Ù (À§ÀÇ ¿¹´Â ½ÇÁ¦·Î´Â ÀϺθ¦ ³ªÅ¸³»°í ÀÖ´Ù. Áï, ¡¸a < b¡¹´Â ½ÇÁ¦·Î´Â ¡¸< a < b¡¹¿©¾ß ÇÔ). ±×·¯³ª, ÃÖÃÊÀÇ °ü°è ¹®ÀÚ°¡ ¡¸<¡¹°¡ ¾Æ´Ï¸é, ÃÖÃÊÀÇ ¡¸<¡¹±îÁöÀÇ ¸ðµç ÅØ½ºÆ® Àμö´Â ¹«½ÃÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î ¡¸, - < a < b¡¹¿¡¼´Â ¡¸-¡¹À» ¹«½ÃÇÒ ¼ö ÀÖ´Â ¹®ÀÚÀÔ´Ï´Ù. À̰ÍÀº Àü¿¡ ¡¸black-birds¡¹¶ó°í ÇÏ´Â ¸»·Î º¸¾Ò´ø ´ë·ÎÀÔ´Ï´Ù. ´Ù¸¥ ¾ð¾îÀÇ ¿¹¸¦ º¸¸é, ´ëºÎºÐÀÇ ¿¢¼¾Æ®¸¦ ¹«½ÃÇÒ ¼ö ÀÖ´Â °ÍÀ» ¾Ë ¼ö ÀÖ½À´Ï´Ù.
Á¤±ÔÈ¿Í ¿¢¼¾Æ®
RuleBasedCollator
´Â ÀÚµ¿ÀûÀ¸·Î ±× ·ê Å×À̺íÀ» ó¸®ÇÏ´Â °ÍÀ¸·Î½á, »çÀü ÇÕ¼ºÀÌ ³¡³ ¹öÀü°ú °áÇÕ ¹®ÀÚ ¹öÀüÀÇ ¿¢¼¾Æ® ÷ºÎ ¹®ÀÚ°¡ ¾î´ÀÂÊÀ̳ª Æ÷ÇԵǵµ·Ï ÇÕ´Ï´Ù. Á¦°øµÇ°í ÀÖ´Â ·ê ij¸¯ÅÍ ¶óÀÎÀÌ º£À̽º ¹®ÀÚ¿Í µ¶¸³ÇÑ °áÇÕ ¿¢¼¾Æ® ¹®ÀڷκÎÅÍ ¸¶¼Å ±¸¼ºµÇ´Â °æ¿ì, ·ê ij¸¯ÅÍ ¶óÀÎÀÇ ¹®ÀÚÀÇ ¸ðµç Ç¥ÁØÀûÀÎ Á¶ÇÕÇØ¿¡ ÀÏÄ¡ÇÏ´Â »çÀü ÇÕ¼ºÀÌ ³¡³ ¿¢¼¾Æ® ÷ºÎ ¹®ÀÚ°¡ Å×ÀÌºí¿¡ ÀԷµ˴ϴÙ.
À̰ÍÀ¸·Î ÄÚ·¹ÀÌŸ°¡ NO_DECOMPOSITION ·Î ¼³Á¤µÇ¾î ÀÖÀ» ¶§¿¡µµ, RuleBasedCollator¸¦ »ç¿ëÇØ ¿¢¼¾Æ® ÷ºÎ ij¸¯ÅÍ ¶óÀÎÀ» ºñ±³ÇÒ ¼ö ÀÖ½À´Ï´Ù. ´Ù¸¸, ÁÖÀÇÇØ¾ß ÇÒ Á¡ÀÌ 2°³ ÀÖ½À´Ï´Ù. 1¹øÂ°´Â Á¶ÇÕ ´ë»óÀÇ Ä³¸¯ÅÍ ¶óÀÎÀÌ Ç¥ÁØÀûÀÎ ¼ø¼¿¡ ¾ø´Â °áÇÕ ¼ø¼¸¦ º¸°ü À¯ÁöÇϰí ÀÖ´Â °æ¿ì, ÄÚ·¹ÀÌŸ¸¦ CANONICAL_DECOMPOSITION ¶Ç´Â FULL_DECOMPOSITION ·Î ¼³Á¤ÇØ °áÇÕ ¼ø¼ÀÇ ¼ÒÆ®¸¦ °¡´ÉÇÏ°Ô ÇÒ Çʿ䰡 ÀÖ´Ù°í ÇÏ´Â °ÍÀÔ´Ï´Ù. ÀÌÁ¦(ÀÌ¹Ì ) 1°³´Â ij¸¯ÅÍ ¶óÀÎÀÌ ºÐÇØ ȣȯÀÇ ¹®ÀÚ (¿ÏÀüÆøÀ̳ª ¹ÝÆøµîÀÇ Çü½Ä)¸¦ º¸°ü À¯ÁöÇÏ´Â °æ¿ì, ·ê Å×ÀÌºí¿¡´Â Ç¥ÁØÀûÀÎ ¸ÅÇθ¸ÀÌ Æ÷ÇԵǹǷΠFULL_DECOMPOSITION¸¦ »ç¿ëÇÒ Çʿ䰡 ÀÖ´Ù°í ÇÏ´Â °ÍÀÔ´Ï´Ù.
¿¡·¯
´ÙÀ½ÀÇ °æ¿ì´Â ¿¡·¯°¡ µË´Ï´Ù.
RuleBasedCollator
°¡ ParseException
À»
Throw ÇÕ´Ï´Ù.
·Ê
°£´ÜÇÑ ¿¹:¡¸< a < b < c < d¡¹
³ë¸£¿þÀ̾î: ¡¸< a, A< b, B< c, C< d, D< e, E< f, F< g, G< h, H<i, I< j, J < k, K< l, L< m, M< n, N< o, O< p, P< q, Q< r, R< s, S< t, T < u, U< v, V< w, W< x, X< y, Y< z, Z < \u00E5=a\u030A, \u00C5=A\u030A ;aa, AA< \u00E6, \u00C6< \u00F8, \u00D8¡¹
º¸Åë, ·ê º£À̽ºÀÇ Collator °´Ã¼¸¦ ÀÛ¼ºÇÏ·Á¸é,
Collator
ÆÑÅ丮 ¸Þ¼µå getInstance
¸¦ »ç¿ëÇÕ´Ï´Ù. ±×·¯³ª, ¿ä±¸¿¡ ¸ÂÃá Æ¯¼öÇÑ ·êÀ» °¡Áö´Â ·ê º£À̽ºÀÇ Collator °´Ã¼¸¦ ÀÛ¼ºÇÏ·Á¸é,
String °´Ã¼¿¡ ·êÀ» ÁöÁ¤ÇØ, RuleBasedCollator
¸¦ ±¸ÃàÇÕ´Ï´Ù. ¿¹¸¦ µé¾î
´ÙÀ½°ú °°ÀÌ ÇÕ´Ï´Ù.
¶Ç´Â:String Simple = "< a< b< c< d"; RuleBasedCollator mySimple = new RuleBasedCollator(Simple);
String Norwegian = "< a, A< b, B< c, C< d, D< e, E< f, F< g, G< h, H< i, I< j, J" + "< k, K< l, L< m, M< n, N< o, O< p, P< q, Q< r, R< s, S< t, T" + "< u, U< v, V< w, W< x, X< y, Y< z, Z" + "< \u00E5=a\u030A, \u00C5=A\u030A" + ";aa, AA< \u00E6, \u00C6< \u00F8, \u00D8"; RuleBasedCollator myNorwegian = new RuleBasedCollator(Norwegian);
Collator
¸¦ °áÇÕÇÏ´Â °ÍÀº ij¸¯ÅÍ ¶óÀÎÀ» °áÇÕÇÑ´Ù¶ó´Â °°Àº Á¤µµ °£´ÜÇÕ´Ï´Ù. ´ÙÀ½ÀÇ ¿¹´Â 2°³ÀÌ ´Ù¸¥ ·ÎÄÉÀÏÀÇ 2°³ÀÇ Collator
¸¦ °áÇÕÇÏ´Â ¿¹ÀÔ´Ï´Ù.
// Create an en_US Collator object RuleBasedCollator en_USCollator = (RuleBasedCollator) Collator.getInstance(new Locale("en", "US", "")); // Create a da_DK Collator object RuleBasedCollator da_DKCollator = (RuleBasedCollator) Collator.getInstance(new Locale("da", "DK", "")); // Combine the two // First, get the collation rules from en_USCollator String en_USRules = en_USCollator.getRules(); // Second, get the collation rules from da_DKCollator String da_DKRules = da_DKCollator.getRules(); RuleBasedCollator newCollator = new RuleBasedCollator(en_USRules + da_DKRules); // newCollator has the combined rules
ÀÌÁ¦(À̹Ì
) 1°³ÀÇ ¿¹¿¡¼´Â ±âÁ¸ÀÇ Å×À̺íÀ» º¯°æÇØ »õ·Î¿î Collator
°´Ã¼¸¦ ÀÛ¼ºÇÕ´Ï´Ù. ¿¹¸¦ µé¾î
¡¸& C < ch, cH, Ch, CH¡¹¸¦ en_USCollator
°´Ã¼¿¡ Ãß°¡ÇØ, µ¶ÀÚÀûÀÎ Å×À̺íÀ» ÀÛ¼ºÇÕ´Ï´Ù.
// Create a new Collator object with additional rules String addRules = "&C< ch, cH, Ch, CH"; RuleBasedCollator myCollator = new RuleBasedCollator(en_USCollator + addRules); // myCollator contains the new rules
´ÙÀ½ÀÇ ¿¹´Â ºñ½ºÆäÀ̽̾ÆÅ©¼¾Æ®ÀÇ ¼ø¼¸¦ º¯°æÇÏ´Â ¹æ¹ýÀ» ³ªÅ¸³»°í ÀÖ½À´Ï´Ù.
// old rule String oldRules = "=\u0301;\u0300;\u0302;\u0308" // main accents + ";\u0327;\u0303;\u0304;\u0305" // main accents + ";\u0306;\u0307;\u0309;\u030A" // main accents + ";\u030B;\u030C;\u030D;\u030E" // main accents + ";\u030F;\u0310;\u0311;\u0312" // main accents + "< a, A ; ae, AE ; \u00e6, \u00c6" + "< b, B < c, C < e, E & C < d, D"; // change the order of accent characters String addOn = "& \u0300 ; \u0308 ; \u0302"; RuleBasedCollator myCollator = new RuleBasedCollator(oldRules + addOn);
¸¶Áö¸· ¿¹¿¡¼´Â »õ·Î¿î ÁÖ¿ä ¼ø¼¸¦ µðÆúÆ®ÀÇ ¼³Á¤º¸´Ù Àü¿¡ µÎ´Â ¹æ¹ýÀ» ³ªÅ¸³À´Ï´Ù. ¿¹¸¦ µé¾î
ÀϺ»¾î Collator
¿¡
¼´Â ¿µ¾îÀÇ ¹®ÀÚ¸¦ ÀϺ»¾îÀÇ ¹®ÀÚº¸´Ù Àü¿¡ ¼ÒÆ® ÇÏ´Â Àϵµ, ÈÄ¿¡ ¼ÒÆ® ÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
// get en_US Collator rules RuleBasedCollator en_USCollator = (RuleBasedCollator) Collator.getInstance(Locale.US); // add a few Japanese character to sort before English characters // suppose the last character before the first base letter 'a' in // the English collation rule is \u2212 String jaString = "& \u2212 < \u3041, \u3042 < \u3043, \u3044"; RuleBasedCollator myJapaneseCollator = new RuleBasedCollator(en_USCollator.getRules() + jaString);
Collator
,
CollationElementIterator
ÇÊµå °³¿ä |
---|
Ŭ·¡½º java.text. Collator ·ÎºÎÅÍ »ó¼ÓµÈ Çʵå |
---|
CANONICAL_DECOMPOSITION,
FULL_DECOMPOSITION,
IDENTICAL,
NO_DECOMPOSITION,
PRIMARY,
SECONDARY,
TERTIARY |
»ý¼ºÀÚ °³¿ä | |
---|---|
RuleBasedCollator (String rules)
RuleBasedCollator »ý¼ºÀÚ ÀÔ´Ï´Ù. |
¸Þ¼µå °³¿ä | |
---|---|
Object |
clone ()
Ç¥ÁØ ¿À¹ö¶óÀ̵å(override)ÀÔ´Ï´Ù. |
int |
compare (String source,
String target)
2°³°¡ ´Ù¸¥ ij¸¯ÅÍ ¶óÀο¡ Æ÷ÇÔµÈ ¹®ÀÚ µ¥ÀÌÅ͸¦, Á¶ÇÕ ·ê¿¡ µû¶ó ºñ±³ÇÕ´Ï´Ù. |
boolean |
equals (Object obj)
2°³ÀÇ Á¶ÇÕ °´Ã¼°¡ µ¿ÀÏÇÑÁö ¾î¶²Áö¸¦ ºñ±³ÇÕ´Ï´Ù. |
CollationElementIterator |
getCollationElementIterator (CharacterIterator source)
ÁöÁ¤µÈ String CollationElementIterator¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
CollationElementIterator |
getCollationElementIterator (String source)
ÁöÁ¤µÈ String CollationElementIterator¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
CollationKey |
getCollationKey (String source)
ij¸¯ÅÍ ¶óÀÎÀ» CollationKey.compareTo ·Î ºñ±³ÇÒ ¼ö ÀÖ´Â ÀÏ·ÃÀÇ ¹®ÀÚ·Î º¯È¯ÇÕ´Ï´Ù. |
String |
getRules ()
Á¶ÇÕ °´Ã¼¿¡ ´ëÇÑ Å×ÀÌºí º£À̽º ·êÀ» ÃëµæÇÕ´Ï´Ù. |
int |
hashCode ()
Å×ÀÌºí º£À̽º Á¶ÇÕ °´Ã¼ÀÇ ÇØ½Ã Äڵ带 »ý¼ºÇÕ´Ï´Ù. |
Ŭ·¡½º java.text. Collator ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
---|
compare,
equals,
getAvailableLocales,
getDecomposition,
getInstance,
getInstance,
getStrength,
setDecomposition,
setStrength |
Ŭ·¡½º java.lang. Object ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
---|
finalize,
getClass,
notify,
notifyAll,
toString,
wait,
wait,
wait |
»ý¼ºÀÚ »ó¼¼ |
---|
public RuleBasedCollator(String rules) throws ParseException
rules
- Á¶ÇÕ Å×À̺íÀ» ±¸ÃàÇÏ´Â ¹ÙÅÁÀ¸·Î µÇ´Â Á¶ÇÕ ·ê
ParseException
- ·êÀÇ ±¸Ãà ÇÁ·Î¼¼½º°¡ ½ÇÆÐÇϸé, Æ÷¸Ë ¿¹¿Ü°¡ Throw µÈ´Ù. ¿¹¸¦ µé¾î
±¸Ãà ·êÀÇ ¡¸a < ? < d¡¹´Â ¡¸?¡¹(ÀÌ)°¡ ÀοëºÎÈ£·Î µÑ·¯½ÎÀÌÁö ¾Ê±â ¶§¹®¿¡
»ý¼ºÀÚ¿¡ ÀÇÇØ ParseException°¡ ¹ß»ýµÇ´Â Locale
¸Þ¼µåÀÇ »ó¼¼ |
---|
public String getRules()
public CollationElementIterator getCollationElementIterator(String source)
CollationElementIterator
public CollationElementIterator getCollationElementIterator(CharacterIterator source)
CollationElementIterator
public int compare(String source, String target)
Collator
³»ÀÇ compare
source
- ¼Ò½º ij¸¯ÅÍ ¶óÀÎtarget
- Ÿ°Ù ij¸¯ÅÍ ¶óÀÎ
CollationKey
,
Collator.getCollationKey(java.lang.String)
public CollationKey getCollationKey(String source)
Collator
³»ÀÇ getCollationKey
source
- Á¶ÇÕ Å°·Î º¯È¯Çϴ ij¸¯ÅÍ ¶óÀÎ
CollationKey
,
Collator.compare(java.lang.String, java.lang.String)
public Object clone()
Collator
³»ÀÇ clone
Cloneable
public boolean equals(Object obj)
Comparator <Object >
³»ÀÇ equals
Collator
³»ÀÇ equals
obj
- ºñ±³ ´ë»óÀÇ Å×ÀÌºí º£À̽ºÀÇ Á¶ÇÕ °´Ã¼
Object.hashCode()
,
Hashtable
public int hashCode()
Collator
³»ÀÇ hashCode
Object.equals(java.lang.Object)
,
Hashtable
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
°³¿ä: NESTED | Çʵå | constructor | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå |
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ ÂüÁ¶ÇϽʽÿÀ.