Java Code Examples for com.sun.org.apache.xerces.internal.util.XMLChar#isValid()
The following examples show how to use
com.sun.org.apache.xerces.internal.util.XMLChar#isValid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseMarkupSerializer.java From hottub with GNU General Public License v2.0 | 5 votes |
protected void surrogates(int high, int low) 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 (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"); } }
Example 2
Source File: BaseMarkupSerializer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected void surrogates(int high, int low) 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 (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"); } }
Example 3
Source File: XMLSerializer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '"') { _printer.printText("""); } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) { _printer.printText((char) ch); } else { printHex(ch); } } }
Example 4
Source File: XMLSerializer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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)); } 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("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '"') { _printer.printText("""); } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) { _printer.printText((char) ch); } else { printHex(ch); } } }
Example 5
Source File: BaseMarkupSerializer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected void surrogates(int high, int low) 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 (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"); } }
Example 6
Source File: BaseMarkupSerializer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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"); } }
Example 7
Source File: BaseMarkupSerializer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected void surrogates(int high, int low) 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 (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"); } }
Example 8
Source File: XMLSerializer.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
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)); } 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("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '"') { _printer.printText("""); } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) { _printer.printText((char) ch); } else { printHex(ch); } } }
Example 9
Source File: BaseMarkupSerializer.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
protected void surrogates(int high, int low) 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 (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"); } }
Example 10
Source File: XMLSerializer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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)); } else { fatalError("The character '"+(char)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)); } else { fatalError("The character '"+(char)ch+"' is an invalid XML character"); } continue; } if ( unescaped ) _printer.printText( ch ); else printXMLChar( ch); } } }
Example 11
Source File: XMLSerializer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
protected void printText( char[] chars, int start, int length, boolean preserveSpace, boolean unescaped ) throws IOException { int index; char ch; 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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)ch+"' is an invalid XML character"); } continue; } if ( unescaped ) _printer.printText( ch ); else printXMLChar( ch ); } } }
Example 12
Source File: XMLSerializer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected void printText( char[] chars, int start, int length, boolean preserveSpace, boolean unescaped ) throws IOException { int index; char ch; 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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)ch+"' is an invalid XML character"); } continue; } if ( unescaped ) _printer.printText( ch ); else printXMLChar( ch ); } } }
Example 13
Source File: XMLSerializer.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
protected void printText( char[] chars, int start, int length, boolean preserveSpace, boolean unescaped ) throws IOException { int index; char ch; 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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)ch+"' is an invalid XML character"); } continue; } if ( unescaped ) _printer.printText( ch ); else printXMLChar( ch ); } } }
Example 14
Source File: XMLSerializer.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
protected void printText( char[] chars, int start, int length, boolean preserveSpace, boolean unescaped ) throws IOException { int index; char ch; 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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)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. while ( length-- > 0 ) { ch = chars[start++]; if (!XMLChar.isValid(ch)) { // check if it is surrogate if ( length-- > 0 ) { surrogates(ch, chars[start++]); } else { fatalError("The character '"+(char)ch+"' is an invalid XML character"); } continue; } if ( unescaped ) _printer.printText( ch ); else printXMLChar( ch ); } } }
Example 15
Source File: XMLSerializer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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 ); } } } }
Example 16
Source File: XMLSerializer.java From JDKSourceCode1.8 with MIT License | 4 votes |
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)); } else { fatalError("The character '"+(char)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)); } else { fatalError("The character '"+(char)ch+"' is an invalid XML character"); } continue; } if ( unescaped ) _printer.printText( ch ); else printXMLChar( ch); } } }
Example 17
Source File: XIncludeTextReader.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * 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); }
Example 18
Source File: XIncludeTextReader.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * 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); }
Example 19
Source File: XIncludeTextReader.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * 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); }
Example 20
Source File: XIncludeTextReader.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * 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); }