Modified: 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/AtomList.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/AtomList.java?rev=1306388&r1=1306387&r2=1306388&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/AtomList.java
 (original)
+++ 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/AtomList.java
 Wed Mar 28 14:55:04 2012
@@ -1,194 +1,185 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.base.api.util;
 
-
 import java.util.Collection;
 import java.util.Iterator;
 
 import org.apache.stanbol.rules.base.api.RuleAtom;
 
-
 public class AtomList implements Collection<RuleAtom> {
 
-       private RuleAtom[] kReSRuleAtoms;
-       
-       public AtomList() {
-               
-       }
-
-       public boolean add(RuleAtom kReSRuleAtom) {
-               if(kReSRuleAtoms == null){
-                       kReSRuleAtoms = new RuleAtom[1];
-                       kReSRuleAtoms[0] = kReSRuleAtom;
-               }
-               else{
-                       RuleAtom[] semionRulesCopy = new 
RuleAtom[kReSRuleAtoms.length+1];
-                       System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 0, 
kReSRuleAtoms.length);
-                       semionRulesCopy[semionRulesCopy.length-1] = 
kReSRuleAtom;
-                       kReSRuleAtoms = semionRulesCopy;
-               }
-               return true;
-       }
-       
-       public boolean addToHead(RuleAtom kReSRuleAtom) {
-               if(kReSRuleAtoms == null){
-                       kReSRuleAtoms = new RuleAtom[1];
-                       kReSRuleAtoms[0] = kReSRuleAtom;
-               }
-               else{
-                       RuleAtom[] semionRulesCopy = new 
RuleAtom[kReSRuleAtoms.length+1];
-                       System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 1, 
kReSRuleAtoms.length);
-                       semionRulesCopy[0] = kReSRuleAtom;
-                       kReSRuleAtoms = semionRulesCopy;
-               }
-               return true;
-       }
-
-       public boolean addAll(Collection<? extends RuleAtom> c) {
-               
-               RuleAtom[] collectionOfSemionRules = new RuleAtom[c.size()];
-               collectionOfSemionRules = c.toArray(collectionOfSemionRules);
-               
-               if(kReSRuleAtoms == null){
-                       kReSRuleAtoms = collectionOfSemionRules;
-               }
-               else{
-                       RuleAtom[] semionRulesCopy = new 
RuleAtom[kReSRuleAtoms.length+collectionOfSemionRules.length];
-                       System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 0, 
kReSRuleAtoms.length);
-                       System.arraycopy(collectionOfSemionRules, 0, 
semionRulesCopy, kReSRuleAtoms.length, collectionOfSemionRules.length);
-                       kReSRuleAtoms = semionRulesCopy;
-               }
-               return true;
-       }
-
-       public void clear() {
-               // TODO Auto-generated method stub
-               
-       }
-
-       public boolean contains(Object o) {
-               for(RuleAtom semionRule : kReSRuleAtoms){
-                       if(semionRule.equals(o)){
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       public boolean containsAll(Collection<?> c) {
-               
-               for(Object o : c){
-                       for(RuleAtom semionRule : kReSRuleAtoms){
-                               if(!semionRule.equals(o)){
-                                       return false;
-                               }
-                               else{
-                                       break;
-                               }
-                       }
-               }
-               return true;
-       }
-
-       public boolean isEmpty() {
-               if(kReSRuleAtoms == null || (kReSRuleAtoms.length == 1 && 
kReSRuleAtoms[0] == null)){
-                       return true;
-               }
-               else{
-                       return false;
-               }
-       }
-
-       public Iterator<RuleAtom> iterator() {
-               return new AtomIterator(this);
-       }
-
-       public boolean remove(Object o) {
-               boolean removed = false;
-               for(int i=0; i<kReSRuleAtoms.length && !removed; i++){
-                       RuleAtom semionRule = kReSRuleAtoms[i];
-                       if(semionRule.equals(o)){
-                               RuleAtom[] semionRulesCopy = new 
RuleAtom[kReSRuleAtoms.length-1];
-                               System.arraycopy(kReSRuleAtoms, 0, 
semionRulesCopy, 0, i);
-                               System.arraycopy(kReSRuleAtoms, i+1, 
semionRulesCopy, 0, semionRulesCopy.length-i);
-                               kReSRuleAtoms = semionRulesCopy;
-                               removed = true;
-                       }
-               }
-               return removed;
-       }
-
-       public boolean removeAll(Collection<?> c) {
-               if(contains(c)){
-                       for(Object o : c){
-                               boolean removed = false;
-                               for(int i=0; i<kReSRuleAtoms.length && 
!removed; i++){
-                                       RuleAtom semionRule = kReSRuleAtoms[i];
-                                       if(semionRule.equals(o)){
-                                               RuleAtom[] semionRulesCopy = 
new RuleAtom[kReSRuleAtoms.length-1];
-                                               System.arraycopy(kReSRuleAtoms, 
0, semionRulesCopy, 0, i);
-                                               System.arraycopy(kReSRuleAtoms, 
i+1, semionRulesCopy, 0, semionRulesCopy.length-i);
-                                               kReSRuleAtoms = semionRulesCopy;
-                                               removed = true;
-                                       }
-                               }
-                       }
-                       return true;
-               }
-               else{
-                       return false;
-               }
-       }
-
-       public boolean retainAll(Collection<?> c) {
-               RuleAtom[] semionRulesCopy = null;
-               RuleAtom[] semionRulesTMP = null;
-               for(Object o : c){
-                       if(o instanceof RuleAtom){
-                               if(contains(o)){
-                                       if(semionRulesCopy == null){
-                                               semionRulesCopy = new 
RuleAtom[1];
-                                               semionRulesCopy[0] = (RuleAtom) 
o;
-                                       }
-                                       else{
-                                               semionRulesTMP = new 
RuleAtom[semionRulesCopy.length+1];
-                                               
System.arraycopy(semionRulesCopy, 0, semionRulesTMP, 0, semionRulesCopy.length);
-                                               
semionRulesTMP[semionRulesTMP.length-1] = (RuleAtom) o;
-                                               semionRulesCopy = 
semionRulesTMP;
-                                       }
-                               }
-                       }
-               }
-               kReSRuleAtoms = semionRulesCopy;
-               return true;
-       }
-
-       public int size() {
-               return kReSRuleAtoms.length;
-       }
-
-       public Object[] toArray() {
-               return kReSRuleAtoms;
-       }
-
-       public <T> T[] toArray(T[] a) {
-               return (T[]) kReSRuleAtoms;
-       }
-       
-}
+    private RuleAtom[] kReSRuleAtoms;
+
+    public AtomList() {
 
+    }
+
+    public boolean add(RuleAtom kReSRuleAtom) {
+        if (kReSRuleAtoms == null) {
+            kReSRuleAtoms = new RuleAtom[1];
+            kReSRuleAtoms[0] = kReSRuleAtom;
+        } else {
+            RuleAtom[] semionRulesCopy = new RuleAtom[kReSRuleAtoms.length + 
1];
+            System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 0, 
kReSRuleAtoms.length);
+            semionRulesCopy[semionRulesCopy.length - 1] = kReSRuleAtom;
+            kReSRuleAtoms = semionRulesCopy;
+        }
+        return true;
+    }
+
+    public boolean addToHead(RuleAtom kReSRuleAtom) {
+        if (kReSRuleAtoms == null) {
+            kReSRuleAtoms = new RuleAtom[1];
+            kReSRuleAtoms[0] = kReSRuleAtom;
+        } else {
+            RuleAtom[] semionRulesCopy = new RuleAtom[kReSRuleAtoms.length + 
1];
+            System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 1, 
kReSRuleAtoms.length);
+            semionRulesCopy[0] = kReSRuleAtom;
+            kReSRuleAtoms = semionRulesCopy;
+        }
+        return true;
+    }
+
+    public boolean addAll(Collection<? extends RuleAtom> c) {
+
+        RuleAtom[] collectionOfSemionRules = new RuleAtom[c.size()];
+        collectionOfSemionRules = c.toArray(collectionOfSemionRules);
+
+        if (kReSRuleAtoms == null) {
+            kReSRuleAtoms = collectionOfSemionRules;
+        } else {
+            RuleAtom[] semionRulesCopy = new RuleAtom[kReSRuleAtoms.length + 
collectionOfSemionRules.length];
+            System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 0, 
kReSRuleAtoms.length);
+            System.arraycopy(collectionOfSemionRules, 0, semionRulesCopy, 
kReSRuleAtoms.length,
+                collectionOfSemionRules.length);
+            kReSRuleAtoms = semionRulesCopy;
+        }
+        return true;
+    }
+
+    public void clear() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean contains(Object o) {
+        for (RuleAtom semionRule : kReSRuleAtoms) {
+            if (semionRule.equals(o)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean containsAll(Collection<?> c) {
+
+        for (Object o : c) {
+            for (RuleAtom semionRule : kReSRuleAtoms) {
+                if (!semionRule.equals(o)) {
+                    return false;
+                } else {
+                    break;
+                }
+            }
+        }
+        return true;
+    }
+
+    public boolean isEmpty() {
+        if (kReSRuleAtoms == null || (kReSRuleAtoms.length == 1 && 
kReSRuleAtoms[0] == null)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Iterator<RuleAtom> iterator() {
+        return new AtomIterator(this);
+    }
+
+    public boolean remove(Object o) {
+        boolean removed = false;
+        for (int i = 0; i < kReSRuleAtoms.length && !removed; i++) {
+            RuleAtom semionRule = kReSRuleAtoms[i];
+            if (semionRule.equals(o)) {
+                RuleAtom[] semionRulesCopy = new RuleAtom[kReSRuleAtoms.length 
- 1];
+                System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 0, i);
+                System.arraycopy(kReSRuleAtoms, i + 1, semionRulesCopy, 0, 
semionRulesCopy.length - i);
+                kReSRuleAtoms = semionRulesCopy;
+                removed = true;
+            }
+        }
+        return removed;
+    }
+
+    public boolean removeAll(Collection<?> c) {
+        if (contains(c)) {
+            for (Object o : c) {
+                boolean removed = false;
+                for (int i = 0; i < kReSRuleAtoms.length && !removed; i++) {
+                    RuleAtom semionRule = kReSRuleAtoms[i];
+                    if (semionRule.equals(o)) {
+                        RuleAtom[] semionRulesCopy = new 
RuleAtom[kReSRuleAtoms.length - 1];
+                        System.arraycopy(kReSRuleAtoms, 0, semionRulesCopy, 0, 
i);
+                        System.arraycopy(kReSRuleAtoms, i + 1, 
semionRulesCopy, 0, semionRulesCopy.length - i);
+                        kReSRuleAtoms = semionRulesCopy;
+                        removed = true;
+                    }
+                }
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public boolean retainAll(Collection<?> c) {
+        RuleAtom[] semionRulesCopy = null;
+        RuleAtom[] semionRulesTMP = null;
+        for (Object o : c) {
+            if (o instanceof RuleAtom) {
+                if (contains(o)) {
+                    if (semionRulesCopy == null) {
+                        semionRulesCopy = new RuleAtom[1];
+                        semionRulesCopy[0] = (RuleAtom) o;
+                    } else {
+                        semionRulesTMP = new RuleAtom[semionRulesCopy.length + 
1];
+                        System.arraycopy(semionRulesCopy, 0, semionRulesTMP, 
0, semionRulesCopy.length);
+                        semionRulesTMP[semionRulesTMP.length - 1] = (RuleAtom) 
o;
+                        semionRulesCopy = semionRulesTMP;
+                    }
+                }
+            }
+        }
+        kReSRuleAtoms = semionRulesCopy;
+        return true;
+    }
+
+    public int size() {
+        return kReSRuleAtoms.length;
+    }
+
+    public Object[] toArray() {
+        return kReSRuleAtoms;
+    }
+
+    public <T> T[] toArray(T[] a) {
+        return (T[]) kReSRuleAtoms;
+    }
+
+}

Modified: 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeIterator.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeIterator.java?rev=1306388&r1=1306387&r2=1306388&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeIterator.java
 (original)
+++ 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeIterator.java
 Wed Mar 28 14:55:04 2012
@@ -1,57 +1,55 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.base.api.util;
 
 import java.util.Iterator;
 
 import org.apache.stanbol.rules.base.api.Recipe;
 
-
 public class RecipeIterator implements Iterator<Recipe> {
 
-       private int currentIndex;
-       private int listSize;
-       private Recipe[] recipes;
-       
-       public RecipeIterator(RecipeList recipeList) {
-               this.listSize = recipeList.size();
-               this.recipes = new Recipe[listSize];
-               this.recipes = recipeList.toArray(this.recipes);
-               this.currentIndex = 0;
-               
-       }
-       
-       public boolean hasNext() {
-               if(currentIndex<(listSize-1)){
-                       return true;
-               }
-               else{
-                       return false;
-               }
-       }
-
-       public Recipe next() {
-               Recipe recipe = recipes[currentIndex];
-               currentIndex++;
-               return recipe;
-       }
-
-       public void remove() {
-               
-       }
-       
+    private int currentIndex;
+    private int listSize;
+    private Recipe[] recipes;
+
+    public RecipeIterator(RecipeList recipeList) {
+        this.listSize = recipeList.size();
+        this.recipes = new Recipe[listSize];
+        this.recipes = recipeList.toArray(this.recipes);
+        this.currentIndex = 0;
+
+    }
+
+    public boolean hasNext() {
+        if (currentIndex < (listSize)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Recipe next() {
+        Recipe recipe = recipes[currentIndex];
+        currentIndex++;
+        return recipe;
+    }
+
+    public void remove() {
+
+    }
+
 }

Modified: 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeList.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeList.java?rev=1306388&r1=1306387&r2=1306388&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeList.java
 (original)
+++ 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RecipeList.java
 Wed Mar 28 14:55:04 2012
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.base.api.util;
 
 import java.util.Collection;
@@ -21,158 +21,156 @@ import java.util.Iterator;
 
 import org.apache.stanbol.rules.base.api.Recipe;
 
+public class RecipeList implements Collection<Recipe> {
 
-public class RecipeList implements Collection<Recipe>{
+    private Recipe[] recipes;
 
-       private Recipe[] recipes;
-       
-       public RecipeList() {
-               
-       }
-
-       public boolean add(Recipe recipe) {
-               if(recipes == null){
-                       recipes = new Recipe[1];
-                       recipes[0] = recipe;
-               }
-               else{
-                       Recipe[] recipesCopy = new Recipe[recipes.length+1];
-                       System.arraycopy(recipes, 0, recipesCopy, 0, 
recipes.length);
-                       recipesCopy[recipesCopy.length-1] = recipe;
-                       recipes = recipesCopy;
-               }
-               return true;
-       }
-
-       public boolean addAll(Collection<? extends Recipe> c) {
-               
-               Recipe[] collectionOfRecipes = new Recipe[c.size()];
-               collectionOfRecipes = c.toArray(collectionOfRecipes);
-               
-               if(recipes == null){
-                       recipes = collectionOfRecipes;
-               }
-               else{
-                       Recipe[] recipesCopy = new 
Recipe[recipes.length+collectionOfRecipes.length];
-                       System.arraycopy(recipes, 0, recipesCopy, 0, 
recipes.length);
-                       System.arraycopy(collectionOfRecipes, 0, recipesCopy, 
recipes.length, collectionOfRecipes.length);
-                       recipes = recipesCopy;
-               }
-               return true;
-       }
-
-       public void clear() {
-               // TODO Auto-generated method stub
-               
-       }
-
-       public boolean contains(Object o) {
-               for(Recipe recipe : recipes){
-                       if(recipe.equals(o)){
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       public boolean containsAll(Collection<?> c) {
-               
-               for(Object o : c){
-                       for(Recipe recipe : recipes){
-                               if(!recipe.equals(o)){
-                                       return false;
-                               }
-                               else{
-                                       break;
-                               }
-                       }
-               }
-               return true;
-       }
-
-       public boolean isEmpty() {
-               if(recipes == null || (recipes.length == 1 && recipes[0] == 
null)){
-                       return true;
-               }
-               else{
-                       return false;
-               }
-       }
-
-       public Iterator<Recipe> iterator() {
-               return new RecipeIterator(this);
-       }
-
-       public boolean remove(Object o) {
-               boolean removed = false;
-               for(int i=0; i<recipes.length && !removed; i++){
-                       Recipe recipe = recipes[i];
-                       if(recipe.equals(o)){
-                               Recipe[] recipesCopy = new 
Recipe[recipes.length-1];
-                               System.arraycopy(recipes, 0, recipesCopy, 0, i);
-                               System.arraycopy(recipes, i+1, recipesCopy, 0, 
recipesCopy.length-i);
-                               recipes = recipesCopy;
-                               removed = true;
-                       }
-               }
-               return removed;
-       }
-
-       public boolean removeAll(Collection<?> c) {
-               if(contains(c)){
-                       for(Object o : c){
-                               boolean removed = false;
-                               for(int i=0; i<recipes.length && !removed; i++){
-                                       Recipe recipe = recipes[i];
-                                       if(recipe.equals(o)){
-                                               Recipe[] recipesCopy = new 
Recipe[recipes.length-1];
-                                               System.arraycopy(recipes, 0, 
recipesCopy, 0, i);
-                                               System.arraycopy(recipes, i+1, 
recipesCopy, 0, recipesCopy.length-i);
-                                               recipes = recipesCopy;
-                                               removed = true;
-                                       }
-                               }
-                       }
-                       return true;
-               }
-               else{
-                       return false;
-               }
-       }
-
-       public boolean retainAll(Collection<?> c) {
-               Recipe[] recipesCopy = null;
-               Recipe[] recipesTMP = null;
-               for(Object o : c){
-                       if(o instanceof Recipe){
-                               if(contains(o)){
-                                       if(recipesCopy == null){
-                                               recipesCopy = new Recipe[1];
-                                               recipesCopy[0] = (Recipe) o;
-                                       }
-                                       else{
-                                               recipesTMP = new 
Recipe[recipesCopy.length+1];
-                                               System.arraycopy(recipesCopy, 
0, recipesTMP, 0, recipesCopy.length);
-                                               recipesTMP[recipesTMP.length-1] 
= (Recipe) o;
-                                               recipesCopy = recipesTMP;
-                                       }
-                               }
-                       }
-               }
-               recipes = recipesCopy;
-               return true;
-       }
-
-       public int size() {
-               return recipes.length-1;
-       }
-
-       public Object[] toArray() {
-               return recipes;
-       }
-
-       public <T> T[] toArray(T[] a) {
-               return (T[]) recipes;
-       }
+    public RecipeList() {
+
+    }
+
+    public boolean add(Recipe recipe) {
+        if (recipes == null) {
+            recipes = new Recipe[1];
+            recipes[0] = recipe;
+        } else {
+            Recipe[] recipesCopy = new Recipe[recipes.length + 1];
+            System.arraycopy(recipes, 0, recipesCopy, 0, recipes.length);
+            recipesCopy[recipesCopy.length - 1] = recipe;
+            recipes = recipesCopy;
+        }
+        return true;
+    }
+
+    public boolean addAll(Collection<? extends Recipe> c) {
+
+        Recipe[] collectionOfRecipes = new Recipe[c.size()];
+        collectionOfRecipes = c.toArray(collectionOfRecipes);
+
+        if (recipes == null) {
+            recipes = collectionOfRecipes;
+        } else {
+            Recipe[] recipesCopy = new Recipe[recipes.length + 
collectionOfRecipes.length];
+            System.arraycopy(recipes, 0, recipesCopy, 0, recipes.length);
+            System.arraycopy(collectionOfRecipes, 0, recipesCopy, 
recipes.length, collectionOfRecipes.length);
+            recipes = recipesCopy;
+        }
+        return true;
+    }
+
+    public void clear() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean contains(Object o) {
+        for (Recipe recipe : recipes) {
+            if (recipe.equals(o)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean containsAll(Collection<?> c) {
+
+        for (Object o : c) {
+            for (Recipe recipe : recipes) {
+                if (!recipe.equals(o)) {
+                    return false;
+                } else {
+                    break;
+                }
+            }
+        }
+        return true;
+    }
+
+    public boolean isEmpty() {
+        if (recipes == null || (recipes.length == 1 && recipes[0] == null)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Iterator<Recipe> iterator() {
+        return new RecipeIterator(this);
+    }
+
+    public boolean remove(Object o) {
+        boolean removed = false;
+        for (int i = 0; i < recipes.length && !removed; i++) {
+            Recipe recipe = recipes[i];
+            if (recipe.equals(o)) {
+                Recipe[] recipesCopy = new Recipe[recipes.length - 1];
+                System.arraycopy(recipes, 0, recipesCopy, 0, i);
+                System.arraycopy(recipes, i + 1, recipesCopy, 0, 
recipesCopy.length - i);
+                recipes = recipesCopy;
+                removed = true;
+            }
+        }
+        return removed;
+    }
+
+    public boolean removeAll(Collection<?> c) {
+        if (contains(c)) {
+            for (Object o : c) {
+                boolean removed = false;
+                for (int i = 0; i < recipes.length && !removed; i++) {
+                    Recipe recipe = recipes[i];
+                    if (recipe.equals(o)) {
+                        Recipe[] recipesCopy = new Recipe[recipes.length - 1];
+                        System.arraycopy(recipes, 0, recipesCopy, 0, i);
+                        System.arraycopy(recipes, i + 1, recipesCopy, 0, 
recipesCopy.length - i);
+                        recipes = recipesCopy;
+                        removed = true;
+                    }
+                }
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public boolean retainAll(Collection<?> c) {
+        Recipe[] recipesCopy = null;
+        Recipe[] recipesTMP = null;
+        for (Object o : c) {
+            if (o instanceof Recipe) {
+                if (contains(o)) {
+                    if (recipesCopy == null) {
+                        recipesCopy = new Recipe[1];
+                        recipesCopy[0] = (Recipe) o;
+                    } else {
+                        recipesTMP = new Recipe[recipesCopy.length + 1];
+                        System.arraycopy(recipesCopy, 0, recipesTMP, 0, 
recipesCopy.length);
+                        recipesTMP[recipesTMP.length - 1] = (Recipe) o;
+                        recipesCopy = recipesTMP;
+                    }
+                }
+            }
+        }
+        recipes = recipesCopy;
+        return true;
+    }
+
+    public int size() {
+        if (recipes == null) {
+            return 0;
+        } else {
+            return recipes.length;
+        }
+
+    }
+
+    public Object[] toArray() {
+        return recipes;
+    }
+
+    public <T> T[] toArray(T[] a) {
+        return (T[]) recipes;
+    }
 
 }

Modified: 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleIterator.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleIterator.java?rev=1306388&r1=1306387&r2=1306388&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleIterator.java
 (original)
+++ 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleIterator.java
 Wed Mar 28 14:55:04 2012
@@ -1,57 +1,55 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.base.api.util;
 
 import java.util.Iterator;
 
 import org.apache.stanbol.rules.base.api.Rule;
 
-
 public class RuleIterator implements Iterator<Rule> {
 
-       private int currentIndex;
-       private int listSize;
-       private Rule[] semionRules;
-       
-       public RuleIterator(RuleList semionRuleList) {
-               this.listSize = semionRuleList.size();
-               this.semionRules = new Rule[listSize];
-               this.semionRules = semionRuleList.toArray(this.semionRules);
-               this.currentIndex = 0;
-               
-       }
-       
-       public boolean hasNext() {
-               if(currentIndex<(listSize)){
-                       return true;
-               }
-               else{
-                       return false;
-               }
-       }
-
-       public Rule next() {
-               Rule semionRule = semionRules[currentIndex];
-               currentIndex++;
-               return semionRule;
-       }
-
-       public void remove() {
-               
-       }
+    private int currentIndex;
+    private int listSize;
+    private Rule[] semionRules;
+
+    public RuleIterator(RuleList semionRuleList) {
+        this.listSize = semionRuleList.size();
+        this.semionRules = new Rule[listSize];
+        this.semionRules = semionRuleList.toArray(this.semionRules);
+        this.currentIndex = 0;
+
+    }
+
+    public boolean hasNext() {
+        if (currentIndex < (listSize)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Rule next() {
+        Rule semionRule = semionRules[currentIndex];
+        currentIndex++;
+        return semionRule;
+    }
+
+    public void remove() {
+
+    }
 
 }

Modified: 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleList.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleList.java?rev=1306388&r1=1306387&r2=1306388&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleList.java
 (original)
+++ 
incubator/stanbol/trunk/rules/base/src/main/java/org/apache/stanbol/rules/base/api/util/RuleList.java
 Wed Mar 28 14:55:04 2012
@@ -1,206 +1,194 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.base.api.util;
 
-
 import java.util.Collection;
 import java.util.Iterator;
 
 import org.apache.stanbol.rules.base.api.Rule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 
 public class RuleList implements Collection<Rule> {
 
-       private final Logger log = LoggerFactory.getLogger(getClass());
-       
-       private Rule[] kReSRules;
-
-       public RuleList() {
-
-       }
-
-       
-       public boolean add(Rule semionRule) {
-               if (kReSRules == null) {
-                       kReSRules = new Rule[1];
-                       kReSRules[0] = semionRule;
-               } else {
-                       Rule[] semionRulesCopy = new Rule[kReSRules.length + 1];
-                       System
-                                       .arraycopy(kReSRules, 0, 
semionRulesCopy, 0,
-                                                       kReSRules.length);
-                       semionRulesCopy[semionRulesCopy.length - 1] = 
semionRule;
-                       kReSRules = semionRulesCopy;
-               }
-               return true;
-       }
-       
-       public boolean addToHead(Rule semionRule) {
-               if (kReSRules == null) {
-                       kReSRules = new Rule[1];
-                       kReSRules[0] = semionRule;
-               } else {
-                       Rule[] semionRulesCopy = new Rule[kReSRules.length + 1];
-                       System
-                                       .arraycopy(kReSRules, 0, 
semionRulesCopy, 1,
-                                                       kReSRules.length);
-                       semionRulesCopy[0] = semionRule;
-                       kReSRules = semionRulesCopy;
-               }
-               return true;
-       }
-
-       public boolean addAll(Collection<? extends Rule> c) {
-
-               Rule[] collectionOfSemionRules = new Rule[c.size()];
-               collectionOfSemionRules = c.toArray(collectionOfSemionRules);
-
-               if (kReSRules == null) {
-                       kReSRules = collectionOfSemionRules;
-               } else {
-                       Rule[] semionRulesCopy = new Rule[kReSRules.length
-                                       + collectionOfSemionRules.length];
-                       System
-                                       .arraycopy(kReSRules, 0, 
semionRulesCopy, 0,
-                                                       kReSRules.length);
-                       System.arraycopy(collectionOfSemionRules, 0, 
semionRulesCopy,
-                                       kReSRules.length, 
collectionOfSemionRules.length);
-                       kReSRules = semionRulesCopy;
-               }
-
-               return true;
-       }
-
-       /**
-        * To clear the collection
-        */
-       public void clear() {
-               this.kReSRules = null;
-       }
-
-       public boolean contains(Object o) {
-               for (Rule semionRule : kReSRules) {
-                       if (semionRule.equals(o)) {
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       public boolean containsAll(Collection<?> c) {
-
-               for (Object o : c) {
-                       for (Rule semionRule : kReSRules) {
-                               if (!semionRule.equals(o)) {
-                                       return false;
-                               } else {
-                                       break;
-                               }
-                       }
-               }
-               return true;
-       }
-
-       public boolean isEmpty() {
-               if (kReSRules == null
-                               || (kReSRules.length == 1 && kReSRules[0] == 
null)) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       public Iterator<Rule> iterator() {
-               return new RuleIterator(this);
-       }
-
-       public boolean remove(Object o) {
-               boolean removed = false;
-               for (int i = 0; i < kReSRules.length && !removed; i++) {
-                       Rule semionRule = kReSRules[i];
-                       if (semionRule.equals(o)) {
-                               Rule[] semionRulesCopy = new 
Rule[kReSRules.length - 1];
-                               System.arraycopy(kReSRules, 0, semionRulesCopy, 
0, i);
-                               System.arraycopy(kReSRules, i + 1, 
semionRulesCopy, 0,
-                                               semionRulesCopy.length - i);
-                               kReSRules = semionRulesCopy;
-                               removed = true;
-                       }
-               }
-               return removed;
-       }
-
-       public boolean removeAll(Collection<?> c) {
-               if (contains(c)) {
-                       for (Object o : c) {
-                               boolean removed = false;
-                               for (int i = 0; i < kReSRules.length && 
!removed; i++) {
-                                       Rule semionRule = kReSRules[i];
-                                       if (semionRule.equals(o)) {
-                                               Rule[] semionRulesCopy = new 
Rule[kReSRules.length - 1];
-                                               System.arraycopy(kReSRules, 0, 
semionRulesCopy, 0, i);
-                                               System.arraycopy(kReSRules, i + 
1, semionRulesCopy, 0,
-                                                               
semionRulesCopy.length - i);
-                                               kReSRules = semionRulesCopy;
-                                               removed = true;
-                                       }
-                               }
-                       }
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       public boolean retainAll(Collection<?> c) {
-               Rule[] semionRulesCopy = null;
-               Rule[] semionRulesTMP = null;
-               for (Object o : c) {
-                       if (o instanceof Rule) {
-                               if (contains(o)) {
-                                       if (semionRulesCopy == null) {
-                                               semionRulesCopy = new Rule[1];
-                                               semionRulesCopy[0] = (Rule) o;
-                                       } else {
-                                               semionRulesTMP = new 
Rule[semionRulesCopy.length + 1];
-                                               
System.arraycopy(semionRulesCopy, 0, semionRulesTMP, 0,
-                                                               
semionRulesCopy.length);
-                                               
semionRulesTMP[semionRulesTMP.length - 1] = (Rule) o;
-                                               semionRulesCopy = 
semionRulesTMP;
-                                       }
-                               }
-                       }
-               }
-               kReSRules = semionRulesCopy;
-               return true;
-       }
-
-       public int size() {
-               return kReSRules.length;
-       }
-
-       public Object[] toArray() {
-               return kReSRules;
-       }
-
-       public <T> T[] toArray(T[] a) {
-               return (T[]) kReSRules;
-       }
+    private Rule[] rules;
+
+    public RuleList() {
+
+    }
+
+    public boolean add(Rule semionRule) {
+        if (rules == null) {
+            rules = new Rule[1];
+            rules[0] = semionRule;
+        } else {
+            Rule[] semionRulesCopy = new Rule[rules.length + 1];
+            System.arraycopy(rules, 0, semionRulesCopy, 0, rules.length);
+            semionRulesCopy[semionRulesCopy.length - 1] = semionRule;
+            rules = semionRulesCopy;
+        }
+        return true;
+    }
+
+    public boolean addToHead(Rule semionRule) {
+        if (rules == null) {
+            rules = new Rule[1];
+            rules[0] = semionRule;
+        } else {
+            Rule[] semionRulesCopy = new Rule[rules.length + 1];
+            System.arraycopy(rules, 0, semionRulesCopy, 1, rules.length);
+            semionRulesCopy[0] = semionRule;
+            rules = semionRulesCopy;
+        }
+        return true;
+    }
+
+    public boolean addAll(Collection<? extends Rule> c) {
+
+        Rule[] collectionOfSemionRules = new Rule[c.size()];
+        collectionOfSemionRules = c.toArray(collectionOfSemionRules);
+
+        if (rules == null) {
+            rules = collectionOfSemionRules;
+        } else {
+            Rule[] semionRulesCopy = new Rule[rules.length + 
collectionOfSemionRules.length];
+            System.arraycopy(rules, 0, semionRulesCopy, 0, rules.length);
+            System.arraycopy(collectionOfSemionRules, 0, semionRulesCopy, 
rules.length,
+                collectionOfSemionRules.length);
+            rules = semionRulesCopy;
+        }
+
+        return true;
+    }
+
+    /**
+     * To clear the collection
+     */
+    public void clear() {
+        this.rules = null;
+    }
+
+    public boolean contains(Object o) {
+        for (Rule semionRule : rules) {
+            if (semionRule.equals(o)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean containsAll(Collection<?> c) {
+
+        for (Object o : c) {
+            for (Rule semionRule : rules) {
+                if (!semionRule.equals(o)) {
+                    return false;
+                } else {
+                    break;
+                }
+            }
+        }
+        return true;
+    }
+
+    public boolean isEmpty() {
+        if (rules == null || (rules.length == 1 && rules[0] == null)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Iterator<Rule> iterator() {
+        return new RuleIterator(this);
+    }
+
+    public boolean remove(Object o) {
+        boolean removed = false;
+        for (int i = 0; i < rules.length && !removed; i++) {
+            Rule semionRule = rules[i];
+            if (semionRule.equals(o)) {
+                Rule[] semionRulesCopy = new Rule[rules.length - 1];
+                System.arraycopy(rules, 0, semionRulesCopy, 0, i);
+                System.arraycopy(rules, i + 1, semionRulesCopy, 0, 
semionRulesCopy.length - i);
+                rules = semionRulesCopy;
+                removed = true;
+            }
+        }
+        return removed;
+    }
+
+    public boolean removeAll(Collection<?> c) {
+        if (contains(c)) {
+            for (Object o : c) {
+                boolean removed = false;
+                for (int i = 0; i < rules.length && !removed; i++) {
+                    Rule semionRule = rules[i];
+                    if (semionRule.equals(o)) {
+                        Rule[] semionRulesCopy = new Rule[rules.length - 1];
+                        System.arraycopy(rules, 0, semionRulesCopy, 0, i);
+                        System.arraycopy(rules, i + 1, semionRulesCopy, 0, 
semionRulesCopy.length - i);
+                        rules = semionRulesCopy;
+                        removed = true;
+                    }
+                }
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public boolean retainAll(Collection<?> c) {
+        Rule[] semionRulesCopy = null;
+        Rule[] semionRulesTMP = null;
+        for (Object o : c) {
+            if (o instanceof Rule) {
+                if (contains(o)) {
+                    if (semionRulesCopy == null) {
+                        semionRulesCopy = new Rule[1];
+                        semionRulesCopy[0] = (Rule) o;
+                    } else {
+                        semionRulesTMP = new Rule[semionRulesCopy.length + 1];
+                        System.arraycopy(semionRulesCopy, 0, semionRulesTMP, 
0, semionRulesCopy.length);
+                        semionRulesTMP[semionRulesTMP.length - 1] = (Rule) o;
+                        semionRulesCopy = semionRulesTMP;
+                    }
+                }
+            }
+        }
+        rules = semionRulesCopy;
+        return true;
+    }
+
+    public int size() {
+        if (rules == null) {
+            return 0;
+        } else {
+            return rules.length;
+        }
+
+    }
+
+    public Object[] toArray() {
+        return rules;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T[] toArray(T[] a) {
+        return (T[]) rules;
+    }
 
 }


Reply via email to