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


Java InputSource.getEncoding方法代码示例

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


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

示例1: setinp

import jdk.internal.org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:Parser.java

示例2: setinp

import jdk.internal.org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:72,代码来源:Parser.java


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