author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 10:07:05 +0200 | |
changeset 224 | 7a15b5efae6a |
parent 223 | 74232660cfff |
child 233 | 15d31c98a129 |
permissions | -rw-r--r-- |
jtulach@223 | 1 |
package org.apidesign.anagram.app.property; |
jtulach@221 | 2 |
|
jtulach@221 | 3 |
import org.apidesign.anagram.api.Scrambler; |
jtulach@221 | 4 |
import org.apidesign.anagram.api.WordLibrary; |
jtulach@221 | 5 |
import org.apidesign.anagram.gui.Anagrams; |
jtulach@221 | 6 |
|
jtulach@221 | 7 |
public final class AnagramsWithProperties extends Anagrams { |
jtulach@221 | 8 |
private WordLibrary wordLibrary; |
jtulach@221 | 9 |
private Scrambler scrambler; |
jtulach@221 | 10 |
|
jtulach@221 | 11 |
public AnagramsWithProperties() { |
jtulach@221 | 12 |
} |
jtulach@221 | 13 |
|
jtulach@221 | 14 |
@Override |
jtulach@221 | 15 |
protected WordLibrary getWordLibrary() { |
jtulach@221 | 16 |
try { |
jtulach@221 | 17 |
if (wordLibrary == null) { |
jtulach@224 | 18 |
String implName = System.getProperty( |
jtulach@224 | 19 |
"org.apidesign.anagram.api.WordLibrary" |
jtulach@224 | 20 |
); |
jtulach@222 | 21 |
assert implName != null; |
jtulach@222 | 22 |
Class<?> impl = Class.forName(implName); |
jtulach@222 | 23 |
wordLibrary = (WordLibrary)impl.newInstance(); |
jtulach@221 | 24 |
} |
jtulach@221 | 25 |
return wordLibrary; |
jtulach@221 | 26 |
} catch (Exception ex) { |
jtulach@221 | 27 |
throw new IllegalStateException(ex); |
jtulach@221 | 28 |
} |
jtulach@221 | 29 |
} |
jtulach@221 | 30 |
|
jtulach@221 | 31 |
@Override |
jtulach@221 | 32 |
protected Scrambler getScrambler() { |
jtulach@221 | 33 |
try { |
jtulach@221 | 34 |
if (scrambler == null) { |
jtulach@224 | 35 |
String implName = System.getProperty( |
jtulach@224 | 36 |
"org.apidesign.anagram.api.Scrambler" |
jtulach@224 | 37 |
); |
jtulach@222 | 38 |
assert implName != null; |
jtulach@222 | 39 |
Class<?> impl = Class.forName(implName); |
jtulach@222 | 40 |
scrambler = (Scrambler)impl.newInstance(); |
jtulach@221 | 41 |
} |
jtulach@221 | 42 |
return scrambler; |
jtulach@221 | 43 |
} catch (Exception ex) { |
jtulach@221 | 44 |
throw new IllegalStateException(ex); |
jtulach@221 | 45 |
} |
jtulach@221 | 46 |
} |
jtulach@221 | 47 |
} |