ICU-4355 Port of no UCA runtime

X-SVN-Rev: 18337
This commit is contained in:
Vladimir Weinstein 2005-07-22 22:52:21 +00:00
parent a065ba1ab2
commit 0ac7284cad
2 changed files with 32 additions and 13 deletions

View file

@ -290,7 +290,7 @@ public final class CollationElementIterator
// surrogate leads are handled as special ces
result = nextSpecial(m_collator_, result, ch);
}
if (result == CE_NOT_FOUND_) {
if (result == CE_NOT_FOUND_ && RuleBasedCollator.UCA_ != null) {
// couldn't find a good CE in the tailoring
// if we got here, the codepoint MUST be over 0xFF - so we look
// directly in the UCA
@ -301,6 +301,10 @@ public final class CollationElementIterator
}
}
}
if(result == CE_NOT_FOUND_) {
// maybe there is no UCA, unlikely in Java, but ported for consistency
result = nextImplicit(ch);
}
return result;
}
@ -370,16 +374,21 @@ public final class CollationElementIterator
result = CE_CONTRACTION_;
}
else {
result
= RuleBasedCollator.UCA_.m_trie_.getLeadValue(ch);
if(RuleBasedCollator.UCA_ != null) {
result = RuleBasedCollator.UCA_.m_trie_.getLeadValue(ch);
}
}
if (RuleBasedCollator.isSpecial(result)) {
result = previousSpecial(RuleBasedCollator.UCA_,
result, ch);
if(RuleBasedCollator.UCA_ != null) {
result = previousSpecial(RuleBasedCollator.UCA_, result, ch);
}
}
}
}
if(result == CE_NOT_FOUND_) {
result = previousImplicit(ch);
}
return result;
}
@ -1625,7 +1634,7 @@ public final class CollationElementIterator
private int nextContraction(RuleBasedCollator collator, int ce)
{
backupInternalState(m_utilSpecialBackUp_);
int entryce = CE_NOT_FOUND_;
int entryce = collator.m_contractionCE_[getContractionOffset(collator, ce)]; //CE_NOT_FOUND_;
while (true) {
int entryoffset = getContractionOffset(collator, ce);
int offset = entryoffset;

View file

@ -1713,6 +1713,14 @@ public final class RuleBasedCollator extends Collator
//
static final byte SORT_LEVEL_TERMINATOR_ = 1;
// These are values from UCA required for
// implicit generation and supressing sort key compression
// they should regularly be in the UCA, but if one
// is running without UCA, it could be a problem
static final int maxRegularPrimary = 0xA0;
static final int minImplicitPrimary = 0xE0;
static final int maxImplicitPrimary = 0xE4;
// block to initialise character property database
static
@ -1737,7 +1745,8 @@ public final class RuleBasedCollator extends Collator
iUCA_CONTRACTIONS_ = CollatorReader.read(iUCA_, iUCA_CONSTANTS_);
// called before doing canonical closure for the UCA.
iimpCEGen_ = new ImplicitCEGenerator(iUCA_CONSTANTS_.PRIMARY_IMPLICIT_MIN_, iUCA_CONSTANTS_.PRIMARY_IMPLICIT_MAX_);
iimpCEGen_ = new ImplicitCEGenerator(minImplicitPrimary, maxImplicitPrimary);
//iimpCEGen_ = new ImplicitCEGenerator(iUCA_CONSTANTS_.PRIMARY_IMPLICIT_MIN_, iUCA_CONSTANTS_.PRIMARY_IMPLICIT_MAX_);
iUCA_.init();
ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_COLLATION_BASE_NAME, ULocale.ENGLISH);
iUCA_.m_rules_ = (String)rb.getObject("UCARules");
@ -2406,12 +2415,13 @@ public final class RuleBasedCollator extends Collator
leadPrimary = 0;
}
else if (p1 < BYTE_FIRST_NON_LATIN_PRIMARY_
|| (p1
> (RuleBasedCollator.UCA_CONSTANTS_.LAST_NON_VARIABLE_[0]
>>> 24)
&& p1
< (RuleBasedCollator.UCA_CONSTANTS_.FIRST_IMPLICIT_[0]
>>> 24))) {
|| (p1 > maxRegularPrimary
//> (RuleBasedCollator.UCA_CONSTANTS_.LAST_NON_VARIABLE_[0]
// >>> 24)
&& p1 < minImplicitPrimary
//< (RuleBasedCollator.UCA_CONSTANTS_.FIRST_IMPLICIT_[0]
// >>> 24)
)) {
// not compressible
leadPrimary = 0;
m_utilBytes1_ = append(m_utilBytes1_,