⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlreaderadapter.java

📁 Rapla是一个灵活的多用户资源管理系统。它提供的一些功能有:日历GUI
💻 JAVA
字号:
/*---------------------------------------------------------------------------*
  | (C) 2006 Christopher Kohlhaas                                            |
  |                                                                          |
  | This program is free software; you can redistribute it and/or modify     |
  | it under the terms of the GNU General Public License as published by the |
  | Free Software Foundation. A copy of the license has been included with   |
  | these distribution in the COPYING file, if not go to www.fsf.org .       |
  |                                                                          |
  | As a special exception, you are granted the permissions to link this     |
  | program with every library, which license fulfills the Open Source       |
  | Definition as published by the Open Source Initiative (OSI).             |
  *--------------------------------------------------------------------------*/
package org.rapla.components.util.xml;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

final public class XMLReaderAdapter {
    /** Here you can set the xml-reader implementation that should be
        used.  The default implementation is the aelfred-parser from
        the saxon project: net.sf.saxon.aelfred.SAXDriver.
    */
    //public static String XML_READER_IMPL ="net.sf.saxon.aelfred.SAXDriver";
    public static String XML_READER_IMPL ="net.sf.saxon.aelfred.SAXDriver";

    private XMLReaderAdapter()
    {
    }
    
    private static ClassLoader getClassLoader() {
        return XMLReaderAdapter.class.getClassLoader();
    }

    public static void checkXMLSupport() throws ClassNotFoundException {
        try {
            getClassLoader().loadClass("javax.xml.parsers.SAXParserFactory");
        } catch (ClassNotFoundException ex) {
            throw new ClassNotFoundException
                ("Couldn't find SAX-XML-PARSER API: javax.xml.parsers"
                 + " You need java 1.4 or higher. For java-versions below 1.4 please download"
                 + " the saxon.jar from rapla.sourceforge.net"
                 + " and put it into the lib directory.");
        }
    }

    public static XMLReader createXMLReader(boolean validating) throws SAXException {
      try {
             SAXParserFactory spf;
              try {
                  spf =  new com.bluecast.xml.JAXPSAXParserFactory(); 
                  
              //    spf = (SAXParserFactory)     getClassLoader().loadClass(com.bluecast.xml.JAXPSAXParserFactory).newInstance(); 
             /*  XMLReader reader = null;
           
               reader = (XMLReader) getClassLoader().loadClass(XML_READER_IMPL).newInstance();
                reader.setFeature("http://xml.org/sax/features/validation", validating);
                return reader;*/
            } catch (Throwable ex) {
                System.err.println("Piccolo not found using standard parser.");
                spf =SAXParserFactory.newInstance();   
              }
            spf.setNamespaceAware(true);
            spf.setValidating(validating);
            return spf.newSAXParser().getXMLReader();
      
        } catch (Exception ex2) {
            throw new SAXException("Couldn't create XMLReader '"
                                   + XML_READER_IMPL +"' : " + ex2.getMessage());
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -