SAXParsers.java
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing,
00013  * software distributed under the License is distributed on an
00014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00015  * KIND, either express or implied.  See the License for the
00016  * specific language governing permissions and limitations
00017  * under the License.    
00018  */
00019 package org.apache.xmlrpc.util;
00020 
00021 import javax.xml.parsers.ParserConfigurationException;
00022 import javax.xml.parsers.SAXParserFactory;
00023 
00024 import org.apache.xmlrpc.XmlRpcException;
00025 import org.xml.sax.SAXException;
00026 import org.xml.sax.XMLReader;
00027 
00028 
00031 public class SAXParsers {
00032         private static SAXParserFactory spf;
00033         static {
00034                 spf = SAXParserFactory.newInstance();
00035                 spf.setNamespaceAware(true);
00036                 spf.setValidating(false);
00037         }
00038 
00041         public static XMLReader newXMLReader() throws XmlRpcException {
00042                 try {
00043                         return spf.newSAXParser().getXMLReader();
00044                 } catch (ParserConfigurationException e) {
00045                         throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e);
00046                 } catch (SAXException e) {
00047                         throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e);
00048                 }
00049         }
00050 
00055         public static SAXParserFactory getSAXParserFactory() {
00056             return spf;
00057         }
00058 
00063         public static void setSAXParserFactory(SAXParserFactory pFactory) {
00064         spf = pFactory;
00065     }
00066 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49