Coverage Report - org.apache.xmlrpc.parser.NodeParser
 
Classes in this File Line Coverage Branch Coverage Complexity
NodeParser
78% 
N/A 
1,667
 
 1  
 /*
 2  
  * Copyright 2003, 2004  The Apache Software Foundation
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.xmlrpc.parser;
 17  
 
 18  
 import javax.xml.parsers.DocumentBuilderFactory;
 19  
 import javax.xml.parsers.ParserConfigurationException;
 20  
 
 21  
 import org.apache.ws.commons.serialize.DOMBuilder;
 22  
 import org.apache.xmlrpc.serializer.NodeSerializer;
 23  
 import org.xml.sax.ContentHandler;
 24  
 import org.xml.sax.SAXException;
 25  
 
 26  
 
 27  
 /** A parser for DOM document.
 28  
  */
 29  17
 public class NodeParser extends ExtParser {
 30  1
         private static final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 31  8
         private final DOMBuilder builder = new DOMBuilder();
 32  
 
 33  
         protected String getTagName() {
 34  8
                 return NodeSerializer.DOM_TAG;
 35  
         }
 36  
 
 37  
         protected ContentHandler getExtHandler() throws SAXException {
 38  
                 try {
 39  8
                         builder.setTarget(dbf.newDocumentBuilder().newDocument());
 40  0
                 } catch (ParserConfigurationException e) {
 41  0
                         throw new SAXException(e);
 42  
                 }
 43  8
                 return builder;
 44  
         }
 45  
 
 46  
         public Object getResult() {
 47  8
                 return builder.getTarget();
 48  
         }
 49  
 }