ICU-2751 implementation and tests for Collator's getVersion and getUCAVersion
X-SVN-Rev: 14316
This commit is contained in:
parent
f7a4a8d4a5
commit
d041ed1d61
@ -23,6 +23,7 @@ import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import com.ibm.icu.dev.test.*;
|
||||
import com.ibm.icu.text.*;
|
||||
import com.ibm.icu.util.VersionInfo;
|
||||
|
||||
public class CollationAPITest extends TestFmwk {
|
||||
public static void main(String[] args) throws Exception {
|
||||
@ -513,6 +514,14 @@ public class CollationAPITest extends TestFmwk {
|
||||
return;
|
||||
}
|
||||
|
||||
logln("Test getVersion");
|
||||
VersionInfo expectedVersion = VersionInfo.getInstance(0x21, 0x40, 0x01, 0x04);
|
||||
doAssert(col.getVersion().equals(expectedVersion), "Expected version "+expectedVersion.toString()+" got "+col.getVersion().toString());
|
||||
|
||||
logln("Test getUCAVersion");
|
||||
VersionInfo expectedUCAVersion = VersionInfo.getInstance(0x4, 0, 0, 0);
|
||||
doAssert(col.getUCAVersion().equals(expectedUCAVersion), "Expected UCA version "+expectedUCAVersion.toString()+" got "+col.getUCAVersion().toString());
|
||||
|
||||
doAssert((col.compare("ab", "abc") < 0), "ab < abc comparison failed");
|
||||
doAssert((col.compare("ab", "AB") < 0), "ab < AB comparison failed");
|
||||
doAssert((col.compare("blackbird", "black-bird") > 0), "black-bird > blackbird comparison failed");
|
||||
@ -836,6 +845,14 @@ public class CollationAPITest extends TestFmwk {
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public VersionInfo getVersion()
|
||||
{
|
||||
return VersionInfo.getInstance(0);
|
||||
}
|
||||
public VersionInfo getUCAVersion()
|
||||
{
|
||||
return VersionInfo.getInstance(0);
|
||||
}
|
||||
}
|
||||
|
||||
Collator col1 = new TestCollator();
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Collator.java,v $
|
||||
* $Date: 2004/01/08 22:26:56 $
|
||||
* $Revision: 1.40 $
|
||||
* $Date: 2004/01/14 21:49:20 $
|
||||
* $Revision: 1.41 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -738,17 +738,13 @@ public abstract class Collator implements Comparator, Cloneable
|
||||
* @return the version object associated with this collator
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public VersionInfo getVersion() {
|
||||
return VersionInfo.getInstance(0);
|
||||
}
|
||||
public abstract VersionInfo getVersion();
|
||||
|
||||
/** Get the UCA version of this collator object.
|
||||
* @return the version object associated with this collator
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public VersionInfo getUCAVersion() {
|
||||
return VersionInfo.getInstance(0);
|
||||
}
|
||||
public abstract VersionInfo getUCAVersion();
|
||||
|
||||
// protected constructor -------------------------------------------------
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java,v $
|
||||
* $Date: 2004/01/08 22:27:03 $
|
||||
* $Revision: 1.54 $
|
||||
* $Date: 2004/01/14 21:49:20 $
|
||||
* $Revision: 1.55 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -4394,4 +4394,42 @@ public final class RuleBasedCollator extends Collator
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/** Get the version of this collator object.
|
||||
* @return the version object associated with this collator
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public VersionInfo getVersion() {
|
||||
/* RunTime version */
|
||||
int rtVersion = VersionInfo.UCOL_RUNTIME_VERSION.getMajor();
|
||||
/* Builder version*/
|
||||
int bdVersion = m_version_.getMajor();
|
||||
|
||||
/* Charset Version. Need to get the version from cnv files
|
||||
* makeconv should populate cnv files with version and
|
||||
* an api has to be provided in ucnv.h to obtain this version
|
||||
*/
|
||||
int csVersion = 0;
|
||||
|
||||
/* combine the version info */
|
||||
int cmbVersion = ((rtVersion<<11) | (bdVersion<<6) | (csVersion)) & 0xFFFF;
|
||||
|
||||
/* Tailoring rules */
|
||||
return VersionInfo.getInstance(cmbVersion>>8,
|
||||
cmbVersion & 0xFF,
|
||||
m_version_.getMinor(),
|
||||
UCA_.m_UCA_version_.getMajor());
|
||||
|
||||
// versionInfo[0] = (uint8_t)(cmbVersion>>8);
|
||||
// versionInfo[1] = (uint8_t)cmbVersion;
|
||||
// versionInfo[2] = coll->image->version[1];
|
||||
// versionInfo[3] = coll->UCA->image->UCAVersion[0];
|
||||
}
|
||||
|
||||
/** Get the UCA version of this collator object.
|
||||
* @return the version object associated with this collator
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public VersionInfo getUCAVersion() {
|
||||
return UCA_.m_UCA_version_;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/util/VersionInfo.java,v $
|
||||
* $Date: 2003/11/18 17:53:53 $
|
||||
* $Revision: 1.17 $
|
||||
* $Date: 2004/01/14 21:49:20 $
|
||||
* $Revision: 1.18 $
|
||||
*
|
||||
* jitterbug 1741
|
||||
*****************************************************************************************
|
||||
@ -108,6 +108,25 @@ public final class VersionInfo
|
||||
*/
|
||||
public static final VersionInfo ICU_VERSION;
|
||||
|
||||
/**
|
||||
* ICU4J collator runtime version
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public static final VersionInfo UCOL_RUNTIME_VERSION;
|
||||
|
||||
/**
|
||||
* ICU4J collator builder version
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public static final VersionInfo UCOL_BUILDER_VERSION;
|
||||
|
||||
/**
|
||||
* ICU4J collator tailorings version
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public static final VersionInfo UCOL_TAILORINGS_VERSION;
|
||||
|
||||
|
||||
// public methods ------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -361,6 +380,9 @@ public final class VersionInfo
|
||||
UNICODE_3_2 = getInstance(3, 2, 0, 0);
|
||||
UNICODE_4_0 = getInstance(4, 0, 0, 0);
|
||||
ICU_VERSION = getInstance(2, 8, 0, 0);
|
||||
UCOL_RUNTIME_VERSION = getInstance(4);
|
||||
UCOL_BUILDER_VERSION = getInstance(5);
|
||||
UCOL_TAILORINGS_VERSION = getInstance(1);
|
||||
}
|
||||
|
||||
// private constructor -----------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user