comparison src/ch/ethz/ssh2/compression/CompressionFactory.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents 91a31873c42a
children 97da8c5fb40a
comparison
equal deleted inserted replaced
305:d2b303406d63 307:071eccdff8ea
17 this.compressorClass = compressorClass; 17 this.compressorClass = compressorClass;
18 } 18 }
19 } 19 }
20 20
21 private static final List<CompressorEntry> compressors 21 private static final List<CompressorEntry> compressors
22 = new ArrayList<CompressorEntry>(); 22 = new ArrayList<CompressorEntry>();
23 23
24 static { 24 static {
25 // Higher priority first 25 // Higher priority first
26 compressors.add(new CompressorEntry("none", null)); 26 compressors.add(new CompressorEntry("none", null));
27 } 27 }
28 28
29 public static String[] getDefaultCompressorList() { 29 public static String[] getDefaultCompressorList() {
30 String list[] = new String[compressors.size()]; 30 String list[] = new String[compressors.size()];
31 for(int i = 0; i < compressors.size(); i++) { 31
32 for (int i = 0; i < compressors.size(); i++) {
32 CompressorEntry ce = compressors.get(i); 33 CompressorEntry ce = compressors.get(i);
33 list[i] = ce.type; 34 list[i] = ce.type;
34 } 35 }
36
35 return list; 37 return list;
36 } 38 }
37 39
38 public static void checkCompressorList(String[] list) { 40 public static void checkCompressorList(String[] list) {
39 for(final String candidate : list) { 41 for (final String candidate : list) {
40 getEntry(candidate); 42 getEntry(candidate);
41 } 43 }
42 } 44 }
43 45
44 public static Compressor createCompressor(String type) { 46 public static Compressor createCompressor(String type) {
45 try { 47 try {
46 CompressorEntry ce = getEntry(type); 48 CompressorEntry ce = getEntry(type);
47 if(null == ce.compressorClass) { 49
50 if (null == ce.compressorClass) {
48 return null; 51 return null;
49 } 52 }
53
50 Class<?> cc = Class.forName(ce.compressorClass); 54 Class<?> cc = Class.forName(ce.compressorClass);
51 return (Compressor) cc.newInstance(); 55 return (Compressor) cc.newInstance();
52 } 56 }
53 catch(Exception e) { 57 catch (Exception e) {
54 throw new IllegalArgumentException("Cannot instantiate " + type); 58 throw new IllegalArgumentException("Cannot instantiate " + type);
55 } 59 }
56 } 60 }
57 61
58 private static CompressorEntry getEntry(String type) { 62 private static CompressorEntry getEntry(String type) {
59 for(CompressorEntry ce : compressors) { 63 for (CompressorEntry ce : compressors) {
60 if(ce.type.equals(type)) { 64 if (ce.type.equals(type)) {
61 return ce; 65 return ce;
62 } 66 }
63 } 67 }
68
64 throw new IllegalArgumentException("Unknown algorithm " + type); 69 throw new IllegalArgumentException("Unknown algorithm " + type);
65 } 70 }
66 } 71 }