Java Code Examples for jdk.internal.org.xml.sax.InputSource#getByteStream()

The following examples show how to use jdk.internal.org.xml.sax.InputSource#getByteStream() . 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: Parser.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 2
Source File: Parser.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 3
Source File: Parser.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 4
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 5
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 6
Source File: Parser.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            /**
             * [#4.3.3] requires BOM for UTF-16, however, it's not uncommon
             * that it may be missing. A mature technique exists in Xerces
             * to further check for possible UTF-16 encoding
             */
            if (reader == null) {
                reader = utf16(is.getByteStream());
            }

            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (!expenc.equals("UTF-8")) {
                    if (expenc.startsWith("UTF-16")) {
                        panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                    }
                    reader = enc(expenc, is.getByteStream());
                }
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 7
Source File: Parser.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            /**
             * [#4.3.3] requires BOM for UTF-16, however, it's not uncommon
             * that it may be missing. A mature technique exists in Xerces
             * to further check for possible UTF-16 encoding
             */
            if (reader == null) {
                reader = utf16(is.getByteStream());
            }

            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (!expenc.equals("UTF-8")) {
                    if (expenc.startsWith("UTF-16")) {
                        panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                    }
                    reader = enc(expenc, is.getByteStream());
                }
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 8
Source File: Parser.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 9
Source File: Parser.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 10
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 11
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 12
Source File: Parser.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 13
Source File: Parser.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}
 
Example 14
Source File: Parser.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets up a new input source on the top of the input stack. Note, the first
 * byte returned by the entity's byte stream has to be the first byte in the
 * entity. However, the parser does not expect the byte order mask in both
 * cases when encoding is provided by the input source.
 *
 * @param is A new input source to set up.
 * @exception IOException If any IO errors occur.
 * @exception Exception is parser specific exception form panic method.
 */
protected void setinp(InputSource is)
        throws Exception {
    Reader reader = null;
    mChIdx = 0;
    mChLen = 0;
    mChars = mInp.chars;
    mInp.src = null;
    if (mPh < PH_DOC_START) {
        mIsSAlone = false;  // default [#2.9]
    }
    mIsSAloneSet = false;
    if (is.getCharacterStream() != null) {
        //          Ignore encoding in the xml text decl.
        reader = is.getCharacterStream();
        xml(reader);
    } else if (is.getByteStream() != null) {
        String expenc;
        if (is.getEncoding() != null) {
            //              Ignore encoding in the xml text decl.
            expenc = is.getEncoding().toUpperCase();
            if (expenc.equals("UTF-16")) {
                reader = bom(is.getByteStream(), 'U');  // UTF-16 [#4.3.3]
            } else {
                reader = enc(expenc, is.getByteStream());
            }
            xml(reader);
        } else {
            //              Get encoding from BOM or the xml text decl.
            reader = bom(is.getByteStream(), ' ');
            if (reader == null) {
                //          Encoding is defined by the xml text decl.
                reader = enc("UTF-8", is.getByteStream());
                expenc = xml(reader);
                if (expenc.startsWith("UTF-16")) {
                    panic(FAULT);  // UTF-16 must have BOM [#4.3.3]
                }
                reader = enc(expenc, is.getByteStream());
            } else {
                //          Encoding is defined by the BOM.
                xml(reader);
            }
        }
    } else {
        //          There is no support for public/system identifiers.
        panic(FAULT);
    }
    mInp.src = reader;
    mInp.pubid = is.getPublicId();
    mInp.sysid = is.getSystemId();
}