本文整理汇总了Java中com.sun.xml.internal.fastinfoset.util.CharArrayIntMap.obtainIndex方法的典型用法代码示例。如果您正苦于以下问题:Java CharArrayIntMap.obtainIndex方法的具体用法?Java CharArrayIntMap.obtainIndex怎么用?Java CharArrayIntMap.obtainIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.xml.internal.fastinfoset.util.CharArrayIntMap
的用法示例。
在下文中一共展示了CharArrayIntMap.obtainIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeNonIdentifyingStringOnFirstBit
import com.sun.xml.internal.fastinfoset.util.CharArrayIntMap; //导入方法依赖的package包/类
/**
* Encode a non identifying string on the first bit of an octet.
* Implementation of clause C.14 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
*
* @param ch the array of characters.
* @param offset the offset into the array of characters.
* @param length the length of characters.
* @param map the vocabulary table of character arrays to indexes.
* @param addToTable true if the string should be added to the vocabulary
* table (if not already present in the table).
* @param clone true if the array of characters should be cloned if added
* to the vocabulary table.
*/
protected final void encodeNonIdentifyingStringOnFirstBit(char[] ch, int offset, int length, CharArrayIntMap map,
boolean addToTable, boolean clone) throws IOException {
if (length == 0) {
// C.26 an index (first bit '1') with seven '1' bits for an empty string
write(0xFF);
} else {
if (addToTable) {
// if char array could be added to table
boolean canAddCharacterContentToTable =
canAddCharacterContentToTable(length, map);
// obtain/get index
int index = canAddCharacterContentToTable ?
map.obtainIndex(ch, offset, length, clone) :
map.get(ch, offset, length);
if (index != KeyIntMap.NOT_PRESENT) {
// if char array is in table
encodeNonZeroIntegerOnSecondBitFirstBitOne(index);
} else if (canAddCharacterContentToTable) {
// if char array is not in table, but could be added
_b = EncodingConstants.NISTRING_ADD_TO_TABLE_FLAG |
_nonIdentifyingStringOnFirstBitCES;
encodeNonEmptyCharacterStringOnFifthBit(ch, offset, length);
} else {
// if char array is not in table and could not be added
_b = _nonIdentifyingStringOnFirstBitCES;
encodeNonEmptyCharacterStringOnFifthBit(ch, offset, length);
}
} else {
_b = _nonIdentifyingStringOnFirstBitCES;
encodeNonEmptyCharacterStringOnFifthBit(ch, offset, length);
}
}
}
示例2: encodeNonIdentifyingStringOnThirdBit
import com.sun.xml.internal.fastinfoset.util.CharArrayIntMap; //导入方法依赖的package包/类
/**
* Encode a non identifying string on the third bit of an octet.
* Implementation of clause C.15 of ITU-T Rec. X.891 | ISO/IEC 24824-1.
*
* @param ch the array of characters.
* @param offset the offset into the array of characters.
* @param length the length of characters.
* @param map the vocabulary table of character arrays to indexes.
* @param addToTable true if the array of characters should be added to the vocabulary
* table (if not already present in the table).
* @param clone true if the array of characters should be cloned if added
* to the vocabulary table.
*/
protected final void encodeNonIdentifyingStringOnThirdBit(char[] ch, int offset, int length,
CharArrayIntMap map, boolean addToTable, boolean clone) throws IOException {
// length cannot be zero since sequence of CIIs has to be > 0
if (addToTable) {
// if char array could be added to table
boolean canAddCharacterContentToTable =
canAddCharacterContentToTable(length, map);
// obtain/get index
int index = canAddCharacterContentToTable ?
map.obtainIndex(ch, offset, length, clone) :
map.get(ch, offset, length);
if (index != KeyIntMap.NOT_PRESENT) {
// if char array is in table
_b = EncodingConstants.CHARACTER_CHUNK | 0x20;
encodeNonZeroIntegerOnFourthBit(index);
} else if (canAddCharacterContentToTable) {
// if char array is not in table, but could be added
_b = EncodingConstants.CHARACTER_CHUNK_ADD_TO_TABLE_FLAG |
_nonIdentifyingStringOnThirdBitCES;
encodeNonEmptyCharacterStringOnSeventhBit(ch, offset, length);
} else {
// if char array is not in table and could not be added
_b = _nonIdentifyingStringOnThirdBitCES;
encodeNonEmptyCharacterStringOnSeventhBit(ch, offset, length);
}
} else {
// char array will not be added to map
_b = _nonIdentifyingStringOnThirdBitCES;
encodeNonEmptyCharacterStringOnSeventhBit(ch, offset, length);
}
}
示例3: addToTable
import com.sun.xml.internal.fastinfoset.util.CharArrayIntMap; //导入方法依赖的package包/类
private void addToTable(String s, CharArrayIntMap m) {
if (s.length() == 0) {
return;
}
char[] c = s.toCharArray();
m.obtainIndex(c, 0, c.length, false);
}