//# 0 errors, 56 messages
//#
/*
    //#VelocityRendererFactory.java:1:1: class: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * 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.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.rendering.velocity;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.pojos.Template;
import org.apache.roller.weblogger.ui.rendering.Renderer;
import org.apache.roller.weblogger.ui.rendering.RendererFactory;


/**
 * RendererFactory for Velocity, creates VelocityRenderers.
 */
public class VelocityRendererFactory implements RendererFactory {
    //#VelocityRendererFactory.java:31: method: void org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory.org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory()
    //#VelocityRendererFactory.java:31: end of method: void org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory.org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory()
    
    private static Log log = LogFactory.getLog(VelocityRendererFactory.class);
    //#VelocityRendererFactory.java:33: method: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory.org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init
    //#VelocityRendererFactory.java:33: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory
    //#    method: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/velocity/VelocityRendererFactory]
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init): __Dispatch_Table.getRenderer(Lorg/apache/roller/weblogger/pojos/Template;)Lorg/apache/roller/weblogger/ui/rendering/Renderer;
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init): log
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/velocity/VelocityRendererFactory] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init): __Dispatch_Table.getRenderer(Lorg/apache/roller/weblogger/pojos/Template;)Lorg/apache/roller/weblogger/ui/rendering/Renderer; == &getRenderer
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init): init'ed(log)
    //#VelocityRendererFactory.java:33: end of method: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory.org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory__static_init
    
    
    public Renderer getRenderer(Template template) {
        
        Renderer renderer = null;
    //#VelocityRendererFactory.java:38: method: Renderer org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory.getRenderer(Template)
    //#input(Renderer getRenderer(Template)): " due to ["._tainted
    //#input(Renderer getRenderer(Template)): "Error creating renderer for "._tainted
    //#input(Renderer getRenderer(Template)): "Unknown exception creatting renderer for "._tainted
    //#input(Renderer getRenderer(Template)): "]"._tainted
    //#input(Renderer getRenderer(Template)): org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.velocityEngine
    //#input(Renderer getRenderer(Template)): template
    //#output(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1) num objects
    //#output(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).__Tag
    //#output(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).parseException
    //#output(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).renderTemplate
    //#output(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).velocityDecorator
    //#output(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).velocityTemplate
    //#output(Renderer getRenderer(Template)): return_value
    //#new obj(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1)
    //#pre[3] (Renderer getRenderer(Template)): template != null
    //#pre[1] (Renderer getRenderer(Template)): (soft) org/apache/roller/weblogger/ui/rendering/velocity/RollerVelocity.velocityEngine != null
    //#post(Renderer getRenderer(Template)): return_value in Addr_Set{null,&new VelocityRenderer(getRenderer#1)}
    //#post(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1) num objects <= 1
    //#post(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).__Tag == org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer
    //#post(Renderer getRenderer(Template)): init'ed(new VelocityRenderer(getRenderer#1).parseException)
    //#post(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).renderTemplate == template
    //#post(Renderer getRenderer(Template)): new VelocityRenderer(getRenderer#1).renderTemplate != null
    //#post(Renderer getRenderer(Template)): init'ed(new VelocityRenderer(getRenderer#1).velocityDecorator)
    //#post(Renderer getRenderer(Template)): init'ed(new VelocityRenderer(getRenderer#1).velocityTemplate)
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.roller.weblogger.pojos.Template:getId
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.velocity.app.VelocityEngine:getTemplate
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.roller.weblogger.pojos.ThemeTemplate:instanceof
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.roller.weblogger.pojos.ThemeTemplate:getDecorator
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.velocity.exception.ResourceNotFoundException:getMessage
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(Renderer getRenderer(Template)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#test_vector(Renderer getRenderer(Template)): java.lang.String:equals(...)@45: {0}, {1}
    //#test_vector(Renderer getRenderer(Template)): org.apache.roller.weblogger.pojos.Template:getId(...)@41: Inverse{null}, Addr_Set{null}
    //#test_vector(Renderer getRenderer(Template)): org.apache.roller.weblogger.pojos.Template:getTemplateLanguage(...)@41: Addr_Set{null}, Inverse{null}
        
        // nothing we can do with null values
        if(template.getTemplateLanguage() == null || template.getId() == null) {
    //#VelocityRendererFactory.java:41: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.Template:getTemplateLanguage()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory
    //#    method: Renderer getRenderer(Template)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.Template:getTemplateLanguage()
    //#VelocityRendererFactory.java:41: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.Template:getId()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory
    //#    method: Renderer getRenderer(Template)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.Template:getId()
            return null;
        }
        
        if("velocity".equals(template.getTemplateLanguage())) { 
    //#VelocityRendererFactory.java:45: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.Template:getTemplateLanguage()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory
    //#    method: Renderer getRenderer(Template)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.Template:getTemplateLanguage()
            
            // standard velocity template
            try {
               renderer = new VelocityRenderer(template);
            } catch(Exception ex) {
                // some kind of exception so we don't have a renderer
                // we do catching/logging in VelocityRenderer constructor
                return null;
            }            
            
        }
        
        return renderer;
    //#VelocityRendererFactory.java:58: end of method: Renderer org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory.getRenderer(Template)
    }
    
}
    //#VelocityRendererFactory.java:: end of class: org.apache.roller.weblogger.ui.rendering.velocity.VelocityRendererFactory
