本文整理汇总了Java中com.ibm.icu.lang.UCharacter.isWhitespace方法的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.isWhitespace方法的具体用法?Java UCharacter.isWhitespace怎么用?Java UCharacter.isWhitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.lang.UCharacter
的用法示例。
在下文中一共展示了UCharacter.isWhitespace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readNextTag
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
private String readNextTag() {
int c = '\0';
while (!atTag) {
c = readChar();
if (c == '<' || c == -1) {
if (c == '<') {
atTag = true;
}
break;
}
if (!UCharacter.isWhitespace(c)) {
System.err.println("Unexpected non-whitespace character "
+ Integer.toHexString(c));
break;
}
}
if (atTag) {
atTag = false;
StringBuilder sb = new StringBuilder();
while (true) {
c = readChar();
if (c == '>' || c == -1) {
break;
}
sb.append((char) c);
}
// System.err.println("read tag: '" + sb.toString() + "'");
return sb.toString();
}
return null;
}
示例2: findSafeEnd
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Returns the last unambiguous break position in the text.
*
* @return position of character, or -1 if one does not exist
*/
private int findSafeEnd() {
for (int i = length - 1; i >= 0; i--) {
if (UCharacter.isWhitespace(buffer[i])) {
return i + 1;
}
}
return -1;
}
示例3: findSafeEnd
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Returns the last unambiguous break position in the text.
*
* @return position of character, or -1 if one does not exist
*/
private int findSafeEnd() {
for (int i = length - 1; i >= 0; i--)
if (UCharacter.isWhitespace(buffer[i]))
return i + 1;
return -1;
}
示例4: readData
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
private String readData() {
StringBuilder sb = new StringBuilder();
boolean inWhitespace = false;
// boolean inAmp = false;
while (true) {
int c = readChar();
if (c == -1 || c == '<') {
atTag = c == '<';
break;
}
if (c == '&') {
c = readChar();
if (c == '#') {
StringBuilder numBuf = new StringBuilder();
int radix = 10;
c = readChar();
if (c == 'x') {
radix = 16;
c = readChar();
}
while (c != ';' && c != -1) {
numBuf.append((char) c);
c = readChar();
}
try {
int num = Integer.parseInt(numBuf.toString(), radix);
c = (char) num;
} catch (NumberFormatException ex) {
System.err.println("numbuf: " + numBuf.toString()
+ " radix: " + radix);
throw ex;
}
} else {
StringBuilder charBuf = new StringBuilder();
while (c != ';' && c != -1) {
charBuf.append((char) c);
c = readChar();
}
String charName = charBuf.toString();
if (charName.equals("lt")) {
c = '<';
} else if (charName.equals("gt")) {
c = '>';
} else if (charName.equals("quot")) {
c = '"';
} else if (charName.equals("apos")) {
c = '\'';
} else if (charName.equals("amp")) {
c = '&';
} else {
System.err.println("unrecognized character entity: '"
+ charName + "'");
continue;
}
}
}
if (UCharacter.isWhitespace(c)) {
if (inWhitespace) {
continue;
}
c = ' ';
inWhitespace = true;
} else {
inWhitespace = false;
}
sb.append((char) c);
}
//System.err.println("read data: '" + sb.toString() + "'");
return sb.toString();
}
示例5: normalize
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
public static String normalize(String str) {
if (str == null) {
return null;
}
StringBuilder sb = null;
boolean inWhitespace = false;
char c = '\0';
boolean special = false;
for (int i = 0; i < str.length(); ++i) {
c = str.charAt(i);
if (UCharacter.isWhitespace(c)) {
if (sb == null && (inWhitespace || c != ' ')) {
sb = new StringBuilder(str.substring(0, i));
}
if (inWhitespace) {
continue;
}
inWhitespace = true;
special = false;
c = ' ';
} else {
inWhitespace = false;
special = c == '<' || c == '&';
if (special && sb == null) {
sb = new StringBuilder(str.substring(0, i));
}
}
if (sb != null) {
if (special) {
sb.append(c == '<' ? "<" : "&");
} else {
sb.append(c);
}
}
}
if (sb != null) {
/*
* if (c == ' ') { int len = sb.length(); if (len == 0) { return
* " "; } if (len > 1 && c == ' ') { sb.deleteCharAt(len - 1); } }
*/
return sb.toString();
}
return str;
}
示例6: isWhitespace
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Indicates whether the specified code point is a whitespace character in
* Java.
*
* @param codePoint
* the code point to check.
* @return {@code true} if the supplied {@code c} is a whitespace character
* in Java; {@code false} otherwise.
*/
public static boolean isWhitespace(int codePoint) {
//FIXME depends on ICU when the codePoint is '\u2007'
return UCharacter.isWhitespace(codePoint);
}
示例7: isWhitespace
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Answers whether the character is a whitespace character in Java.
*
* @param codePoint
* the character, including supplementary characters
* @return true if the supplied <code>c</code> is a whitespace character
* in Java, otherwise false.
*/
public static boolean isWhitespace(int codePoint) {
//FIXME depends on ICU when the codePoint is '\u2007'
return UCharacter.isWhitespace(codePoint);
}