⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 templateenginemanager.java

📁 struts 2 核心包 的源码 有错误是难免的
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   TemplateEngineManager.java

package org.apache.struts2.components.template;

import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Container;
import java.util.*;

// Referenced classes of package org.apache.struts2.components.template:
//			TemplateEngine, Template

public class TemplateEngineManager
{
	class LazyEngineFactory
		implements EngineFactory
	{

		private String name;
		final TemplateEngineManager this$0;

		public TemplateEngine create()
		{
			TemplateEngine engine = (TemplateEngine)container.getInstance(org/apache/struts2/components/template/TemplateEngine, name);
			if (engine == null)
				throw new ConfigurationException((new StringBuilder()).append("Unable to locate template engine: ").append(name).toString());
			else
				return engine;
		}

		public LazyEngineFactory(String name)
		{
			this$0 = TemplateEngineManager.this;
			super();
			this.name = name;
		}
	}

	static interface EngineFactory
	{

		public abstract TemplateEngine create();
	}


	public static final String DEFAULT_TEMPLATE_TYPE_CONFIG_KEY = "struts.ui.templateSuffix";
	public static final String DEFAULT_TEMPLATE_TYPE = "ftl";
	Map templateEngines;
	Container container;
	String defaultTemplateType;

	public TemplateEngineManager()
	{
		templateEngines = new HashMap();
	}

	public void setDefaultTemplateType(String type)
	{
		defaultTemplateType = type;
	}

	public void setContainer(Container container)
	{
		this.container = container;
		Map map = new HashMap();
		Set prefixes = container.getInstanceNames(org/apache/struts2/components/template/TemplateEngine);
		String prefix;
		for (Iterator i$ = prefixes.iterator(); i$.hasNext(); map.put(prefix, new LazyEngineFactory(prefix)))
			prefix = (String)i$.next();

		templateEngines = Collections.unmodifiableMap(map);
	}

	public void registerTemplateEngine(String templateExtension, final TemplateEngine templateEngine)
	{
		templateEngines.put(templateExtension, new EngineFactory() {

			final TemplateEngine val$templateEngine;
			final TemplateEngineManager this$0;

			public TemplateEngine create()
			{
				return templateEngine;
			}

			
			{
				this$0 = TemplateEngineManager.this;
				templateEngine = templateengine;
				super();
			}
		});
	}

	public TemplateEngine getTemplateEngine(Template template, String templateTypeOverride)
	{
		String templateType = "ftl";
		String templateName = template.toString();
		if (templateName.indexOf(".") > 0)
			templateType = templateName.substring(templateName.indexOf(".") + 1);
		else
		if (templateTypeOverride != null && templateTypeOverride.length() > 0)
		{
			templateType = templateTypeOverride;
		} else
		{
			String type = defaultTemplateType;
			if (type != null)
				templateType = type;
		}
		return ((EngineFactory)templateEngines.get(templateType)).create();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -