1.1 --- a/samples/componentinjection/anagram-modular/nbproject/project.xml Sat Jun 14 10:06:48 2008 +0200
1.2 +++ b/samples/componentinjection/anagram-modular/nbproject/project.xml Sat Jun 14 10:06:50 2008 +0200
1.3 @@ -18,7 +18,13 @@
1.4 <source-folder>
1.5 <label>src-word-static</label>
1.6 <type>java</type>
1.7 - <location>src-api</location>
1.8 + <location>src-word-static</location>
1.9 + <encoding>UTF-8</encoding>
1.10 + </source-folder>
1.11 + <source-folder>
1.12 + <label>src-scrambler-simple</label>
1.13 + <type>java</type>
1.14 + <location>src-scrambler-simple</location>
1.15 <encoding>UTF-8</encoding>
1.16 </source-folder>
1.17 <source-folder>
1.18 @@ -68,6 +74,10 @@
1.19 <label>src-word-static</label>
1.20 <location>src-word-static</location>
1.21 </source-folder>
1.22 + <source-folder style="packages">
1.23 + <label>src-scrambler-simple</label>
1.24 + <location>src-scrambler-simple</location>
1.25 + </source-folder>
1.26 <source-file>
1.27 <location>build.xml</location>
1.28 </source-file>
1.29 @@ -95,6 +105,12 @@
1.30 <source-level>1.5</source-level>
1.31 </compilation-unit>
1.32 <compilation-unit>
1.33 + <package-root>src-scrambler-simple</package-root>
1.34 + <classpath mode="compile">src-api</classpath>
1.35 + <built-to>build/scrambler-simple/classes</built-to>
1.36 + <source-level>1.5</source-level>
1.37 + </compilation-unit>
1.38 + <compilation-unit>
1.39 <package-root>src-test</package-root>
1.40 <classpath mode="compile">src-new-api:../libs/dist/junit-4.4.jar</classpath>
1.41 <source-level>1.5</source-level>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/samples/componentinjection/anagram-modular/src-scrambler-simple/org/apidesign/anagram/scramblersimple/SimpleScrambler.java Sat Jun 14 10:06:50 2008 +0200
2.3 @@ -0,0 +1,28 @@
2.4 +package org.apidesign.anagram.scramblersimple;
2.5 +
2.6 +import java.util.Random;
2.7 +import org.apidesign.anagram.api.Scrambler;
2.8 +
2.9 +public final class SimpleScrambler implements Scrambler {
2.10 + private static final Random random = new Random();
2.11 +
2.12 + public String scramble(String word) {
2.13 + for (;;) {
2.14 + int index1 = random.nextInt(word.length());
2.15 + int index2 = random.nextInt(word.length());
2.16 +
2.17 + if (index1 == index2) {
2.18 + continue;
2.19 + }
2.20 +
2.21 + char char1 = word.charAt(index1);
2.22 + char char2 = word.charAt(index2);
2.23 +
2.24 + StringBuilder sb = new StringBuilder(word);
2.25 + sb.setCharAt(index1, char2);
2.26 + sb.setCharAt(index2, char1);
2.27 + return sb.toString();
2.28 + }
2.29 + }
2.30 +
2.31 +}