package uk.ac.ebi.quickgo.ontology.common.coterm;

/**
 * @author Tony Wardell
 * Date: 29/09/2016
 * Time: 16:08
 * Created with IntelliJ IDEA.
 */
public class CoTermLimit {

    int defaultLimit;

    public CoTermLimit(int defaultLimit) {
        this.defaultLimit = defaultLimit;
    }

    public int workoutLimit(String limit) {
        int limitNumeric = 0;
        if (limit == null) {
            limitNumeric = defaultLimit;
        } else {
            if (LimitValue.FULL.toString().equals(limitNumeric)) {
                limitNumeric = Integer.MAX_VALUE;
            } else {
                try {
                    limitNumeric = Integer.parseInt(limit);
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException("The value for limit co-occurring terms is not ALL, or 0-100");
                }
            }
        }
        return limitNumeric;
    }

    enum LimitValue{
        FULL
    }
}

@@ -473,18 +473,17 @@
 itValue.
-FU
+A
 LL.toStr
@@ -498,21 +498,24 @@
 uals
-(limitNumeric
+IgnoreCase(limit
 )) %7B
@@ -578,32 +578,160 @@
        %7D else %7B%0A
+                if (limit.trim().length() == 0) %7B%0A                    limitNumeric = defaultLimit;%0A                %7D else %7B%0A    
                 
@@ -736,16 +736,20 @@
   try %7B%0A
+    
         
@@ -800,16 +800,153 @@
 limit);%0A
+%0A                        if (limitNumeric == 0) %7B%0A                            limitNumeric = defaultLimit;%0A                        %7D%0A    
         
@@ -985,24 +985,28 @@
 eption e) %7B%0A
+    
             
@@ -1063,22 +1063,16 @@
 lue for 
-limit 
 co-occur
@@ -1082,16 +1082,22 @@
 g terms 
+limit 
 is not A
@@ -1107,16 +1107,78 @@
  or 
-0-100%22);
+a %22 +%0A                                %22number%22);%0A                    %7D
 %0A   
@@ -1271,16 +1271,17 @@
 mitValue
+ 
 %7B%0A      
@@ -1286,10 +1286,9 @@
     
-FU
+A
 LL%0A 

Add some logic for spaces and zeros.