| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.keystroke; |
| 17 |
|
|
| 18 |
|
import static org.fest.util.Strings.join; |
| 19 |
|
|
| 20 |
|
import java.util.*; |
| 21 |
|
|
| 22 |
|
import org.fest.swing.util.OSFamily; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
@link |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
@author |
| 29 |
|
|
| 30 |
|
@since |
| 31 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 32 |
|
class KeyStrokeMappingProviderNames implements Iterable<String> { |
| 33 |
|
|
| 34 |
|
private final String osFamily; |
| 35 |
|
private final String language; |
| 36 |
|
private final String country; |
| 37 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 38 |
30
|
static KeyStrokeMappingProviderNames generateNamesFrom(OSFamily osFamily, Locale locale) {... |
| 39 |
30
|
return new KeyStrokeMappingProviderNames(osFamily, locale); |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 42 |
30
|
private KeyStrokeMappingProviderNames(OSFamily osFamily, Locale locale) {... |
| 43 |
30
|
this.osFamily = osFamily.key(); |
| 44 |
30
|
language = locale.getLanguage(); |
| 45 |
30
|
country = locale.getCountry(); |
| 46 |
|
} |
| 47 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
32
|
public Iterator<String> iterator() {... |
| 49 |
32
|
return new NameIterator(osFamily, language, country); |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 7 |
Complexity Density: 0.39 |
|
| 52 |
|
private static class NameIterator implements Iterator<String> { |
| 53 |
|
private static final String PREFIX = KeyStrokeMappingProvider.class.getName(); |
| 54 |
|
|
| 55 |
|
private static final String DELIMETER = "_"; |
| 56 |
|
|
| 57 |
|
private final String osFamily; |
| 58 |
|
private final String language; |
| 59 |
|
private final String country; |
| 60 |
|
|
| 61 |
|
private State state; |
| 62 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 63 |
|
private enum State { |
| 64 |
|
FULL_NAME, WITHOUT_COUNTRY, LANGUAGE_ONLY, END |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 67 |
32
|
NameIterator(String osFamily, String language, String country) {... |
| 68 |
32
|
this.osFamily = osFamily; |
| 69 |
32
|
this.language = language; |
| 70 |
32
|
this.country = country; |
| 71 |
32
|
state = State.FULL_NAME; |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 74 |
90
|
public String next() {... |
| 75 |
90
|
switch(state) { |
| 76 |
31
|
case FULL_NAME: |
| 77 |
31
|
state = State.WITHOUT_COUNTRY; |
| 78 |
31
|
return join(PREFIX, osFamily, language, country).with(DELIMETER); |
| 79 |
29
|
case WITHOUT_COUNTRY: |
| 80 |
29
|
state = State.LANGUAGE_ONLY; |
| 81 |
29
|
return join(PREFIX, osFamily, language).with(DELIMETER); |
| 82 |
29
|
case LANGUAGE_ONLY: |
| 83 |
29
|
state = State.END; |
| 84 |
29
|
return join(PREFIX, language).with(DELIMETER); |
| 85 |
1
|
default: |
| 86 |
1
|
throw new NoSuchElementException("There are no more names to generate"); |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
88
|
public boolean hasNext() {... |
| 91 |
88
|
return state != State.END; |
| 92 |
|
} |
| 93 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
1
|
public void remove() {... |
| 95 |
1
|
throw new UnsupportedOperationException("This iterator does not support 'remove'"); |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
} |