Coverage Report - org.seasar.teeda.core.config.webapp.impl.WebappConfigBuilderImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
WebappConfigBuilderImpl
100%
8/8
N/A
1
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.config.webapp.impl;
 17  
 
 18  
 import java.io.InputStream;
 19  
 
 20  
 import javax.xml.parsers.SAXParser;
 21  
 
 22  
 import org.seasar.framework.util.SAXParserFactoryUtil;
 23  
 import org.seasar.framework.xml.SaxHandler;
 24  
 import org.seasar.framework.xml.SaxHandlerParser;
 25  
 import org.seasar.framework.xml.TagHandlerRule;
 26  
 import org.seasar.teeda.core.config.webapp.WebappConfigBuilder;
 27  
 import org.seasar.teeda.core.config.webapp.element.WebappConfig;
 28  
 import org.seasar.teeda.core.config.webapp.rule.WebappTagHandlerRule;
 29  
 
 30  
 /**
 31  
  * @author manhole
 32  
  */
 33  4
 public class WebappConfigBuilderImpl implements WebappConfigBuilder {
 34  
 
 35  1
     private static TagHandlerRule rule_ = new WebappTagHandlerRule();
 36  
 
 37  
     private static final String DTD_PATH = "javax/servlet/resources/web-app_2_3.dtd";
 38  
 
 39  
     private static final String PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
 40  
 
 41  
     public WebappConfig build(InputStream is, String path) {
 42  4
         SaxHandlerParser parser = createSaxHandlerParser();
 43  4
         return (WebappConfig) parser.parse(is);
 44  
     }
 45  
 
 46  
     private SaxHandlerParser createSaxHandlerParser() {
 47  4
         SAXParser saxParser = SAXParserFactoryUtil.newSAXParser();
 48  4
         SaxHandler handler = new SaxHandler(rule_);
 49  4
         handler.registerDtdPath(PUBLIC_ID, DTD_PATH);
 50  4
         return new SaxHandlerParser(handler, saxParser);
 51  
     }
 52  
 
 53  
 }