📄 extensionloader.java.svn-base
字号:
/*
* ExtensionLoader.java
*
* Created on 23. Februar 2007, 16:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package kanjitori;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Pirx
*/
public class ExtensionLoader<Content> implements Loader<Content> {
private Map<String, Loader<Content>> map = new HashMap<String, Loader<Content>>();
/**
* Implements the MapLoader interface.
* @param mapFileName the FileName of the String
* @return the Map, or null (if no MapLoader was found for this extension)
*/
public Content load(String fileName) {
int index = fileName.lastIndexOf('.');
if (index != -1) {
String ext = fileName.substring(index + 1).toLowerCase();
Loader<Content> loader = map.get(ext);
if (loader != null) {
return loader.load(fileName);
}
}
return null;
}
/**
* Registers a MapLoader to be called with the given extension.
* @param ext The File extension
* @param loader The MapLoader
*/
public void register(String ext, Loader<Content> loader) {
map.put(ext.toLowerCase(), loader);
}
/**
* Returns the "known" extensions.
* @return A String list of all registered extensions (in lowercase)
*/
public String[] getRegisteredExtensions() {
String[] extensions = new String[map.size()];
int i = 0;
for (String s: map.keySet()) {
extensions[i++] = s;
}
return extensions;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -