package com.dth.slovo;

public class WordProcessor {
    /** Class
     * 
     */
    public WordProcessor(){}
    
    public String processWord(String word) {
        // Initialize StringBuilder and trim the string
        StringBuilder temp = new StringBuilder(word.trim());
        
        // If its empty, return null
        if (temp.length() == 0) return null;

        // Remove leading punctuation marks               
        while (temp.length() > 0 && !Character.isAlphabetic(temp.charAt(0))) {
            temp.deleteCharAt(0);
        }
        if (temp.length() == 0) return null;
        
        // Remove trailing punctuation marks  
        while (temp.length() > 0 && !Character.isAlphabetic(temp.charAt(temp.length() - 1))) {
            temp.deleteCharAt(temp.length() - 1);
        }
        if (temp.length() == 0) return null;
        
        // To lowercase
        for (int i = 0; i < temp.length(); i++) {
            char c = temp.charAt(i);
            temp.setCharAt(i, Character.toLowerCase(c));
        }
        
        return temp.toString();
    }
}

@@ -19,16 +19,616 @@
 ovo;%0D%0A%0D%0A
+/**%0D%0A * WordProcessor is a small class that normalizes the %7B@code String%7D%0D%0A * by altering it in numerous ways, so that the resulting %7B@code String%7D%0D%0A * will only contain a sequence of alphabetic characters.%0D%0A * %0D%0A * %3Cp%3EFor example, in the following code, strings %7Bcode %22a%22%7D, %7Bcode %22b%22%7D,%0D%0A * and %7Bcode %22c%22%7D will contain %22happy%22 in all cases.%0D%0A * %3Cblockquote%3E%0D%0A *     WordProcessor processor = new WordProcessor();%0D%0A *     String a = processor.processWord(%22 happy     %22);%0D%0A *     String b = processor.processWord(%22.happy!%22);%0D%0A *     String c = processor.processWord(%22 HaPPy!%22);%0D%0A * %3C/blockquote%3E%0D%0A */%0D%0A
 public c
@@ -653,75 +653,583 @@
  %7B%0D%0A
+%0D%0A
     /**
- Class%0D%0A     * %0D%0A     */%0D%0A    public WordProcessor()%7B%7D
+%0D%0A     * Processes the %7B@code String%7D by subjecting it to the%0D%0A     * following changes:%0D%0A     * %3Cul%3E%0D%0A     *     %3Cli%3E Removing leading and trailing white spaces%0D%0A     *     %3Cli%3E Removing leading and trailing punctuation marks%0D%0A     *     %3Cli%3E Converting to lowercase.%0D%0A     * %3C/ul%3E%0D%0A     * %0D%0A     * @param   word    the input %7B@code String%7D that will be processed.%0D%0A     * %0D%0A     * @return  the normalized %7B@code String%7D, if the input contained%0D%0A     *          at least one alphabetic character. Otherwise returns%0D%0A     *          an empty %7B@code String%7D.
 %0D%0A    
+ */
 %0D%0A  
@@ -1294,16 +1294,20 @@
 tialize 
+the 
 StringBu
@@ -1395,24 +1395,16 @@
 im());%0D%0A
-        
 %0D%0A      
@@ -1413,16 +1413,17 @@
 // If it
+'
 s empty,
@@ -1459,32 +1459,47 @@
 p.length() == 0)
+ %7B%0D%0A           
  return null;%0D%0A%0D
@@ -1496,16 +1496,27 @@
 n null;%0D
+%0A        %7D%0D
 %0A%0D%0A     
@@ -1719,32 +1719,47 @@
 p.length() == 0)
+ %7B%0D%0A           
  return null;%0D%0A 
@@ -1757,32 +1757,35 @@
  null;%0D%0A        
+%7D%0D%0A
 %0D%0A        // Rem
@@ -2007,16 +2007,31 @@
 () == 0)
+ %7B%0D%0A           
  return 
@@ -2037,32 +2037,35 @@
  null;%0D%0A        
+%7D%0D%0A
 %0D%0A        // To 
@@ -2130,46 +2130,8 @@
  %7B%0D%0A
-            char c = temp.charAt(i);%0D%0A
     
@@ -2178,17 +2178,30 @@
 werCase(
-c
+temp.charAt(i)
 ));%0D%0A   
@@ -2208,24 +2208,16 @@
      %7D%0D%0A
-        
 %0D%0A      

Add WordProcessor javadoc