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


Java XMLChar.isSpace方法代码示例

本文整理汇总了Java中org.apache.xerces.util.XMLChar.isSpace方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isSpace方法的具体用法?Java XMLChar.isSpace怎么用?Java XMLChar.isSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xerces.util.XMLChar的用法示例。


在下文中一共展示了XMLChar.isSpace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanCharReference

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private void scanCharReference() throws IOException {
	fStringBuffer2.clear();
	boolean hex = entityScanner.peekChar() == 'x';
	int ch = scanCharReferenceValue(fStringBuffer2, null);
	if (ch != -1) {
		int c = Integer.valueOf(fStringBuffer3.toString(), hex ? 16 : 10);
		if (c < 0x20 && !XMLChar.isSpace(c)) {
			return;
		}
		if (hex) {//
			appendCharacter("&x");
		} else {
			appendCharacter("&");
		}
		appendCharacter(fStringBuffer3.toString());
		appendCharacter(";");
	} else {
		appendCharacter("&amp;#");
		appendCharacter(fStringBuffer3.toString());
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:22,代码来源:TmxScanner.java

示例2: isWhitespace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private boolean isWhitespace(Chars data){
    char chars[] = data.array();
    int end = data.offset()+data.length();
    for(int i=data.offset(); i<end; i++){
        if(!XMLChar.isSpace(chars[i]))
            return false;
    }
    return true;
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:10,代码来源:AsyncXMLReader.java

示例3: isWhiteSpace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * @see javax.xml.stream.events.Characters#isWhiteSpace()
 */
public boolean isWhiteSpace() {
    final int length = fData != null ? fData.length() : 0;
    if (length == 0) {
        return false;
    }
    for (int i = 0; i < length; ++i) {
        if (!XMLChar.isSpace(fData.charAt(i))) {
            return false;
        }
    }
    return true; 
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:16,代码来源:CharactersImpl.java

示例4: normalizeWhitespace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Normalize whitespace in an XMLString converting all whitespace
 * characters to space characters.
 */
protected void normalizeWhitespace(XMLString value) {
    int end = value.offset + value.length;
    for (int i = value.offset; i < end; ++i) {
        int c = value.ch[i];
        if (XMLChar.isSpace(c)) {
            value.ch[i] = ' ';
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:14,代码来源:XML11DTDScannerImpl.java

示例5: isUnchangedByNormalization

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Checks whether this string would be unchanged by normalization.
 * 
 * @return -1 if the value would be unchanged by normalization,
 * otherwise the index of the first whitespace character which
 * would be transformed.
 */
protected int isUnchangedByNormalization(XMLString value) {
    int end = value.offset + value.length;
    for (int i = value.offset; i < end; ++i) {
        int c = value.ch[i];
        if (XMLChar.isSpace(c)) {
            return i - value.offset;
        }
    }
    return -1;
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:18,代码来源:XML11DTDScannerImpl.java

示例6: characters

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Character content.
 * 
 * @param text   The content.
 * @param augs   Additional information that may include infoset augmentations
 *               
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void characters(XMLString text, Augmentations augs) throws XNIException {
    // when it's not within xs:appinfo or xs:documentation
    if (fInnerAnnotationDepth == -1 ) {
        for (int i=text.offset; i<text.offset+text.length; i++) {
            // and there is a non-whitespace character
            if (!XMLChar.isSpace(text.ch[i])) {
                // the string we saw: starting from the first non-whitespace character.
                String txt = new String(text.ch, i, text.length+text.offset-i);
                // report an error
                fErrorReporter.reportError(fLocator, 
                        XSMessageFormatter.SCHEMA_DOMAIN,
                        "s4s-elt-character",
                        new Object[]{txt},
                        XMLErrorReporter.SEVERITY_ERROR);
                break;
            }
        }
        // don't call super.characters() when it's not within one of the 2
        // annotation elements: the traversers ignore them anyway. We can
        // save time/memory creating the text nodes.
    }
    // when it's within either of the 2 elements, characters are allowed
    // and we need to store them.
    else {
        schemaDOM.characters(text);
    }
    
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:38,代码来源:SchemaDOMParser.java

示例7: characterData

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
public boolean characterData(String data, Augmentations augs) {

        fSawText = fSawText || data.length() > 0;

        // REVISIT: this methods basically duplicates implementation of
        //          handleCharacters(). We should be able to reuse some code

        // if whitespace == -1 skip normalization, because it is a complexType
        // or a union type.
        if (fNormalizeData && fWhiteSpace != -1 && fWhiteSpace != XSSimpleType.WS_PRESERVE) {
            // normalize data
            normalizeWhitespace(data, fWhiteSpace == XSSimpleType.WS_COLLAPSE);
            fBuffer.append(fNormalizedStr.ch, fNormalizedStr.offset, fNormalizedStr.length);
        } else {
            if (fAppendBuffer)
                fBuffer.append(data);
        }

        // When it's a complex type with element-only content, we need to
        // find out whether the content contains any non-whitespace character.
        boolean allWhiteSpace = true;
        if (fCurrentType != null
            && fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
            XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType;
            if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) {
                // data outside of element content
                for (int i = 0; i < data.length(); i++) {
                    if (!XMLChar.isSpace(data.charAt(i))) {
                        allWhiteSpace = false;
                        fSawCharacters = true;
                        break;
                    }
                }
            }
        }

        return allWhiteSpace;
    }
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:39,代码来源:XMLSchemaValidator.java

示例8: handleCharacters

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
XMLString handleCharacters(XMLString text) {

        if (fSkipValidationDepth >= 0)
            return text;

        fSawText = fSawText || text.length > 0;

        // Note: data in EntityRef and CDATA is normalized as well
        // if whitespace == -1 skip normalization, because it is a complexType
        // or a union type.
        if (fNormalizeData && fWhiteSpace != -1 && fWhiteSpace != XSSimpleType.WS_PRESERVE) {
            // normalize data
            normalizeWhitespace(text, fWhiteSpace == XSSimpleType.WS_COLLAPSE);
            text = fNormalizedStr;
        }
        if (fAppendBuffer)
            fBuffer.append(text.ch, text.offset, text.length);

        // When it's a complex type with element-only content, we need to
        // find out whether the content contains any non-whitespace character.
        if (fCurrentType != null
            && fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
            XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType;
            if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) {
                // data outside of element content
                for (int i = text.offset; i < text.offset + text.length; i++) {
                    if (!XMLChar.isSpace(text.ch[i])) {
                        fSawCharacters = true;
                        break;
                    }
                }
            }
        }

        return text;
    }
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:37,代码来源:XMLSchemaValidator.java

示例9: normalizeWhitespace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private void normalizeWhitespace(String value, boolean collapse) {
    boolean skipSpace = collapse;
    char c;
    int size = value.length();

    // ensure the ch array is big enough
    if (fNormalizedStr.ch == null || fNormalizedStr.ch.length < size) {
        fNormalizedStr.ch = new char[size];
    }
    fNormalizedStr.offset = 0;
    fNormalizedStr.length = 0;

    for (int i = 0; i < size; i++) {
        c = value.charAt(i);
        if (XMLChar.isSpace(c)) {
            if (!skipSpace) {
                // take the first whitespace as a space and skip the others
                fNormalizedStr.ch[fNormalizedStr.length++] = ' ';
                skipSpace = collapse;
            }
        } else {
            fNormalizedStr.ch[fNormalizedStr.length++] = c;
            skipSpace = false;
        }
    }
    if (skipSpace) {
        if (fNormalizedStr.length != 0)
            // if we finished on a space trim it but also record it
            fNormalizedStr.length--;
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:32,代码来源:XMLSchemaValidator.java

示例10: fixupXPath

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** Fixup XPath expression. Avoid creating a new String if possible. */
private static String fixupXPath(String xpath) {
    
    final int end = xpath.length();
    int offset = 0;
    boolean whitespace = true;
    char c;
    
    // NOTE: We have to prefix the field XPath with "./" in
    //       order to handle selectors such as "@attr" that 
    //       select the attribute because the fields could be
    //       relative to the selector element. -Ac
    //       Unless xpath starts with a descendant node -Achille Fokoue
    //      ... or a / or a . - NG
    for (; offset < end; ++offset) {
        c = xpath.charAt(offset);
        if (whitespace) {
            if (!XMLChar.isSpace(c)) {
                if (c == '.' || c == '/') {
                    whitespace = false;
                }
                else if (c != '|') {
                    return fixupXPath2(xpath, offset, end);
                }
            }
        }
        else if (c == '|') {
            whitespace = true;
        }
    }
    return xpath;
    
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:34,代码来源:Field.java

示例11: fixupXPath2

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private static String fixupXPath2(String xpath, int offset, final int end) {

     StringBuffer buffer = new StringBuffer(end + 2);
     for (int i = 0; i < offset; ++i) {
         buffer.append(xpath.charAt(i));
     }
     buffer.append("./");
     
     boolean whitespace = false;
     char c;
     
     for (; offset < end; ++offset) {
         c = xpath.charAt(offset);
         if (whitespace) {
             if (!XMLChar.isSpace(c)) {
                 if (c == '.' || c == '/') {
                     whitespace = false;
                 }
                 else if (c != '|') {
                     buffer.append("./");
                     whitespace = false;
                 }
             }
         }
         else if (c == '|') {
             whitespace = true;
         }
         buffer.append(c);
     }
     return buffer.toString();
     
 }
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:33,代码来源:Field.java

示例12: normalizeWhitespace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Normalize whitespace in an XMLString converting all whitespace
 * characters to space characters.
 */
protected void normalizeWhitespace(XMLString value, int fromIndex) {
    int end = value.offset + value.length;
    for (int i = value.offset + fromIndex; i < end; ++i) {
        int c = value.ch[i];
        if (XMLChar.isSpace(c)) {
            value.ch[i] = ' ';
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:14,代码来源:XML11DocumentScannerImpl.java

示例13: checkWhitespace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Checks whether the string only contains white space characters.
 * 
 * @param value the text to check
 */
private void checkWhitespace(XMLString value) {
    int end = value.offset + value.length;
    for (int i = value.offset; i < end; ++i) {
        if (!XMLChar.isSpace(value.ch[i])) {
            reportFatalError("ContentIllegalAtTopLevel");
            return;
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:15,代码来源:XIncludeHandler.java

示例14: isTextAccept

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
public boolean isTextAccept(QName qname, XMLString content) {
	boolean spaces = true;
	for (int i = content.offset; i < content.offset + content.length; i++) {
		spaces = spaces &&  XMLChar.isSpace(content.ch[i]);
	}
	if (spaces) {
		return true;
	}
	return acceptText.containsSymbol(qname.rawname);
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:11,代码来源:TmxSchema.java

示例15: skipSpaces

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
boolean skipSpaces() throws IOException, TmxEndEntityException {
	if (entity.position == entity.count) {
		load(0);
	}
	int c = entity.ch[entity.position];
	if (XMLChar.isSpace(c)) {
		do {
			boolean finish = false;
			if (c == '\n' || c == '\r') {
				entity.lineNumber++;
				entity.columnNumber = 1;
				if (entity.position == entity.count - 1) {
					entity.ch[0] = (char) c;
					finish = load(1);
					if (!finish) {
						entity.position = 0;
						entity.startPosition = 0;
					}
				}
				if (c == '\r') {
					if (entity.ch[++entity.position] != '\n'){
						entity.position--;
					}
				}
			} else {
				entity.columnNumber++;
			}
			if (!finish) entity.position++;
			if (entity.position == entity.count) {
				load(0);
			}
		} while (XMLChar.isSpace(c = entity.ch[entity.position]));
		return true;
	}
	return false;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:37,代码来源:TmxEntityScanner2.java


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