CollationElementIterator.java: Reformated.
2004-01-06 Michael Koch <konqueror@gmx.de> * java/text/CollationElementIterator.java: Reformated. (CollationElementIterator): Changed order of arguments. * java/text/RuleBasedCollator.java (RuleBasedCollator): Merged class documentation. (CollationElement): Added documentation. (compare): Reformated, renamed arguments. (equals): Likewise. (getCollationElementIterator): Likewise. (getCollationKey): Likewise. From-SVN: r75484
This commit is contained in:
parent
64d961b859
commit
5f383ba58b
3 changed files with 62 additions and 38 deletions
|
@ -1,3 +1,15 @@
|
|||
2004-01-06 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/text/CollationElementIterator.java: Reformated.
|
||||
(CollationElementIterator): Changed order of arguments.
|
||||
* java/text/RuleBasedCollator.java
|
||||
(RuleBasedCollator): Merged class documentation.
|
||||
(CollationElement): Added documentation.
|
||||
(compare): Reformated, renamed arguments.
|
||||
(equals): Likewise.
|
||||
(getCollationElementIterator): Likewise.
|
||||
(getCollationKey): Likewise.
|
||||
|
||||
2004-01-06 Graydon Hoare <graydon@redhat.com>
|
||||
|
||||
* javax/swing/JLayeredPane.java: Fix semantics, add javadocs.
|
||||
|
|
|
@ -53,6 +53,7 @@ package java.text;
|
|||
*
|
||||
* @author Aaron M. Renn <arenn@urbanophile.com>
|
||||
* @author Tom Tromey <tromey@cygnus.com>
|
||||
* @author Guilhem Lavaux <guilhem.lavaux@free.fr>
|
||||
*/
|
||||
public final class CollationElementIterator
|
||||
{
|
||||
|
@ -89,15 +90,17 @@ public final class CollationElementIterator
|
|||
* @param collator The <code>RuleBasedCollation</code> used for calculating collation values
|
||||
* @param text The <code>String</code> to iterate over.
|
||||
*/
|
||||
CollationElementIterator (String text, RuleBasedCollator collator)
|
||||
CollationElementIterator(RuleBasedCollator collator, String text)
|
||||
{
|
||||
setText (text);
|
||||
this.collator = collator;
|
||||
|
||||
setText (text);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the collation ordering value of the next character
|
||||
* in the string. This method will return <code>NULLORDER</code> if the
|
||||
* This method returns the collation ordering value of the next character sequence
|
||||
* in the string (it may be an extended character following collation rules).
|
||||
* This method will return <code>NULLORDER</code> if the
|
||||
* end of the string was reached.
|
||||
*
|
||||
* @return The collation ordering value.
|
||||
|
@ -118,7 +121,7 @@ public final class CollationElementIterator
|
|||
*
|
||||
* @return The primary order value of the specified collation value. This is the high 16 bits.
|
||||
*/
|
||||
public static final int primaryOrder (int order)
|
||||
public static final int primaryOrder(int order)
|
||||
{
|
||||
// From the JDK 1.2 spec.
|
||||
return order >>> 16;
|
||||
|
@ -141,7 +144,7 @@ public final class CollationElementIterator
|
|||
*
|
||||
* @return The secondary order value of the specified collation value. This is the bits 8-15.
|
||||
*/
|
||||
public static final short secondaryOrder (int order)
|
||||
public static final short secondaryOrder(int order)
|
||||
{
|
||||
// From the JDK 1.2 spec.
|
||||
return (short) ((order >>> 8) & 255);
|
||||
|
@ -155,7 +158,7 @@ public final class CollationElementIterator
|
|||
*
|
||||
* @return The tertiary order value of the specified collation value. This is the low eight bits.
|
||||
*/
|
||||
public static final short tertiaryOrder (int order)
|
||||
public static final short tertiaryOrder(int order)
|
||||
{
|
||||
// From the JDK 1.2 spec.
|
||||
return (short) (order & 255);
|
||||
|
@ -169,7 +172,7 @@ public final class CollationElementIterator
|
|||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public void setText (String text)
|
||||
public void setText(String text)
|
||||
{
|
||||
this.text = text;
|
||||
this.index = 0;
|
||||
|
@ -189,6 +192,4 @@ public final class CollationElementIterator
|
|||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
} // class CollationElementIterator
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
|
|||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package java.text;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
@ -62,7 +61,10 @@ import java.util.Vector;
|
|||
* <li> Reset: '&' : <text>
|
||||
* </ul>
|
||||
* The modifier character indicates that accents sort backward as is the
|
||||
* case with French. The relational operators specify how the text
|
||||
* case with French. The modifier applies to all rules <b>after</b>
|
||||
* the modifier but before the next primary sequence. If placed at the end
|
||||
* of the sequence if applies to all unknown accented character.
|
||||
* The relational operators specify how the text
|
||||
* argument relates to the previous term. The relation characters have
|
||||
* the following meanings:
|
||||
* <ul>
|
||||
|
@ -113,6 +115,9 @@ import java.util.Vector;
|
|||
* anywhere in the previous rule string segment so the rule following the
|
||||
* reset rule cannot be inserted.
|
||||
* <p>
|
||||
* "< a & A @ < e & E < f& F" - This sequence is equivalent to the following
|
||||
* "< a & A < E & e < f & F".
|
||||
* <p>
|
||||
* For a description of the various comparison strength types, see the
|
||||
* documentation for the <code>Collator</code> class.
|
||||
* <p>
|
||||
|
@ -134,11 +139,14 @@ import java.util.Vector;
|
|||
*
|
||||
* @author Aaron M. Renn <arenn@urbanophile.com>
|
||||
* @author Tom Tromey <tromey@cygnus.com>
|
||||
* @date March 25, 1999
|
||||
* @author Guilhem Lavaux <guilhem@kaffe.org>
|
||||
*/
|
||||
|
||||
public class RuleBasedCollator extends Collator
|
||||
{
|
||||
/**
|
||||
* This class describes what rank has a character (or a sequence of characters)
|
||||
* in the lexicographic order. Each element in a rule has a collation element.
|
||||
*/
|
||||
final class CollationElement
|
||||
{
|
||||
String key;
|
||||
|
@ -178,7 +186,7 @@ public class RuleBasedCollator extends Collator
|
|||
*
|
||||
* @exception ParseException If the rule string contains syntax errors.
|
||||
*/
|
||||
public RuleBasedCollator (String rules) throws ParseException
|
||||
public RuleBasedCollator(String rules) throws ParseException
|
||||
{
|
||||
if (rules.equals (""))
|
||||
throw new ParseException ("empty rule set", 0);
|
||||
|
@ -409,20 +417,20 @@ public class RuleBasedCollator extends Collator
|
|||
* the second. The value depends not only on the collation rules in
|
||||
* effect, but also the strength and decomposition settings of this object.
|
||||
*
|
||||
* @param s1 The first <code>String</code> to compare.
|
||||
* @param s2 A second <code>String</code> to compare to the first.
|
||||
* @param source The first <code>String</code> to compare.
|
||||
* @param target A second <code>String</code> to compare to the first.
|
||||
*
|
||||
* @return A negative integer if s1 < s2, a positive integer
|
||||
* if s1 > s2, or 0 if s1 == s2.
|
||||
* @return A negative integer if source < target, a positive integer
|
||||
* if source > target, or 0 if source == target.
|
||||
*/
|
||||
public int compare (String source, String target)
|
||||
public int compare(String source, String target)
|
||||
{
|
||||
CollationElementIterator cs, ct;
|
||||
|
||||
cs = new CollationElementIterator (source, this);
|
||||
ct = new CollationElementIterator (target, this);
|
||||
cs = new CollationElementIterator(this, source);
|
||||
ct = new CollationElementIterator(this, target);
|
||||
|
||||
while (true)
|
||||
for(;;)
|
||||
{
|
||||
int os = next (cs, strength);
|
||||
int ot = next (ct, strength);
|
||||
|
@ -455,9 +463,10 @@ public class RuleBasedCollator extends Collator
|
|||
*
|
||||
* @param obj The <code>Object</code> to compare against this object.
|
||||
*
|
||||
* @return <code>true</code> if the specified object is equal to this object, <code>false</code> otherwise.
|
||||
* @return <code>true</code> if the specified object is equal to this object,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean equals (Object obj)
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (! (obj instanceof RuleBasedCollator) || ! super.equals(obj))
|
||||
return false;
|
||||
|
@ -473,17 +482,19 @@ public class RuleBasedCollator extends Collator
|
|||
* for the specified <code>String</code> under the collation rules for this
|
||||
* object.
|
||||
*
|
||||
* @param str The <code>String</code> to return the <code>CollationElementIterator</code> instance for.
|
||||
* @param source The <code>String</code> to return the
|
||||
* <code>CollationElementIterator</code> instance for.
|
||||
*
|
||||
* @return A <code>CollationElementIterator</code> for the specified <code>String</code>.
|
||||
* @return A <code>CollationElementIterator</code> for the specified
|
||||
* <code>String</code>.
|
||||
*/
|
||||
public CollationElementIterator getCollationElementIterator (String source)
|
||||
public CollationElementIterator getCollationElementIterator(String source)
|
||||
{
|
||||
StringBuffer expand = new StringBuffer (source.length());
|
||||
int max = source.length();
|
||||
for (int i = 0; i < max; ++i)
|
||||
decomposeCharacter (source.charAt(i), expand);
|
||||
return new CollationElementIterator (expand.toString(), this);
|
||||
return new CollationElementIterator(this, expand.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -491,19 +502,19 @@ public class RuleBasedCollator extends Collator
|
|||
* for the <code>String</code> represented by the specified
|
||||
* <code>CharacterIterator</code>.
|
||||
*
|
||||
* @param ci The <code>CharacterIterator</code> with the desired <code>String</code>.
|
||||
* @param source The <code>CharacterIterator</code> with the desired <code>String</code>.
|
||||
*
|
||||
* @return A <code>CollationElementIterator</code> for the specified <code>String</code>.
|
||||
*/
|
||||
public CollationElementIterator getCollationElementIterator (CharacterIterator source)
|
||||
public CollationElementIterator getCollationElementIterator(CharacterIterator source)
|
||||
{
|
||||
StringBuffer expand = new StringBuffer ();
|
||||
StringBuffer expand = new StringBuffer();
|
||||
for (char c = source.first ();
|
||||
c != CharacterIterator.DONE;
|
||||
c = source.next ())
|
||||
decomposeCharacter (c, expand);
|
||||
|
||||
return new CollationElementIterator (expand.toString(), this);
|
||||
return new CollationElementIterator(this, expand.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,14 +524,14 @@ public class RuleBasedCollator extends Collator
|
|||
* provide speed benefits if multiple comparisons are performed, such
|
||||
* as during a sort.
|
||||
*
|
||||
* @param str The <code>String</code> to create a <code>CollationKey</code> for.
|
||||
* @param source The <code>String</code> to create a <code>CollationKey</code> for.
|
||||
*
|
||||
* @return A <code>CollationKey</code> for the specified <code>String</code>.
|
||||
*/
|
||||
public CollationKey getCollationKey (String source)
|
||||
public CollationKey getCollationKey(String source)
|
||||
{
|
||||
return new CollationKey (getCollationElementIterator (source), source,
|
||||
strength);
|
||||
return new CollationKey(getCollationElementIterator(source), source,
|
||||
strength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue