Coverage Report - org.kuali.rice.ken.util.CompoundEntityResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
CompoundEntityResolver
0%
0/18
0%
0/4
2
 
 1  
 /*
 2  
  * Copyright 2007-2008 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 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.kuali.rice.ken.util;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.log4j.Logger;
 23  
 import org.xml.sax.EntityResolver;
 24  
 import org.xml.sax.InputSource;
 25  
 import org.xml.sax.SAXException;
 26  
 
 27  
 /**
 28  
  * EntityResolver implementation that delegates in sequence to a list of EntityResolvers,
 29  
  * returning the first match.
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  */
 32  
 public class CompoundEntityResolver implements EntityResolver {
 33  0
     private static final Logger LOG = Logger.getLogger(CompoundEntityResolver.class);
 34  
 
 35  
     private final List<EntityResolver> resolvers;
 36  
 
 37  
     /**
 38  
      * Constructs a CompoundEntityResolver.java.
 39  
      * @param first
 40  
      * @param second
 41  
      */
 42  0
     public CompoundEntityResolver(EntityResolver first, EntityResolver second) {
 43  0
         this.resolvers = new ArrayList<EntityResolver>(2);
 44  0
         this.resolvers.add(first);
 45  0
         this.resolvers.add(second);
 46  0
     }
 47  
 
 48  
     /**
 49  
      * Constructs a CompoundEntityResolver.java.
 50  
      * @param resolvers
 51  
      */
 52  0
     public CompoundEntityResolver(List<EntityResolver> resolvers) {
 53  0
         this.resolvers = resolvers;
 54  0
     }
 55  
 
 56  
     /**
 57  
      * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
 58  
      */
 59  
     public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
 60  0
         LOG.debug("resolveEntity: " + publicId + " " + systemId);
 61  0
         for (EntityResolver resolver: resolvers) {
 62  0
             LOG.debug("Invoking entity resolver: " + resolver);
 63  0
             InputSource source = resolver.resolveEntity(publicId, systemId);
 64  0
             if (source != null) {
 65  0
                 LOG.debug("source != null: " + source);
 66  0
                 return source;
 67  
             }
 68  0
         }
 69  0
         return null;
 70  
     }
 71  
 }