Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  * either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
 package org.lastaflute.di.core.factory.dixml;
 
 import java.util.Map;
 
 

Author(s):
modified by jflute (originated in Seasar)
 
 
     public static final String PUBLIC_ID10 = "-//DBFLUTE//DTD LastaDi 1.0//EN";
     public static final String DTD_PATH10 = "org/lastaflute/di/lastadi10.dtd";
 
     protected DiXmlTagHandlerRule rule = new DiXmlTagHandlerRule();
     protected final Map<StringStringdtdMap = new HashMap<StringString>();
 
     public DiXmlLaContainerBuilder() {
         .put();
     }
 
     public void addDtd(final String publicIdfinal String systemId) {
         .put(publicIdsystemId);
     }
 
     public void clearDtd() {
         .clear();
     }
 
     public LaContainer build(String path) {
         return parse(nullpath);
     }
 
     public LaContainer include(LaContainer parentfinal String path) {
         final LaContainer child = parse(parentpath);
         parent.include(child);
         return child;
     }
 
     protected LaContainer parse(LaContainer parentString path) {
         final SaxHandlerParser parser = createSaxHandlerParser(parentpath);
         final InputStream is = findDiXmlInputStream(parentpath);
         try {
             return (LaContainerparser.parse(ispath);
         } catch (Throwable cause) { // contains NoSuchMethodError
             if (cause instanceof DiXmlParseFailureException) {
                 throw (DiXmlParseFailureExceptioncause;
             }
             throwDependencyXmlParseFailureException(parentpathcause);
             return null// unreachable
         } finally {
             LdiInputStreamUtil.close(is);
         }
     }
 
     protected void throwDependencyXmlParseFailureException(LaContainer parentString pathThrowable cause) {
         final LdiExceptionMessageBuilder br = new LdiExceptionMessageBuilder();
         br.addNotice("Failed to parse the dependency XML.");
         br.addItem("Dependency XML");
         br.addElement(path + (parent != null ? " included by " + parent.getPath() : ""));
         final String msg = br.buildExceptionMessage();
         throw new DiXmlParseFailureException(msgcause);
     }
 
     protected SaxHandlerParser createSaxHandlerParser(final LaContainer parentfinal String path) {
         final SAXParserFactory factory = LdiSAXParserFactoryUtil.newInstance();
         factory.setValidating(true);
         factory.setNamespaceAware(true);
         LdiSAXParserFactoryUtil.setXIncludeAware(factorytrue);
        final SAXParser saxParser = LdiSAXParserFactoryUtil.newSAXParser(factory);
        final SaxHandler handler = new SaxHandler();
        for (final Iterator<Entry<StringString>> it = .entrySet().iterator(); it.hasNext();) {
            final Entry<StringStringentry = (Entry<StringString>) it.next();
            final String publicId = entry.getKey();
            final String systemId = entry.getValue();
            handler.registerDtdPath(publicIdsystemId);
        }
        final TagHandlerContext ctx = handler.getTagHandlerContext();
        ctx.addParameter("parent"parent);
        ctx.addParameter("path"path);
        return new SaxHandlerParser(handlersaxParser);
    }
    // ===================================================================================
    //                                                                            Accessor
    //                                                                            ========
    public DiXmlTagHandlerRule getRule() {
        return ;
    }
    public void setRule(final DiXmlTagHandlerRule rule) {
        this. = rule;
    }
New to GrepCode? Check out our FAQ X