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

📄 wcsclientfactory.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
/**
 * 
 */
package com.esri.solutions.jitk.datasources.ogc.wcs;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.esri.solutions.jitk.datasources.exceptions.ClientNotFoundException;

/**
 * @author vlad2928
 *
 */
public class WCSClientFactory {

	private static Map<String, String> classNames = new HashMap<String, String>();
	
	static {
		classNames.put("1.1.1", WCSHTTPClientVersion111.class.getName());
		classNames.put("1.1.0", WCSHTTPClientVersion110.class.getName());
		classNames.put("1.0.0", WCSHTTPClientVersion100.class.getName());
	}
	
	public static synchronized Map<String, String> getClassNames() {
		return WCSClientFactory.classNames;
	}
	
	public static synchronized void setClassNames(Map<String, String> classNames) {
		WCSClientFactory.classNames = classNames;
	}

	public static synchronized void setClassName(String key, String className) {
		WCSClientFactory.classNames.put(key, className);
	}
	
	private static Object newInstance(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		if(className == null) {
			throw new ClassNotFoundException("Class name is null.");
		} else {
			Class<?> classObject = Class.forName(className);
			return classObject.newInstance();
		}
	}
	
	public static List<String> getSupportedVersions() {
		List<String> versions = new ArrayList<String>(classNames.keySet());
		Collections.sort(versions);
		Collections.reverse(versions);
		
		return versions;
	}
	
	public static boolean isSupportedVersion(String version) {
		return classNames.keySet().contains(version);
	}
	
	public static IWCSClient getInstance(String version) throws ClientNotFoundException {
		
		IWCSClient client = null;
		
		try {
			client = (IWCSClient)newInstance(classNames.get(version));
		
		} catch(ClassNotFoundException ex) {
			throw new ClientNotFoundException(ex.getMessage());
				
		} catch(IllegalAccessException ex) {
			throw new ClientNotFoundException(ex.getMessage());
				
		} catch(InstantiationException ex) {
			throw new ClientNotFoundException(ex.getMessage());
		}
		
		return client;
	}
}

⌨️ 快捷键说明

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