A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / spelling / engine / DefaultPhoneticDistanceAlgorithm.java
index 2d758bb..cb95f37 100644 (file)
@@ -19,83 +19,86 @@ package net.sourceforge.phpdt.internal.ui.text.spelling.engine;
  * 
  * @since 3.0
  */
-public final class DefaultPhoneticDistanceAlgorithm implements IPhoneticDistanceAlgorithm {
+public final class DefaultPhoneticDistanceAlgorithm implements
+               IPhoneticDistanceAlgorithm {
 
        /** The change case cost */
-       public static final int COST_CASE= 10;
+       public static final int COST_CASE = 10;
 
        /** The insert character cost */
-       public static final int COST_INSERT= 95;
+       public static final int COST_INSERT = 95;
 
        /** The remove character cost */
-       public static final int COST_REMOVE= 95;
+       public static final int COST_REMOVE = 95;
 
        /** The substitute characters cost */
-       public static final int COST_SUBSTITUTE= 100;
+       public static final int COST_SUBSTITUTE = 100;
 
        /** The swap characters cost */
-       public static final int COST_SWAP= 90;
+       public static final int COST_SWAP = 90;
 
        /*
         * @see org.eclipse.spelling.done.IPhoneticDistanceAlgorithm#getDistance(java.lang.String,java.lang.String)
         */
        public final int getDistance(final String from, final String to) {
 
-               final char[] first= (" " + from).toCharArray(); //$NON-NLS-1$
-               final char[] second= (" " + to).toCharArray(); //$NON-NLS-1$
+               final char[] first = (" " + from).toCharArray(); //$NON-NLS-1$
+               final char[] second = (" " + to).toCharArray(); //$NON-NLS-1$
 
-               final int rows= first.length;
-               final int columns= second.length;
+               final int rows = first.length;
+               final int columns = second.length;
 
-               final int[][] metric= new int[rows][columns];
-               for (int column= 1; column < columns; column++)
-                       metric[0][column]= metric[0][column - 1] + COST_REMOVE;
+               final int[][] metric = new int[rows][columns];
+               for (int column = 1; column < columns; column++)
+                       metric[0][column] = metric[0][column - 1] + COST_REMOVE;
 
-               for (int row= 1; row < rows; row++)
-                       metric[row][0]= metric[row - 1][0] + COST_INSERT;
+               for (int row = 1; row < rows; row++)
+                       metric[row][0] = metric[row - 1][0] + COST_INSERT;
 
                char source, target;
 
-               int swap= Integer.MAX_VALUE;
-               int change= Integer.MAX_VALUE;
+               int swap = Integer.MAX_VALUE;
+               int change = Integer.MAX_VALUE;
 
                int minimum, diagonal, insert, remove;
-               for (int row= 1; row < rows; row++) {
+               for (int row = 1; row < rows; row++) {
 
-                       source= first[row];
-                       for (int column= 1; column < columns; column++) {
+                       source = first[row];
+                       for (int column = 1; column < columns; column++) {
 
-                               target= second[column];
-                               diagonal= metric[row - 1][column - 1];
+                               target = second[column];
+                               diagonal = metric[row - 1][column - 1];
 
                                if (source == target) {
-                                       metric[row][column]= diagonal;
+                                       metric[row][column] = diagonal;
                                        continue;
                                }
 
-                               change= Integer.MAX_VALUE;
-                               if (Character.toLowerCase(source) == Character.toLowerCase(target))
-                                       change= COST_CASE + diagonal;
+                               change = Integer.MAX_VALUE;
+                               if (Character.toLowerCase(source) == Character
+                                               .toLowerCase(target))
+                                       change = COST_CASE + diagonal;
 
-                               swap= Integer.MAX_VALUE;
-                               if (row != 1 && column != 1 && source == second[column - 1] && first[row - 1] == target)
-                                       swap= COST_SWAP + metric[row - 2][column - 2];
+                               swap = Integer.MAX_VALUE;
+                               if (row != 1 && column != 1 && source == second[column - 1]
+                                               && first[row - 1] == target)
+                                       swap = COST_SWAP + metric[row - 2][column - 2];
 
-                               minimum= COST_SUBSTITUTE + diagonal;
+                               minimum = COST_SUBSTITUTE + diagonal;
                                if (swap < minimum)
-                                       minimum= swap;
+                                       minimum = swap;
 
-                               remove= metric[row][column - 1];
+                               remove = metric[row][column - 1];
                                if (COST_REMOVE + remove < minimum)
-                                       minimum= COST_REMOVE + remove;
+                                       minimum = COST_REMOVE + remove;
 
-                               insert= metric[row - 1][column];
+                               insert = metric[row - 1][column];
                                if (COST_INSERT + insert < minimum)
-                                       minimum= COST_INSERT + insert;
+                                       minimum = COST_INSERT + insert;
                                if (change < minimum)
-                                       minimum= change;
+                                       minimum = change;
 
-                               metric[row][column]= minimum;
+                               metric[row][column] = minimum;
                        }
                }
                return metric[rows - 1][columns - 1];