本文整理汇总了Java中java.lang.Character.isSupplementaryCodePoint方法的典型用法代码示例。如果您正苦于以下问题:Java Character.isSupplementaryCodePoint方法的具体用法?Java Character.isSupplementaryCodePoint怎么用?Java Character.isSupplementaryCodePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Character
的用法示例。
在下文中一共展示了Character.isSupplementaryCodePoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nextContractChar
import java.lang.Character; //导入方法依赖的package包/类
/**
* Get the ordering priority of the next contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int nextContractChar(int ch)
{
// First get the ordering of this single character,
// which is always the first element in the list
Vector<EntryPair> list = ordering.getContractValues(ch);
EntryPair pair = list.firstElement();
int order = pair.value;
// find out the length of the longest contracting character sequence in the list.
// There's logic in the builder code to make sure the longest sequence is always
// the last.
pair = list.lastElement();
int maxLength = pair.entryName.length();
// (the Normalizer is cloned here so that the seeking we do in the next loop
// won't affect our real position in the text)
NormalizerBase tempText = (NormalizerBase)text.clone();
// extract the next maxLength characters in the string (we have to do this using the
// Normalizer to ensure that our offsets correspond to those the rest of the
// iterator is using) and store it in "fragment".
tempText.previous();
key.setLength(0);
int c = tempText.next();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.next();
}
String fragment = key.toString();
// now that we have that fragment, iterate through this list looking for the
// longest sequence that matches the characters in the actual text. (maxLength
// is used here to keep track of the length of the longest sequence)
// Upon exit from this loop, maxLength will contain the length of the matching
// sequence and order will contain the collation-element value corresponding
// to this sequence
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = list.elementAt(i);
if (!pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
// seek our current iteration position to the end of the matching sequence
// and return the appropriate collation-element value (if there was no matching
// sequence, we're already seeked to the right position and order already contains
// the correct collation-element value for the single character)
while (maxLength > 1) {
c = text.next();
maxLength -= Character.charCount(c);
}
return order;
}
示例2: prevContractChar
import java.lang.Character; //导入方法依赖的package包/类
/**
* Get the ordering priority of the previous contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int prevContractChar(int ch)
{
// This function is identical to nextContractChar(), except that we've
// switched things so that the next() and previous() calls on the Normalizer
// are switched and so that we skip entry pairs with the fwd flag turned on
// rather than off. Notice that we still use append() and startsWith() when
// working on the fragment. This is because the entry pairs that are used
// in reverse iteration have their names reversed already.
Vector<EntryPair> list = ordering.getContractValues(ch);
EntryPair pair = list.firstElement();
int order = pair.value;
pair = list.lastElement();
int maxLength = pair.entryName.length();
NormalizerBase tempText = (NormalizerBase)text.clone();
tempText.next();
key.setLength(0);
int c = tempText.previous();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.previous();
}
String fragment = key.toString();
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = list.elementAt(i);
if (pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
while (maxLength > 1) {
c = text.previous();
maxLength -= Character.charCount(c);
}
return order;
}
示例3: nextContractChar
import java.lang.Character; //导入方法依赖的package包/类
/**
* Get the ordering priority of the next contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int nextContractChar(int ch)
{
// First get the ordering of this single character,
// which is always the first element in the list
Vector list = ordering.getContractValues(ch);
EntryPair pair = (EntryPair)list.firstElement();
int order = pair.value;
// find out the length of the longest contracting character sequence in the list.
// There's logic in the builder code to make sure the longest sequence is always
// the last.
pair = (EntryPair)list.lastElement();
int maxLength = pair.entryName.length();
// (the Normalizer is cloned here so that the seeking we do in the next loop
// won't affect our real position in the text)
NormalizerBase tempText = (NormalizerBase)text.clone();
// extract the next maxLength characters in the string (we have to do this using the
// Normalizer to ensure that our offsets correspond to those the rest of the
// iterator is using) and store it in "fragment".
tempText.previous();
key.setLength(0);
int c = tempText.next();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.next();
}
String fragment = key.toString();
// now that we have that fragment, iterate through this list looking for the
// longest sequence that matches the characters in the actual text. (maxLength
// is used here to keep track of the length of the longest sequence)
// Upon exit from this loop, maxLength will contain the length of the matching
// sequence and order will contain the collation-element value corresponding
// to this sequence
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = (EntryPair)list.elementAt(i);
if (!pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
// seek our current iteration position to the end of the matching sequence
// and return the appropriate collation-element value (if there was no matching
// sequence, we're already seeked to the right position and order already contains
// the correct collation-element value for the single character)
while (maxLength > 1) {
c = text.next();
maxLength -= Character.charCount(c);
}
return order;
}
示例4: prevContractChar
import java.lang.Character; //导入方法依赖的package包/类
/**
* Get the ordering priority of the previous contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int prevContractChar(int ch)
{
// This function is identical to nextContractChar(), except that we've
// switched things so that the next() and previous() calls on the Normalizer
// are switched and so that we skip entry pairs with the fwd flag turned on
// rather than off. Notice that we still use append() and startsWith() when
// working on the fragment. This is because the entry pairs that are used
// in reverse iteration have their names reversed already.
Vector list = ordering.getContractValues(ch);
EntryPair pair = (EntryPair)list.firstElement();
int order = pair.value;
pair = (EntryPair)list.lastElement();
int maxLength = pair.entryName.length();
NormalizerBase tempText = (NormalizerBase)text.clone();
tempText.next();
key.setLength(0);
int c = tempText.previous();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.previous();
}
String fragment = key.toString();
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = (EntryPair)list.elementAt(i);
if (pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
while (maxLength > 1) {
c = text.previous();
maxLength -= Character.charCount(c);
}
return order;
}
示例5: nextContractChar
import java.lang.Character; //导入方法依赖的package包/类
/**
* Get the ordering priority of the next contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int nextContractChar(int ch)
{
// First get the ordering of this single character,
// which is always the first element in the list
Vector list = ordering.getContractValues(ch);
EntryPair pair = (EntryPair)list.firstElement();
int order = pair.value;
// find out the length of the longest contracting character sequence in the list.
// There's logic in the builder code to make sure the longest sequence is always
// the last.
pair = (EntryPair)list.lastElement();
int maxLength = pair.entryName.length();
// (the Normalizer is cloned here so that the seeking we do in the next loop
// won't affect our real position in the text)
NormalizerBase tempText = (NormalizerBase)text.clone();
// extract the next maxLength characters in the string (we have to do this using the
// Normalizer to ensure that our offsets correspond to those the rest of the
// iterator is using) and store it in "fragment".
tempText.previous();
key.setLength(0);
int c = tempText.next();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.next();
}
String fragment = key.toString();
// now that we have that fragment, iterate through this list looking for the
// longest sequence that matches the characters in the actual text. (maxLength
// is used here to keep track of the length of the longest sequence)
// Upon exit from this loop, maxLength will contain the length of the matching
// sequence and order will contain the collation-element value corresponding
// to this sequence
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = (EntryPair)list.elementAt(i);
if (!pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
// seek our current iteration position to the end of the matching sequence
// and return the appropriate collation-element value (if there was no matching
// sequence, we're already seeked to the right position and order already contains
// the correct collation-element value for the single character)
while (maxLength > 1) {
c = text.next();
maxLength -= Character.charCount(c);
}
return order;
}