当前位置: 首页>>代码示例>>Java>>正文


Java UCharacter.isWhitespace方法代码示例

本文整理汇总了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;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:33,代码来源:XMLRecordReader.java

示例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;
}
 
开发者ID:jprante,项目名称:elasticsearch-icu,代码行数:14,代码来源:IcuTokenizer.java

示例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;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:ICUTokenizer.java

示例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();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:72,代码来源:XMLRecordReader.java

示例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 == '<' ? "&lt;" : "&amp;");
            } 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;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:45,代码来源:XMLRecordWriter.java

示例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);
    
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:Character.java

示例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);
    
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:14,代码来源:Character.java


注:本文中的com.ibm.icu.lang.UCharacter.isWhitespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。