Coverage Report - org.simpleframework.xml.stream.ProviderFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
ProviderFactory
16%
1/6
N/A
5
 
 1  
 /*
 2  
  * ProviderFactory.java January 2010
 3  
  *
 4  
  * Copyright (C) 2010, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml.stream;
 20  
 
 21  
 /**
 22  
  * The <code>ProviderFactory</code> object is used to instantiate a
 23  
  * provider of XML parsing to the framework. This scans the classpath
 24  
  * for the classes required for StAX, if they are present then this 
 25  
  * is what will be used to process XML. If however StAX can not be
 26  
  * used then a DOM implementation is provided. A DOM provider as a
 27  
  * default suits most Java profiles as it is a very common parser.
 28  
  * 
 29  
  * @author Niall Gallagher
 30  
  * 
 31  
  * @see org.simpleframework.xml.stream.NodeBuilder
 32  
  */
 33  0
 final class ProviderFactory {
 34  
 
 35  
    /**
 36  
     * This is used to acquire the <code>Provider</code> to be used 
 37  
     * to process XML documents. The provider returned is determined
 38  
     * by scanning the classpath for StAX dependencies, if they are
 39  
     * available then the provider used is StAX otherwise it is DOM. 
 40  
     * Scanning the classpath in this manner ensures the most suitable
 41  
     * parser is used for the host platform.
 42  
     * 
 43  
     * @return this returns the provider that has been instantiate
 44  
     */
 45  
    public static Provider getInstance() {
 46  
       try {
 47  
          try {
 48  1
             return new StreamProvider();
 49  0
          } catch(Throwable e) {
 50  0
             return new PullProvider();
 51  
          }
 52  0
       } catch(Throwable e) {
 53  0
          return new DocumentProvider();
 54  
       }
 55  
    }
 56  
 }