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


Java XMLChar类代码示例

本文整理汇总了Java中com.sun.xml.internal.fastinfoset.org.apache.xerces.util.XMLChar的典型用法代码示例。如果您正苦于以下问题:Java XMLChar类的具体用法?Java XMLChar怎么用?Java XMLChar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XMLChar类属于com.sun.xml.internal.fastinfoset.org.apache.xerces.util包,在下文中一共展示了XMLChar类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeCharacterAsUtf8FourByte

import com.sun.xml.internal.fastinfoset.org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private void encodeCharacterAsUtf8FourByte(int c, char[] ch, int chpos, int chend, int bpos) throws IOException {
    if (chpos == chend) {
        throw new IOException("");
    }

    final char d = ch[chpos];
    if (!XMLChar.isLowSurrogate(d)) {
        throw new IOException("");
    }

    final int uc = (((c & 0x3ff) << 10) | (d & 0x3ff)) + 0x10000;
    if (uc < 0 || uc >= 0x200000) {
        throw new IOException("");
    }

    _encodingBuffer[bpos++] = (byte)(0xF0 | ((uc >> 18)));
    _encodingBuffer[bpos++] = (byte)(0x80 | ((uc >> 12) & 0x3F));
    _encodingBuffer[bpos++] = (byte)(0x80 | ((uc >> 6) & 0x3F));
    _encodingBuffer[bpos++] = (byte)(0x80 | (uc & 0x3F));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Encoder.java

示例2: checkWhiteSpace

import com.sun.xml.internal.fastinfoset.org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private void checkWhiteSpace(){
    //refer to xerces XMLChar
    if(!Util.isEmptyString(_text)){
        isSpace = true;
        for(int i=0;i<_text.length();i++){
            if(!XMLChar.isSpace(_text.charAt(i))){
                isSpace = false;
                break;
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:CharactersEvent.java

示例3: isWhiteSpace

import com.sun.xml.internal.fastinfoset.org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
 *  Returns true if the cursor points to a character data event that consists of all whitespace
 *  Application calling this method needs to cache the value and avoid calling this method again
 *  for the same event.
 * @return true if the cursor points to all whitespace, false otherwise
 */
public final boolean isWhiteSpace() {
    if(isCharacters() || (_eventType == CDATA)){
        char [] ch = this.getTextCharacters();
        int start = this.getTextStart();
        int length = this.getTextLength();
        for (int i = start; i < start + length; i++){
            if(!XMLChar.isSpace(ch[i])){
                return false;
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:StAXDocumentParser.java

示例4: encodeUTF8String

import com.sun.xml.internal.fastinfoset.org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
 * Encode a string using the UTF-8 encoding.
 *
 * @param ch the array of characters.
 * @param offset the offset into the array of characters.
 * @param length the length of characters.
 */
protected final int encodeUTF8String(char[] ch, int offset, int length) throws IOException {
    int bpos = 0;

    // Make sure buffer is large enough
    ensureEncodingBufferSizeForUtf8String(length);

    final int end = offset + length;
    int c;
    while (end != offset) {
        c = ch[offset++];
        if (c < 0x80) {
            // 1 byte, 7 bits
            _encodingBuffer[bpos++] = (byte) c;
        } else if (c < 0x800) {
            // 2 bytes, 11 bits
            _encodingBuffer[bpos++] =
                (byte) (0xC0 | (c >> 6));    // first 5
            _encodingBuffer[bpos++] =
                (byte) (0x80 | (c & 0x3F));  // second 6
        } else if (c <= '\uFFFF') {
            if (!XMLChar.isHighSurrogate(c) && !XMLChar.isLowSurrogate(c)) {
                // 3 bytes, 16 bits
                _encodingBuffer[bpos++] =
                    (byte) (0xE0 | (c >> 12));   // first 4
                _encodingBuffer[bpos++] =
                    (byte) (0x80 | ((c >> 6) & 0x3F));  // second 6
                _encodingBuffer[bpos++] =
                    (byte) (0x80 | (c & 0x3F));  // third 6
            } else {
                // 4 bytes, high and low surrogate
                encodeCharacterAsUtf8FourByte(c, ch, offset, end, bpos);
                bpos += 4;
                offset++;
            }
        }
    }

    return bpos;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:Encoder.java

示例5: isWhiteSpace

import com.sun.xml.internal.fastinfoset.org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
 * Check if character array contains characters that are all white space.
 *
 * @param ch the character array
 * @param start the starting character index into the array to check from
 * @param length the number of characters to check
 * @return true if all characters are white space, false otherwise
 */
public static boolean isWhiteSpace(final char[] ch, int start, final int length) {
    if (!XMLChar.isSpace(ch[start])) return false;

    final int end = start + length;
    while(++start < end && XMLChar.isSpace(ch[start]));

    return start == end;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:Encoder.java


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