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


Java InputSource类代码示例

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


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

示例1: parse

import jdk.internal.org.xml.sax.InputSource; //导入依赖的package包/类
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.helpers.DefaultHandler}.
 *
 * @param is The InputSource containing the content to be parsed.
 * @param dh The SAX DefaultHandler to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, DefaultHandler dh)
    throws SAXException, IOException
{
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    XMLReader reader = this.getXMLReader();
    if (dh != null) {
        reader.setContentHandler(dh);
        reader.setEntityResolver(dh);
        reader.setErrorHandler(dh);
        reader.setDTDHandler(dh);
    }
    reader.parse(is);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:SAXParser.java

示例2: parse

import jdk.internal.org.xml.sax.InputSource; //导入依赖的package包/类
/**
 * Parse the content given {@link org.xml.sax.InputSource} as XML using the
 * specified {@link org.xml.sax.helpers.DefaultHandler}.
 *
 * @param is The InputSource containing the content to be parsed.
 * @param handler The SAX DefaultHandler to use.
 * @exception IOException If any IO errors occur.
 * @exception IllegalArgumentException If the InputSource or handler is
 * null.
 * @exception SAXException If the underlying parser throws a SAXException
 * while parsing.
 * @see org.xml.sax.helpers.DefaultHandler
 */
public void parse(InputSource is, DefaultHandler handler)
    throws SAXException, IOException
{
    if ((is == null) || (handler == null)) {
        throw new IllegalArgumentException("");
    }
    //              Set up the handler
    mHandCont = handler;
    mHandDtd = handler;
    mHandErr = handler;
    mHandEnt = handler;
    //              Set up the document
    mInp = new Input(BUFFSIZE_READER);
    mPh = PH_BEFORE_DOC;  // before parsing
    try {
        setinp(is);
    } catch (SAXException | IOException | RuntimeException saxe) {
        throw saxe;
    } catch (Exception e) {
        panic(e.toString());
    }
    parse();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:ParserSAX.java

示例3: pent

import jdk.internal.org.xml.sax.InputSource; //导入依赖的package包/类
/**
 * Resoves a parameter entity.
 *
 * This method resolves a parameter entity references. It is also reports
 * external entities to the application.
 *
 * @param flag The '-' instruct the method to do not set up surrounding
 * spaces [#4.4.8].
 * @exception Exception is parser specific exception form panic method.
 * @exception IOException
 */
@SuppressWarnings("fallthrough")
private void pent(char flag) throws Exception {
    char ch;
    int idx = mBuffIdx + 1;
    Input inp = null;
    String str = null;
    bappend('%');
    if (mPh != PH_DTD) // the DTD internal subset
    {
        return;         // Not Recognized [#4.4.1]
    }               //              Read entity name
    bname(false);
    str = new String(mBuff, idx + 2, mBuffIdx - idx - 1);
    if (getch() != ';') {
        panic(FAULT);
    }
    inp = mPEnt.get(str);
    //              Restore the buffer offset
    mBuffIdx = idx - 1;
    if (inp != null) {
        if (inp.chars == null) {
            //              External parameter entity
            InputSource is = resolveEnt(str, inp.pubid, inp.sysid);
            if (is != null) {
                if (flag != '-') {
                    bappend(' ');  // tail space
                }
                push(new Input(BUFFSIZE_READER));
                // BUG: there is no leading space! [#4.4.8]
                setinp(is);
                mInp.pubid = inp.pubid;
                mInp.sysid = inp.sysid;
            } else {
                //          Unresolved external parameter entity
                skippedEnt("%" + str);
            }
        } else {
            //              Internal parameter entity
            if (flag == '-') {
                //          No surrounding spaces
                inp.chIdx = 1;
            } else {
                //          Insert surrounding spaces
                bappend(' ');  // tail space
                inp.chIdx = 0;
            }
            push(inp);
        }
    } else {
        //          Unknown parameter entity
        skippedEnt("%" + str);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:65,代码来源:Parser.java

示例4: 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

示例5: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。