/*
*******************************************************************************
-* Copyright (C) 2009-2010, International Business Machines
+* Copyright (C) 2009-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
return impl.getDecomposition(c);
}
+ @Override
+ public int getCombiningClass(int c) {
+ return impl.getCC(impl.getNorm16(c));
+ }
+
// quick checks
@Override
public boolean isNormalized(CharSequence s) {
new IntProperty(0, BLOCK_MASK_, BLOCK_SHIFT_),
new CombiningClassIntProperty(SRC_NFC) { // CANONICAL_COMBINING_CLASS
int getValue(int c) {
- Normalizer2Impl impl = Norm2AllModes.getNFCInstance().impl;
- return impl.getCC(impl.getNorm16(c));
+ return Norm2AllModes.getNFCInstance().decomp.getCombiningClass(c);
}
},
new IntProperty(2, DECOMPOSITION_TYPE_MASK_, 0),
/*
*******************************************************************************
-* Copyright (C) 2010, International Business Machines
+* Copyright (C) 2011, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
int j=i;
c=Character.codePointBefore(label, j);
j-=Character.charCount(c);
- if(UCharacter.getCombiningClass(c)==9) {
+ if(uts46Norm2.getCombiningClass(c)==9) {
continue;
}
// check precontext (Joining_Type:{L,D})(Joining_Type:T)*
import com.ibm.icu.impl.IllegalIcuArgumentException;
import com.ibm.icu.impl.Norm2AllModes;
-import com.ibm.icu.impl.Normalizer2Impl;
import com.ibm.icu.impl.Trie2;
import com.ibm.icu.impl.UBiDiProps;
import com.ibm.icu.impl.UCaseProps;
if (ch < MIN_VALUE || ch > MAX_VALUE) {
throw new IllegalArgumentException("Codepoint out of bounds");
}
- Normalizer2Impl impl = Norm2AllModes.getNFCInstance().impl;
- return impl.getCC(impl.getNorm16(ch));
+ return Norm2AllModes.getNFCInstance().decomp.getCombiningClass(ch);
}
/**
/*
*******************************************************************************
-* Copyright (C) 2009-2010, International Business Machines
+* Copyright (C) 2009-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
return set.contains(c) ? norm2.getDecomposition(c) : null;
}
+ /**
+ * {@inheritDoc}
+ * @draft ICU 49
+ * @provisional This API might change or be removed in a future release.
+ */
+ @Override
+ public int getCombiningClass(int c) {
+ return set.contains(c) ? norm2.getCombiningClass(c) : 0;
+ }
+
/**
* {@inheritDoc}
* @stable ICU 4.4
*/
public abstract String getDecomposition(int c);
+ /**
+ * Gets the combining class of c.
+ * The default implementation returns 0
+ * but all standard implementations return the Unicode Canonical_Combining_Class value.
+ * @param c code point
+ * @return c's combining class
+ * @draft ICU 49
+ * @provisional This API might change or be removed in a future release.
+ */
+ public int getCombiningClass(int c) { return 0; }
+
/**
* Tests if the string is normalized.
* Internally, in cases where the quickCheck() method would return "maybe"
type = 0,
dir = 0;
+ Normalizer2 nfkc = Normalizer2.getInstance(null, "nfkc", Normalizer2.Mode.COMPOSE);
+
try
{
BufferedReader input = TestUtil.getDataReader(
"class " + cc);
break;
}
+ if (nfkc.getCombiningClass(ch) != cc)
+ {
+ errln("FAIL \\u" + hex(ch) + " expected NFKC combining " +
+ "class " + cc);
+ break;
+ }
// testing the direction
if (d.length() == 1)
/*
*******************************************************************************
- * Copyright (C) 1996-2010, International Business Machines Corporation and
+ * Copyright (C) 1996-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/
}
}
}
+
+ public void TestFilteredNormalizer2() {
+ Normalizer2 nfcNorm2=Normalizer2.getInstance(null, "nfc", Normalizer2.Mode.COMPOSE);
+ UnicodeSet filter=new UnicodeSet("[^\u00a0-\u00ff\u0310-\u031f]");
+ FilteredNormalizer2 fn2=new FilteredNormalizer2(nfcNorm2, filter);
+ int c;
+ for(c=0; c<=0x3ff; ++c) {
+ int expectedCC= filter.contains(c) ? nfcNorm2.getCombiningClass(c) : 0;
+ int cc=fn2.getCombiningClass(c);
+ assertEquals(
+ "FilteredNormalizer2(NFC, ^A0-FF,310-31F).getCombiningClass(U+"+hex(c)+
+ ")==filtered NFC.getCC()",
+ expectedCC, cc);
+ }
+ }
}