Save This Page
Home » openjdk-7 » com.sun.xml.internal » xsom » impl » parser » [javadoc | source]
    1   /*
    2    * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   package com.sun.xml.internal.xsom.impl.parser;
   26   
   27   import com.sun.xml.internal.xsom.parser.XMLParser;
   28   import org.xml.sax.InputSource;
   29   import org.xml.sax.SAXException;
   30   import org.xml.sax.XMLReader;
   31   import org.xml.sax.helpers.XMLFilterImpl;
   32   import org.xml.sax.helpers.XMLReaderAdapter;
   33   
   34   import javax.xml.parsers.ParserConfigurationException;
   35   import javax.xml.parsers.SAXParser;
   36   import javax.xml.parsers.SAXParserFactory;
   37   import java.io.IOException;
   38   
   39   
   40   /**
   41    * {@link SAXParserFactory} implementation that ultimately
   42    * uses {@link XMLParser} to parse documents.
   43    *
   44    * @author
   45    *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
   46    */
   47   public class SAXParserFactoryAdaptor extends SAXParserFactory {
   48   
   49       private final XMLParser parser;
   50   
   51       public SAXParserFactoryAdaptor( XMLParser _parser ) {
   52           this.parser = _parser;
   53       }
   54   
   55       public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
   56           return new SAXParserImpl();
   57       }
   58   
   59       public void setFeature(String name, boolean value) {
   60           ;
   61       }
   62   
   63       public boolean getFeature(String name) {
   64           return false;
   65       }
   66   
   67       private class SAXParserImpl extends SAXParser
   68       {
   69           private final XMLReaderImpl reader = new XMLReaderImpl();
   70   
   71           /**
   72            * @deprecated
   73            */
   74           public org.xml.sax.Parser getParser() throws SAXException {
   75               return new XMLReaderAdapter(reader);
   76           }
   77   
   78           public XMLReader getXMLReader() throws SAXException {
   79               return reader;
   80           }
   81   
   82           public boolean isNamespaceAware() {
   83               return true;
   84           }
   85   
   86           public boolean isValidating() {
   87               return false;
   88           }
   89   
   90           public void setProperty(String name, Object value) {
   91           }
   92   
   93           public Object getProperty(String name) {
   94               return null;
   95           }
   96       }
   97   
   98       private class XMLReaderImpl extends XMLFilterImpl
   99       {
  100           public void parse(InputSource input) throws IOException, SAXException {
  101               parser.parse(input,this,this,this);
  102           }
  103   
  104           public void parse(String systemId) throws IOException, SAXException {
  105               parser.parse(new InputSource(systemId),this,this,this);
  106           }
  107       }
  108   }

Save This Page
Home » openjdk-7 » com.sun.xml.internal » xsom » impl » parser » [javadoc | source]