use of android.icu.text.UnicodeSet in project j2objc by google.
the class UtilityTest method TestUnicodeSet.
@Test
public void TestUnicodeSet() {
String[] array = new String[] { "a", "b", "c", "{de}" };
List list = Arrays.asList(array);
Set aset = new HashSet(list);
logln(" *** The source set's size is: " + aset.size());
// The size reads 4
UnicodeSet set = new UnicodeSet();
set.clear();
set.addAll(aset);
logln(" *** After addAll, the UnicodeSet size is: " + set.size());
// The size should also read 4, but 0 is seen instead
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class CollationDataBuilder method setDigitTags.
protected void setDigitTags() {
UnicodeSet digits = new UnicodeSet("[:Nd:]");
UnicodeSetIterator iter = new UnicodeSetIterator(digits);
while (iter.next()) {
assert (iter.codepoint != UnicodeSetIterator.IS_STRING);
int c = iter.codepoint;
int ce32 = trie.get(c);
if (ce32 != Collation.FALLBACK_CE32 && ce32 != Collation.UNASSIGNED_CE32) {
int index = addCE32(ce32);
if (index > Collation.MAX_INDEX) {
throw new IndexOutOfBoundsException("too many mappings");
// BufferOverflowException is a better fit
// but cannot be constructed with a message string.
}
ce32 = Collation.makeCE32FromTagIndexAndLength(Collation.DIGIT_TAG, index, // u_charDigitValue(c)
UCharacter.digit(c));
trie.set(c, ce32);
}
}
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class TestBoilerplate method getSet.
public static <T> UnicodeSet getSet(Map<Integer, T> m, T value) {
UnicodeSet result = new UnicodeSet();
for (Iterator<Integer> it = m.keySet().iterator(); it.hasNext(); ) {
Integer key = it.next();
T val = m.get(key);
if (!val.equals(value))
continue;
result.add(key.intValue());
}
return result;
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizer method nextToken.
/**
* Returns the next token in this string tokenizer's string. First,
* the set of characters considered to be delimiters by this
* <tt>StringTokenizer</tt> object is changed to be the characters in
* the string <tt>delim</tt>. Then the next token in the string
* after the current position is returned. The current position is
* advanced beyond the recognized token. The new delimiter set
* remains the default after this call.
* @param delim the new delimiters.
* @return the next token, after switching to the new delimiter set.
* @exception NoSuchElementException if there are no more tokens in
* this tokenizer's string.
*/
public String nextToken(String delim) {
m_delimiters_ = EMPTY_DELIMITER_;
if (delim != null && delim.length() > 0) {
m_delimiters_ = new UnicodeSet();
m_delimiters_.addAll(delim);
}
return nextToken(m_delimiters_);
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class BasicTest method TestCanonIterData.
@Test
public void TestCanonIterData() {
// For now, just a regression test.
Normalizer2Impl impl = Norm2AllModes.getNFCInstance().impl.ensureCanonIterData();
// but it is not a segment starter because it occurs in a decomposition mapping.
if (impl.isCanonSegmentStarter(0xfb5)) {
errln("isCanonSegmentStarter(U+0fb5)=true is wrong");
}
// For [:Segment_Starter:] to work right, not just the property function has to work right,
// UnicodeSet also needs a correct range starts set.
UnicodeSet segStarters = new UnicodeSet("[:Segment_Starter:]").freeze();
if (segStarters.contains(0xfb5)) {
errln("[:Segment_Starter:].contains(U+0fb5)=true is wrong");
}
// Try characters up to Kana and miscellaneous CJK but below Han (for expediency).
for (int c = 0; c <= 0x33ff; ++c) {
boolean isStarter = impl.isCanonSegmentStarter(c);
boolean isContained = segStarters.contains(c);
if (isStarter != isContained) {
errln(String.format("discrepancy: isCanonSegmentStarter(U+%04x)=%5b != " + "[:Segment_Starter:].contains(same)", c, isStarter));
}
}
}
Aggregations