Java Code Examples for com.ibm.icu.text.UnicodeSet#getRangeStart()
The following examples show how to use
com.ibm.icu.text.UnicodeSet#getRangeStart() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Compiler.java From tcl-regex-java with Apache License 2.0 | 6 votes |
/** * dovec - fill in arcs for each element of a cvec * all kinds of MCCE complexity removed. */ private void dovec(UnicodeSet set, State lp, State rp) throws RegexException { int rangeCount = set.getRangeCount(); for (int rx = 0; rx < rangeCount; rx++) { int rangeStart = set.getRangeStart(rx); int rangeEnd = set.getRangeEnd(rx); /* * Note: ICU operates in UTF-32 here, and the ColorMap is happy to play along. */ if (LOG.isDebugEnabled() && IS_DEBUG) { LOG.debug(String.format("%s %d %4x %4x", set, rx, rangeStart, rangeEnd)); } //TODO: this arc is probably redundant. if (rangeStart == rangeEnd) { nfa.newarc(PLAIN, cm.subcolor(rangeStart), lp, rp); } cm.subrange(rangeStart, rangeEnd, lp, rp); } }
Example 2
Source File: CharacterProperties.java From trekarta with GNU General Public License v3.0 | 5 votes |
private static UnicodeSet makeSet(int property) { UnicodeSet set = new UnicodeSet(); UnicodeSet inclusions = CharacterPropertiesImpl.getInclusionsForProperty(property); int numRanges = inclusions.getRangeCount(); int startHasProperty = -1; for (int i = 0; i < numRanges; ++i) { int rangeEnd = inclusions.getRangeEnd(i); for (int c = inclusions.getRangeStart(i); c <= rangeEnd; ++c) { // TODO: Get a UCharacterProperty.BinaryProperty to avoid the property dispatch. if (UCharacter.hasBinaryProperty(c, property)) { if (startHasProperty < 0) { // Transition from false to true. startHasProperty = c; } } else if (startHasProperty >= 0) { // Transition from true to false. set.add(startHasProperty, c - 1); startHasProperty = -1; } } } if (startHasProperty >= 0) { set.add(startHasProperty, 0x10FFFF); } return set.freeze(); }
Example 3
Source File: CharacterPropertiesImpl.java From trekarta with GNU General Public License v3.0 | 5 votes |
private static UnicodeSet getIntPropInclusions(int prop) { assert(UProperty.INT_START <= prop && prop < UProperty.INT_LIMIT); int inclIndex = UCharacterProperty.SRC_COUNT + prop - UProperty.INT_START; if (inclusions[inclIndex] != null) { return inclusions[inclIndex]; } int src = UCharacterProperty.INSTANCE.getSource(prop); UnicodeSet incl = getInclusionsForSource(src); UnicodeSet intPropIncl = new UnicodeSet(0, 0); int numRanges = incl.getRangeCount(); int prevValue = 0; for (int i = 0; i < numRanges; ++i) { int rangeEnd = incl.getRangeEnd(i); for (int c = incl.getRangeStart(i); c <= rangeEnd; ++c) { // TODO: Get a UCharacterProperty.IntProperty to avoid the property dispatch. int value = UCharacter.getIntPropertyValue(c, prop); if (value != prevValue) { intPropIncl.add(c); prevValue = value; } } } // Compact for caching. return inclusions[inclIndex] = intPropIncl.compact(); }
Example 4
Source File: CharacterProperties.java From trekarta with GNU General Public License v3.0 | 4 votes |
private static CodePointMap makeMap(int property) { int nullValue = property == UProperty.SCRIPT ? UScript.UNKNOWN : 0; MutableCodePointTrie mutableTrie = new MutableCodePointTrie(nullValue, nullValue); UnicodeSet inclusions = CharacterPropertiesImpl.getInclusionsForProperty(property); int numRanges = inclusions.getRangeCount(); int start = 0; int value = nullValue; for (int i = 0; i < numRanges; ++i) { int rangeEnd = inclusions.getRangeEnd(i); for (int c = inclusions.getRangeStart(i); c <= rangeEnd; ++c) { // TODO: Get a UCharacterProperty.IntProperty to avoid the property dispatch. int nextValue = UCharacter.getIntPropertyValue(c, property); if (value != nextValue) { if (value != nullValue) { mutableTrie.setRange(start, c - 1, value); } start = c; value = nextValue; } } } if (value != 0) { mutableTrie.setRange(start, 0x10FFFF, value); } CodePointTrie.Type type; if (property == UProperty.BIDI_CLASS || property == UProperty.GENERAL_CATEGORY) { type = CodePointTrie.Type.FAST; } else { type = CodePointTrie.Type.SMALL; } CodePointTrie.ValueWidth valueWidth; // TODO: UCharacterProperty.IntProperty int max = UCharacter.getIntPropertyMaxValue(property); if (max <= 0xff) { valueWidth = CodePointTrie.ValueWidth.BITS_8; } else if (max <= 0xffff) { valueWidth = CodePointTrie.ValueWidth.BITS_16; } else { valueWidth = CodePointTrie.ValueWidth.BITS_32; } return mutableTrie.buildImmutable(type, valueWidth); }