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


Java XMLChar.isValid方法代码示例

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


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

示例1: read

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
public int read(char[] cbuf, int off, int len) throws IOException {
  int n = in.read(cbuf, off, len);
  if (n != -1) {
    for (int i = 0; i < n; i++) {
      char c = cbuf[off + i];
      char value = c;
      if (!(XMLChar.isValid(c))) // fix invalid characters
        value = 'X';
      else if (lastBad && c == '<') { // fix mis-matched brackets
        if (i != n - 1 && cbuf[off + i + 1] != '/')
          value = 'X';
      }
      lastBad = (c == 65533);
      cbuf[off + i] = value;
    }
  }
  return n;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:19,代码来源:DmozParser.java

示例2: read

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
public int read(char[] cbuf, int off, int len)
  throws IOException {
  int n = in.read(cbuf, off, len);
  if (n != -1) {
    for (int i = 0; i < n; i++) {
      char c = cbuf[off+i];
      char value = c;
      if (!(XMLChar.isValid(c)))            // fix invalid characters
        value = 'X';
      else if (lastBad && c == '<') {       // fix mis-matched brackets
        if (i != n-1 && cbuf[off+i+1] != '/')
          value = 'X';
      }
      lastBad = (c == 65533);
      cbuf[off+i] = value;
    }
  }
  return n;
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:20,代码来源:DmozParser.java

示例3: charReference

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
void charReference(Chars data) throws SAXException{
    int cp = Integer.parseInt(data.toString(), radix);
    if(XMLChar.isValid(cp)){
        if(valueStarted)
            value.appendCodePoint(cp);
        else if(contentHandler!=null){
            char chars[] = Character.toChars(cp);
            contentHandler.characters(chars, 0, chars.length);
        }
    }else
        throw fatalError("invalid xml character");
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:13,代码来源:AsyncXMLReader.java

示例4: surrogates

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected void surrogates(int high, int low, boolean inContent) throws IOException{
    if (XMLChar.isHighSurrogate(high)) {
        if (!XMLChar.isLowSurrogate(low)) {
            //Invalid XML
            fatalError("The character '"+(char)low+"' is an invalid XML character"); 
        }
        else {
            int supplemental = XMLChar.supplemental((char)high, (char)low);
            if (!XMLChar.isValid(supplemental)) {
                //Invalid XML
                fatalError("The character '"+(char)supplemental+"' is an invalid XML character"); 
            }
            else {
                if (inContent && content().inCData) {
                    _printer.printText("]]>&#x");                        
                    _printer.printText(Integer.toHexString(supplemental));                        
                    _printer.printText(";<![CDATA[");
                }  
                else {
                    printHex(supplemental);
                }
            }
        }
    } else {
        fatalError("The character '"+(char)high+"' is an invalid XML character"); 
    }

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:29,代码来源:BaseMarkupSerializer.java

示例5: printEscaped

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected void printEscaped(String source) throws IOException {
    int length = source.length();
    for (int i = 0; i < length; ++i) {
        int ch = source.charAt(i);
        if (!XMLChar.isValid(ch)) {
            if (++i < length) {
                surrogates(ch, source.charAt(i), false);
            } else {
                fatalError("The character '" + (char) ch + "' is an invalid XML character");
            }
            continue;
        }
        // escape NL, CR, TAB
        if (ch == '\n' || ch == '\r' || ch == '\t') {
            printHex(ch);
        } else if (ch == '<') {
            _printer.printText("&lt;");
        } else if (ch == '&') {
            _printer.printText("&amp;");
        } else if (ch == '"') {
            _printer.printText("&quot;");
        } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) {
            _printer.printText((char) ch);
        } else {
            printHex(ch);
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:29,代码来源:XMLSerializer.java

示例6: escapeXml

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
public static String escapeXml(String s) {
    s = StringEscapeUtils.escapeXml(s);
    StringBuffer dest = new StringBuffer();
    char c;
    for (int i = 0; i < s.length(); i++) {
        c = s.charAt(i);
        if (XMLChar.isValid(c)) {
            dest.append(c);
        }
    }
    return dest.toString();
}
 
开发者ID:kiegroup,项目名称:jbpm-data-modeler,代码行数:13,代码来源:XMLNode.java

示例7: isValid

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private boolean isValid(char c) {
	return XMLChar.isValid(c);
}
 
开发者ID:NewTranx,项目名称:newtranx-utils,代码行数:4,代码来源:XmlFilterReader.java

示例8: printText

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected void printText( String text, boolean preserveSpace, boolean unescaped )
throws IOException {
    int index;
    char ch;
    int length = text.length();
    if ( preserveSpace ) {
        // Preserving spaces: the text must print exactly as it is,
        // without breaking when spaces appear in the text and without
        // consolidating spaces. If a line terminator is used, a line
        // break will occur.
        for ( index = 0 ; index < length ; ++index ) {
            ch = text.charAt( index );
            if (!XMLChar.isValid(ch)) {
                // check if it is surrogate
                if (++index <length) {
                    surrogates(ch, text.charAt(index), true);
                } else {
                    fatalError("The character '"+ch+"' is an invalid XML character"); 
                }
                continue;
            }
            if ( unescaped ) {
                _printer.printText( ch );
            } else
                printXMLChar( ch );
        }
    } else {
        // Not preserving spaces: print one part at a time, and
        // use spaces between parts to break them into different
        // lines. Spaces at beginning of line will be stripped
        // by printing mechanism. Line terminator is treated
        // no different than other text part.
        for ( index = 0 ; index < length ; ++index ) {
            ch = text.charAt( index );
            if (!XMLChar.isValid(ch)) {
                // check if it is surrogate
                if (++index <length) {
                    surrogates(ch, text.charAt(index), true);
                } else {
                    fatalError("The character '"+ch+"' is an invalid XML character"); 
                }
                continue;
            }

if ( unescaped )
                _printer.printText( ch );
            else
                printXMLChar( ch);
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:52,代码来源:XMLSerializer.java

示例9: isValid

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Returns true if the specified character is a valid XML character
 * as per the rules of XML 1.0.
 *
 * @param ch The character to check.
 */
protected boolean isValid(int ch) {
    return XMLChar.isValid(ch);
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:10,代码来源:XIncludeTextReader.java


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