db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta Satoor" <msat...@gmail.com>
Subject Question about next() and previous() on CollationElementIterator.
Date Mon, 10 Sep 2007 19:57:19 GMT
Hi,

I have a very simple program(included at the bottom of the mail) which uses
the CollationElementIterator to do some very basic next/previous method
calls through the iterator. When I run the program, it is not behaving as
per the JDBC API documentation at
http://java.sun.com/j2se/1.5.0/docs/api/java/text/CollationElementIterator.html#next()
The JDBC API for next and previous very specifically say that "call next()
and then call previous(), or call previous() and then call next()), you'll
get back the same element twice." But when I execute the following program
with Sun's jdk 1.5 on command line, I get following output
next is 2147418112
previous is -97714176

I had expected the output to be
next is 2147418112
previous is 2147418112

Am I doing something wrong here or not interpreting the documentation
correctly? Any help will be greatly appreciated. As a side note, when I run
the same program through the Eclipse debugger, I get the expected behavior
which is that next and previous both return the same value.

thanks,
Mamta

import java.text.Collator;
import java.text.RuleBasedCollator;
import java.util.Locale;
import java.text.CollationElementIterator;

public class simpleTest {
 public static String aa = "\uFA2D";

 public static void main(String[] args) throws Exception {
  RuleBasedCollator myCollator = (RuleBasedCollator)Collator.getInstance(new
Locale("no","NO"));
  CollationElementIterator anIterator =
myCollator.getCollationElementIterator(aa);
  System.out.println("next is " + anIterator.next());
  System.out.println("previous is " + anIterator.previous());
 }
}

Mime
View raw message