public static ImageIcon getMiscIcon(String resourceName) { if (resourceName == null) throw new IllegalArgumentException("resourceName == null"); URL url = ResourceLoader.class.getResource(ResourceLoader.ICON_PATH + "/MISC/" + resourceName); if (url == null) url = getFallback(true); ImageIcon icon = new ImageIcon(url); return icon; } /** * getIcon method * @param name * @return standard icon */ public static ImageIcon getIcon(String name) { return getIcon(ResourceLoader.ICON_PATH, name, false); } /** * getSmallIcon method * @param name * @return small icon */ public static ImageIcon getSmallIcon(String name) { return getIcon(ResourceLoader.ICON_PATH, name, true); } /** * getIcon method * @param path * @param name * @param small * @return icon */ public static ImageIcon getIcon(String path, String name, boolean small) { URL url; if (small) url = ResourceLoader.class.getResource(path + "/16x16/" + name); else url = ResourceLoader.class.getResource(path + "/22x22/" + name); if (url == null) url = getFallback(small); ImageIcon icon = new ImageIcon(url); return icon; } /** * GetFallback method - returns correct size image-missing icon if other icon does not exist * @param small * @return icon */ private static URL getFallback(boolean small) { String path; String name; URL url; path = "org/columba/core/icons"; name = "image-missing.png"; if (small) url = ResourceLoader.class.getResource(path + "/16x16/" + name); else url = ResourceLoader.class.getResource(path + "/22x22/" + name); return url; } /** * getString method - gets i18n bundle name * @param resourceBundleName * @param resourceName * @return resource bundle */ public static final String getString(String resourceBundleName, String resourceName) { ResourceBundle bundle = null; String bundlePath = i18nPath + "." + resourceBundleName; try { bundle = ResourceBundle.getBundle(bundlePath, Locale.getDefault()); return bundle.getString(resourceName); } catch (MissingResourceException e) { // fall-back to global resource loader return GlobalResourceLoader.getString(null, resourceBundleName, resourceName); } }
public static ImageIcon getMiscIcon(String resourceName) { if (resourceName == null) throw new IllegalArgumentException("resourceName == null"); URL url = ResourceLoader.class.getResource(ResourceLoader.ICON_PATH + "/MISC/" + resourceName); if (url == null) url = getFallback(true); ImageIcon icon = new ImageIcon(url); return icon; } public static ImageIcon getIcon(String name) { return getIcon(ResourceLoader.ICON_PATH, name, false); } public static ImageIcon getSmallIcon(String name) { return getIcon(ResourceLoader.ICON_PATH, name, true); } public static ImageIcon getIcon(String path, String name, boolean small) { URL url; if (small) url = ResourceLoader.class.getResource(path + "/16x16/" + name); else url = ResourceLoader.class.getResource(path + "/22x22/" + name); if (url == null) url = getFallback(small); ImageIcon icon = new ImageIcon(url); return icon; } /** * @param small * @return */ private static URL getFallback(boolean small) { String path; String name; URL url; path = "/org/columba/core/icons"; name = "image-missing.png"; if (small) url = ResourceLoader.class.getResource(path + "/16x16/" + name); else url = ResourceLoader.class.getResource(path + "/22x22/" + name); return url; } public static final String getString(String resourceBundleName, String resourceName) { ResourceBundle bundle = null; String bundlePath = i18nPath + "." + resourceBundleName; try { bundle = ResourceBundle.getBundle(bundlePath, Locale.getDefault()); return bundle.getString(resourceName); } catch (MissingResourceException e) { // fall-back to global resource loader return GlobalResourceLoader.getString(null, resourceBundleName, resourceName); } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/resourceloader/ResourceLoader.java File path: /columba-1.4-src/plugins/org.columba.chat.altura/src/org/columba/chat/resourceloader/ResourceLoader.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public static ImageIcon getMiscIcon(String resourceName) {
1
public static ImageIcon getMiscIcon(String resourceName) {
2
		if (resourceName == null)
2
		if (resourceName == null)
3
			throw new IllegalArgumentException("resourceName == null");
3
			throw new IllegalArgumentException("resourceName == null");
4
		URL url = ResourceLoader.class.getResource(ResourceLoader.ICON_PATH
4
		URL url = ResourceLoader.class.getResource(ResourceLoader.ICON_PATH
5
				+ "/MISC/" 
5
 + "/MISC/"
6
+ resourceName);
6
				+ resourceName);
7
		if (url == null)
7
		if (url == null)
8
			url = getFallback(true);
8
			url = getFallback(true);
9
		ImageIcon icon = new ImageIcon(url);
9
		ImageIcon icon = new ImageIcon(url);
10
		return icon;
10
		return icon;
11
	}
11
	}
12
	/**
13
	 * getIcon method
14
	 * @param name
15
	 * @return standard icon
16
	 */
17
	public static ImageIcon getIcon(String name) {
12
	public static ImageIcon getIcon(String name) {
18
		return getIcon(ResourceLoader.ICON_PATH, name, false);
13
		return getIcon(ResourceLoader.ICON_PATH, name, false);
19
	}
14
	}
20
	/**
21
	 * getSmallIcon method
22
	 * @param name
23
	 * @return small icon
24
	 */
25
	public static ImageIcon getSmallIcon(String name) {
15
	public static ImageIcon getSmallIcon(String name) {
26
		return getIcon(ResourceLoader.ICON_PATH, name, true);
16
		return getIcon(ResourceLoader.ICON_PATH, name, true);
27
	}
17
	}
28
	/**
29
	 * getIcon method
30
	 * @param path
31
	 * @param name
32
	 * @param small
33
	 * @return icon
34
	 */
35
	public static ImageIcon getIcon(String path, String name, boolean small) {
18
	public static ImageIcon getIcon(String path, String name, boolean small) {
36
		URL url;
19
		URL url;
37
		if (small)
20
		if (small)
38
			url = ResourceLoader.class.getResource(path + "/16x16/" + name);
21
			url = ResourceLoader.class.getResource(path + "/16x16/" + name);
39
		else
22
		else
40
			url = ResourceLoader.class.getResource(path + "/22x22/" + name);
23
			url = ResourceLoader.class.getResource(path + "/22x22/" + name);
41
		if (url == null)
24
		if (url == null)
42
			url = getFallback(small);
25
			url = getFallback(small);
43
		ImageIcon icon = new ImageIcon(url);
26
		ImageIcon icon = new ImageIcon(url);
44
		return icon;
27
		return icon;
45
	}
28
	}
46
	/**
29
	/**
47
	 * GetFallback method - returns correct size image-missing icon if other icon does not exist
30
	
48
	 * @param small
31
 * @param small
49
	 * @return icon 
32
	 * @return
50
	 */
33
	 */
51
	private static URL getFallback(boolean small) {
34
	private static URL getFallback(boolean small) {
52
		String path;
35
		String path;
53
		String name;
36
		String name;
54
		URL url;
37
		URL url;
55
		path = "org/columba/core/icons";
38
		path = "/org/columba/core/icons";
56
		name = "image-missing.png";
39
		name = "image-missing.png";
57
		if (small)
40
		if (small)
58
			url = ResourceLoader.class.getResource(path + "/16x16/" + name);
41
			url = ResourceLoader.class.getResource(path + "/16x16/" + name);
59
		else
42
		else
60
			url = ResourceLoader.class.getResource(path + "/22x22/" + name);
43
			url = ResourceLoader.class.getResource(path + "/22x22/" + name);
61
		return url;
44
		return url;
62
	}
45
	}
63
	/**
64
	 * getString method - gets i18n bundle name
65
	 * @param resourceBundleName
66
	 * @param resourceName
67
	 * @return resource bundle
68
	 */
69
	public static final String getString(String resourceBundleName,
46
	public static final String getString(String resourceBundleName,
70
			String resourceName) {
47
			String resourceName) {
71
		ResourceBundle bundle = null;
48
		ResourceBundle bundle = null;
72
		String bundlePath = i18nPath + "." + resourceBundleName;
49
		String bundlePath = i18nPath + "." + resourceBundleName;
73
		try {
50
		try {
74
			bundle = ResourceBundle.getBundle(bundlePath, Locale.getDefault());
51
			bundle = ResourceBundle.getBundle(bundlePath, Locale.getDefault());
75
			return bundle.getString(resourceName);
52
			return bundle.getString(resourceName);
76
		} catch (MissingResourceException e) {
53
		} catch (MissingResourceException e) {
54
			
77
			// fall-back to global resource loader
55
			// fall-back to global resource loader
78
			return GlobalResourceLoader.getString(null, resourceBundleName,
56
			return GlobalResourceLoader.getString(null, resourceBundleName,
79
					resourceName);
57
					resourceName);
80
		}
58
		}
81
	}
59
	}
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0