• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SAXException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
public void load(Properties props, InputStream in)
    throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
    this.properties = props;

    try {
        SAXParser parser = new SAXParserImpl();
        parser.parse(in, this);
    } catch (SAXException saxe) {
        throw new InvalidPropertiesFormatException(saxe);
    }

    /**
     * String xmlVersion = propertiesElement.getAttribute("version"); if
     * (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
     * InvalidPropertiesFormatException( "Exported Properties file format
     * version " + xmlVersion + " is not supported. This java installation
     * can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
     * " may need to install a newer version of JDK.");
     */
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:PropertiesDefaultHandler.java


示例2: parse

import jdk.internal.org.xml.sax.SAXException; //导入依赖的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: parse

import jdk.internal.org.xml.sax.SAXException; //导入依赖的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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:SAXParser.java


示例4: parse

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

    //convert file to appropriate URI, f.toURI().toASCIIString()
    //converts the URI to string as per rule specified in
    //RFC 2396,
    InputSource input = new InputSource(f.toURI().toASCIIString());
    this.parse(input, dh);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:SAXParser.java


示例5: endElement

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:PropertiesDefaultHandler.java


示例6: bflash_ws

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Reports white space characters and empties the parser's buffer. This
 * method is called only if parser is going to return control to the main
 * loop. This means that this method may use parser buffer to report white
 * space without copeing characters to temporary buffer.
 */
protected void bflash_ws() throws SAXException {
    if (mBuffIdx >= 0) {
        // BUG: With additional info from DTD and xml:space attr [#2.10]
        // the following call can be supported:
        // mHandCont.ignorableWhitespace(mBuff, 0, (mBuffIdx + 1));

        //          Textual data has been read
        mHandCont.characters(mBuff, 0, (mBuffIdx + 1));
        mBuffIdx = -1;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ParserSAX.java


示例7: startElement

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:PropertiesDefaultHandler.java


示例8: bflash

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Reports characters and empties the parser's buffer. This method is called
 * only if parser is going to return control to the main loop. This means
 * that this method may use parser buffer to report white space without
 * copying characters to temporary buffer.
 */
protected void bflash() throws SAXException {
    if (mBuffIdx >= 0) {
        //          Textual data has been read
        mHandCont.characters(mBuff, 0, (mBuffIdx + 1));
        mBuffIdx = -1;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ParserSAX.java


示例9: panic

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Notifies the handler about fatal parsing error.
 *
 * @param msg The problem description message.
 */
protected void panic(String msg) throws SAXException {
    SAXParseException spe = new SAXParseException(msg, this);
    mHandErr.fatalError(spe);
    throw spe;  // [#1.2] fatal error definition
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ParserSAX.java


示例10: notationDecl

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void notationDecl(String name, String publicId, String systemId) throws SAXException {
    rootElm = name;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:PropertiesDefaultHandler.java


示例11: error

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void error(SAXParseException x) throws SAXException {
    throw x;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:PropertiesDefaultHandler.java


示例12: fatalError

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void fatalError(SAXParseException x) throws SAXException {
    throw x;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:PropertiesDefaultHandler.java


示例13: warning

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void warning(SAXParseException x) throws SAXException {
    throw x;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:PropertiesDefaultHandler.java


示例14: characters

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
    if (validEntry) {
        buf.append(ch, start, length);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:PropertiesDefaultHandler.java


示例15: parse

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Parse an XML document.
 *
 * <p>The application can use this method to instruct the XML reader to
 * begin parsing an XML document from any valid input source (a character
 * stream, a byte stream, or a URI).</p>
 *
 * <p>Applications may not invoke this method while a parse is in progress
 * (they should create a new XMLReader instead for each nested XML
 * document). Once a parse is complete, an application may reuse the same
 * XMLReader object, possibly with a different input source.</p>
 *
 * <p>During the parse, the XMLReader will provide information about the XML
 * document through the registered event handlers.</p>
 *
 * <p>This method is synchronous: it will not return until parsing has
 * ended. If a client application wants to terminate parsing early, it
 * should throw an exception.</p>
 *
 * @param is The input source for the top-level of the XML document.
 * @exception org.xml.sax.SAXException Any SAX exception, possibly wrapping
 * another exception.
 * @exception java.io.IOException An IO exception from the parser, possibly
 * from a byte stream or character stream supplied by the application.
 * @see org.xml.sax.InputSource
 * @see #parse(java.lang.String)
 * @see #setEntityResolver
 * @see #setDTDHandler
 * @see #setContentHandler
 * @see #setErrorHandler
 */
public void parse(InputSource is) throws IOException, SAXException {
    if (is == null) {
        throw new IllegalArgumentException("");
    }
    //              Set up the document
    mInp = new Input(BUFFSIZE_READER);
    mPh = PH_BEFORE_DOC;  // before parsing
    try {
        setinp(is);
    } catch (SAXException saxe) {
        throw saxe;
    } catch (IOException ioe) {
        throw ioe;
    } catch (RuntimeException rte) {
        throw rte;
    } catch (Exception e) {
        panic(e.toString());
    }
    parse();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:52,代码来源:ParserSAX.java


示例16: unparsedEntityDecl

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Receive notification of an unparsed entity declaration.
 *
 * <p>By default, do nothing.  Application writers may override this
 * method in a subclass to keep track of the unparsed entities
 * declared in a document.</p>
 *
 * @param name The entity name.
 * @param publicId The entity public identifier, or null if not
 *                 available.
 * @param systemId The entity system identifier.
 * @param notationName The name of the associated notation.
 * @exception org.xml.sax.SAXException Any SAX exception, possibly
 *            wrapping another exception.
 * @see org.xml.sax.DTDHandler#unparsedEntityDecl
 */
public void unparsedEntityDecl (String name, String publicId,
                                String systemId, String notationName)
    throws SAXException
{
    // no op
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:DefaultHandler.java


示例17: startElement

import jdk.internal.org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Receive notification of the start of an element.
 *
 * <p>By default, do nothing.  Application writers may override this
 * method in a subclass to take specific actions at the start of
 * each element (such as allocating a new tree node or writing
 * output to a file).</p>
 *
 * @param uri The Namespace URI, or the empty string if the
 *        element has no Namespace URI or if Namespace
 *        processing is not being performed.
 * @param localName The local name (without prefix), or the
 *        empty string if Namespace processing is not being
 *        performed.
 * @param qName The qualified name (with prefix), or the
 *        empty string if qualified names are not available.
 * @param attributes The attributes attached to the element.  If
 *        there are no attributes, it shall be an empty
 *        Attributes object.
 * @exception org.xml.sax.SAXException Any SAX exception, possibly
 *            wrapping another exception.
 * @see org.xml.sax.ContentHandler#startElement
 */
public void startElement (String uri, String localName,
                          String qName, Attributes attributes)
    throws SAXException
{
    // no op
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:DefaultHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpServer2类代码示例发布时间:2022-05-22
下一篇:
Java GetTransactionIdRequestProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap