Java Code Examples for com.ibm.icu.lang.UProperty#INT_START
The following examples show how to use
com.ibm.icu.lang.UProperty#INT_START .
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: UCharacterProperty.java From fitnotifications with Apache License 2.0 | 5 votes |
public int getIntPropertyValue(int c, int which) { if(which<UProperty.INT_START) { if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) { return binProps[which].contains(c) ? 1 : 0; } } else if(which<UProperty.INT_LIMIT) { return intProps[which-UProperty.INT_START].getValue(c); } else if (which == UProperty.GENERAL_CATEGORY_MASK) { return getMask(getType(c)); } return 0; // undefined }
Example 2
Source File: UCharacterProperty.java From fitnotifications with Apache License 2.0 | 5 votes |
public int getIntPropertyMaxValue(int which) { if(which<UProperty.INT_START) { if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) { return 1; // maximum TRUE for all binary properties } } else if(which<UProperty.INT_LIMIT) { return intProps[which-UProperty.INT_START].getMaxValue(which); } return -1; // undefined }
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: CharacterPropertiesImpl.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * Returns a mutable UnicodeSet -- do not modify! */ public static synchronized UnicodeSet getInclusionsForProperty(int prop) { if (UProperty.INT_START <= prop && prop < UProperty.INT_LIMIT) { return getIntPropInclusions(prop); } else { int src = UCharacterProperty.INSTANCE.getSource(prop); return getInclusionsForSource(src); } }
Example 5
Source File: UCharacterProperty.java From trekarta with GNU General Public License v3.0 | 5 votes |
public int getIntPropertyValue(int c, int which) { if(which<UProperty.INT_START) { if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) { return binProps[which].contains(c) ? 1 : 0; } } else if(which<UProperty.INT_LIMIT) { return intProps[which-UProperty.INT_START].getValue(c); } else if (which == UProperty.GENERAL_CATEGORY_MASK) { return getMask(getType(c)); } return 0; // undefined }
Example 6
Source File: UCharacterProperty.java From trekarta with GNU General Public License v3.0 | 5 votes |
public int getIntPropertyMaxValue(int which) { if(which<UProperty.INT_START) { if(UProperty.BINARY_START<=which && which<UProperty.BINARY_LIMIT) { return 1; // maximum TRUE for all binary properties } } else if(which<UProperty.INT_LIMIT) { return intProps[which-UProperty.INT_START].getMaxValue(which); } return -1; // undefined }
Example 7
Source File: UnicodeData.java From es6draft with MIT License | 5 votes |
static EnumProperty forId(int propertyId) { if ((propertyId >= UProperty.INT_START && propertyId < INT_PROPERTY_LIMIT) || propertyId == UProperty.GENERAL_CATEGORY_MASK || propertyId == UProperty.SCRIPT_EXTENSIONS) { if (propertyId == UProperty.GENERAL_CATEGORY) { return General_Category; } for (EnumProperty e : EnumProperty.values()) { if (e.propertyId == propertyId) { return e; } } } return null; }
Example 8
Source File: UnicodeDataTest.java From es6draft with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Test public void testLimits() { // integer valued properties for (int p = UProperty.INT_START; p < UProperty.INT_LIMIT; ++p) { int min = UCharacter.getIntPropertyMinValue(p); int max = UCharacter.getIntPropertyMaxValue(p); assertTrue(String.format("min=%d", min), min >= 0); assertTrue(String.format("min=%d, max=%d", min, max), min <= max); assertTrue(String.format("max=%d", max), max < 512); // BINARY_MASK in UEncoding } }
Example 9
Source File: UCharacterProperty.java From fitnotifications with Apache License 2.0 | 4 votes |
public final int getSource(int which) { if(which<UProperty.BINARY_START) { return SRC_NONE; /* undefined */ } else if(which<UProperty.BINARY_LIMIT) { return binProps[which].getSource(); } else if(which<UProperty.INT_START) { return SRC_NONE; /* undefined */ } else if(which<UProperty.INT_LIMIT) { return intProps[which-UProperty.INT_START].getSource(); } else if(which<UProperty.STRING_START) { switch(which) { case UProperty.GENERAL_CATEGORY_MASK: case UProperty.NUMERIC_VALUE: return SRC_CHAR; default: return SRC_NONE; } } else if(which<UProperty.STRING_LIMIT) { switch(which) { case UProperty.AGE: return SRC_PROPSVEC; case UProperty.BIDI_MIRRORING_GLYPH: return SRC_BIDI; case UProperty.CASE_FOLDING: case UProperty.LOWERCASE_MAPPING: case UProperty.SIMPLE_CASE_FOLDING: case UProperty.SIMPLE_LOWERCASE_MAPPING: case UProperty.SIMPLE_TITLECASE_MAPPING: case UProperty.SIMPLE_UPPERCASE_MAPPING: case UProperty.TITLECASE_MAPPING: case UProperty.UPPERCASE_MAPPING: return SRC_CASE; case UProperty.ISO_COMMENT: case UProperty.NAME: case UProperty.UNICODE_1_NAME: return SRC_NAMES; default: return SRC_NONE; } } else { switch(which) { case UProperty.SCRIPT_EXTENSIONS: return SRC_PROPSVEC; default: return SRC_NONE; /* undefined */ } } }
Example 10
Source File: UCharacterProperty.java From fitnotifications with Apache License 2.0 | 4 votes |
/** * Constructor * @exception IOException thrown when data reading fails or data corrupted */ private UCharacterProperty() throws IOException { // consistency check if(binProps.length!=UProperty.BINARY_LIMIT) { throw new ICUException("binProps.length!=UProperty.BINARY_LIMIT"); } if(intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)) { throw new ICUException("intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)"); } // jar access ByteBuffer bytes=ICUBinary.getRequiredData(DATA_FILE_NAME_); m_unicodeVersion_ = ICUBinary.readHeaderAndDataVersion(bytes, DATA_FORMAT, new IsAcceptable()); // Read or skip the 16 indexes. int propertyOffset = bytes.getInt(); /* exceptionOffset = */ bytes.getInt(); /* caseOffset = */ bytes.getInt(); int additionalOffset = bytes.getInt(); int additionalVectorsOffset = bytes.getInt(); m_additionalColumnsCount_ = bytes.getInt(); int scriptExtensionsOffset = bytes.getInt(); int reservedOffset7 = bytes.getInt(); /* reservedOffset8 = */ bytes.getInt(); /* dataTopOffset = */ bytes.getInt(); m_maxBlockScriptValue_ = bytes.getInt(); m_maxJTGValue_ = bytes.getInt(); ICUBinary.skipBytes(bytes, (16 - 12) << 2); // read the main properties trie m_trie_ = Trie2_16.createFromSerialized(bytes); int expectedTrieLength = (propertyOffset - 16) * 4; int trieLength = m_trie_.getSerializedLength(); if(trieLength > expectedTrieLength) { throw new IOException("uprops.icu: not enough bytes for main trie"); } // skip padding after trie bytes ICUBinary.skipBytes(bytes, expectedTrieLength - trieLength); // skip unused intervening data structures ICUBinary.skipBytes(bytes, (additionalOffset - propertyOffset) * 4); if(m_additionalColumnsCount_ > 0) { // reads the additional property block m_additionalTrie_ = Trie2_16.createFromSerialized(bytes); expectedTrieLength = (additionalVectorsOffset-additionalOffset)*4; trieLength = m_additionalTrie_.getSerializedLength(); if(trieLength > expectedTrieLength) { throw new IOException("uprops.icu: not enough bytes for additional-properties trie"); } // skip padding after trie bytes ICUBinary.skipBytes(bytes, expectedTrieLength - trieLength); // additional properties int size = scriptExtensionsOffset - additionalVectorsOffset; m_additionalVectors_ = ICUBinary.getInts(bytes, size, 0); } // Script_Extensions int numChars = (reservedOffset7 - scriptExtensionsOffset) * 2; if(numChars > 0) { m_scriptExtensions_ = ICUBinary.getChars(bytes, numChars, 0); } }
Example 11
Source File: UCharacterProperty.java From trekarta with GNU General Public License v3.0 | 4 votes |
final int getSource(int which) { if(which<UProperty.BINARY_START) { return SRC_NONE; /* undefined */ } else if(which<UProperty.BINARY_LIMIT) { return binProps[which].getSource(); } else if(which<UProperty.INT_START) { return SRC_NONE; /* undefined */ } else if(which<UProperty.INT_LIMIT) { return intProps[which-UProperty.INT_START].getSource(); } else if(which<UProperty.STRING_START) { switch(which) { case UProperty.GENERAL_CATEGORY_MASK: case UProperty.NUMERIC_VALUE: return SRC_CHAR; default: return SRC_NONE; } } else if(which<UProperty.STRING_LIMIT) { switch(which) { case UProperty.AGE: return SRC_PROPSVEC; case UProperty.BIDI_MIRRORING_GLYPH: return SRC_BIDI; case UProperty.CASE_FOLDING: case UProperty.LOWERCASE_MAPPING: case UProperty.SIMPLE_CASE_FOLDING: case UProperty.SIMPLE_LOWERCASE_MAPPING: case UProperty.SIMPLE_TITLECASE_MAPPING: case UProperty.SIMPLE_UPPERCASE_MAPPING: case UProperty.TITLECASE_MAPPING: case UProperty.UPPERCASE_MAPPING: return SRC_CASE; case UProperty.ISO_COMMENT: case UProperty.NAME: case UProperty.UNICODE_1_NAME: return SRC_NAMES; default: return SRC_NONE; } } else { switch(which) { case UProperty.SCRIPT_EXTENSIONS: return SRC_PROPSVEC; default: return SRC_NONE; /* undefined */ } } }
Example 12
Source File: UCharacterProperty.java From trekarta with GNU General Public License v3.0 | 4 votes |
/** * Constructor * @exception IOException thrown when data reading fails or data corrupted */ private UCharacterProperty() throws IOException { // consistency check if(binProps.length!=UProperty.BINARY_LIMIT) { throw new ICUException("binProps.length!=UProperty.BINARY_LIMIT"); } if(intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)) { throw new ICUException("intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)"); } // jar access ByteBuffer bytes=ICUBinary.getRequiredData(DATA_FILE_NAME_); m_unicodeVersion_ = ICUBinary.readHeaderAndDataVersion(bytes, DATA_FORMAT, new IsAcceptable()); // Read or skip the 16 indexes. int propertyOffset = bytes.getInt(); /* exceptionOffset = */ bytes.getInt(); /* caseOffset = */ bytes.getInt(); int additionalOffset = bytes.getInt(); int additionalVectorsOffset = bytes.getInt(); m_additionalColumnsCount_ = bytes.getInt(); int scriptExtensionsOffset = bytes.getInt(); int reservedOffset7 = bytes.getInt(); /* reservedOffset8 = */ bytes.getInt(); /* dataTopOffset = */ bytes.getInt(); m_maxBlockScriptValue_ = bytes.getInt(); m_maxJTGValue_ = bytes.getInt(); ICUBinary.skipBytes(bytes, (16 - 12) << 2); // read the main properties trie m_trie_ = Trie2_16.createFromSerialized(bytes); int expectedTrieLength = (propertyOffset - 16) * 4; int trieLength = m_trie_.getSerializedLength(); if(trieLength > expectedTrieLength) { throw new IOException("uprops.icu: not enough bytes for main trie"); } // skip padding after trie bytes ICUBinary.skipBytes(bytes, expectedTrieLength - trieLength); // skip unused intervening data structures ICUBinary.skipBytes(bytes, (additionalOffset - propertyOffset) * 4); if(m_additionalColumnsCount_ > 0) { // reads the additional property block m_additionalTrie_ = Trie2_16.createFromSerialized(bytes); expectedTrieLength = (additionalVectorsOffset-additionalOffset)*4; trieLength = m_additionalTrie_.getSerializedLength(); if(trieLength > expectedTrieLength) { throw new IOException("uprops.icu: not enough bytes for additional-properties trie"); } // skip padding after trie bytes ICUBinary.skipBytes(bytes, expectedTrieLength - trieLength); // additional properties int size = scriptExtensionsOffset - additionalVectorsOffset; m_additionalVectors_ = ICUBinary.getInts(bytes, size, 0); } // Script_Extensions int numChars = (reservedOffset7 - scriptExtensionsOffset) * 2; if(numChars > 0) { m_scriptExtensions_ = ICUBinary.getChars(bytes, numChars, 0); } }