
/*
 *   Calccedo Library
 *   hint this code under Apache License
 */


package com.precious.calccedo.handlers;




/**
 *
 * @author Ibrahim Abdsaid Hanna
 *         ibrahim.seniore@gmail.com
 */
public class Eshortuct extends CalccedoHandler{
    
     String leftTemp;
     char operandType;
     int leftOperandIndex;
     int rightOperandIndex;
   
        public Eshortuct(){
            
        }
     
    public Eshortuct(String leftTemp,char operandType,int leftOperandIndex,int rightOperandIndex){
        this.leftTemp=leftTemp;
        this.operandType=operandType;
        this.leftOperandIndex=leftOperandIndex;
        this.rightOperandIndex=rightOperandIndex;
    }

 
    // process E shortuct to not conflict with - and + operand     
    public Eshortuct process(String subformula,int Eindex){
        
         String leftTemp="E";
         char operandType = 0;
         int leftOperandIndex = 0;
         int rightOperandIndex = 0;
        
         boolean ignore=false;
         
         
         
           for(int i=Eindex;i>=0;i--){
                if(!isNumber(subformula.charAt(i))){
                   if(isMinus(subformula.charAt(i))&&ignore==false){
                       leftOperandIndex=i;
                       leftTemp=subformula.charAt(i)+leftTemp;
                       break;
                   }
                  else if(isPlus(subformula.charAt(i))){
                      leftOperandIndex=i;
                      break;
                   }
                   
               }
               else{
                   leftTemp=subformula.charAt(i)+leftTemp;
               }
           }
           
           
           
           for(int j=Eindex;j<subformula.length();j++){
               
                if(!isNumber(subformula.charAt(j))){
                   if(isMinus(subformula.charAt(j))&&Eindex+1=='-'&&ignore==false){
                       leftTemp=leftTemp+'-';
                       ignore=true;
                   }
                  else if(isPlus(subformula.charAt(j))){
                      operandType='+';
                      rightOperandIndex=j;
                      break;
                   }
                  else if(ignore==true&&(isMinus(subformula.charAt(j))||isPlus(subformula.charAt(j)))){
                       operandType=subformula.charAt(j);
                       rightOperandIndex=j;
                       break;
                  }
                 
                 else if(isMinus(subformula.charAt(j))||isPlus(subformula.charAt(j))){
                       operandType=subformula.charAt(j);
                       rightOperandIndex=j;
                       break;
                  }
                 
               }
               else{
                   leftTemp=leftTemp+subformula.charAt(j);
               }
           }
         
        return new Eshortuct(leftTemp, operandType,leftOperandIndex,rightOperandIndex);
    }
    
    
    
    public boolean isMinus(char c){
        return c=='-' ? true:false;
    }
    
    
    public boolean isPlus(char c){
        return c=='+' ? true:false;
    }
    

    
}
 

@@ -51,17 +51,16 @@
 r Apache
- 
 License%0A
@@ -106,16 +106,103 @@
 dlers;%0A%0A
+import com.precious.calccedo.configuration.Configuration;%0Aimport java.util.ArrayList;%0A%0A
 %0A%0A%0A/**%0A 
@@ -277,22 +277,16 @@
 com%0A */%0A
-public
  class E
@@ -427,16 +427,83 @@
 dex;%0A   
+  ArrayList%3CCharacter%3E list=new ArrayList%3CCharacter%3E();%0A     %0A     
 %0A       
@@ -523,29 +523,16 @@
 tuct()%7B%0A
-            %0A
         
@@ -802,24 +802,42 @@
 erandIndex;%0A
+        %0A        %0A
     %7D%0A%0A %0A   
@@ -1143,32 +1143,141 @@
 false;%0A         
+list.clear();%0A         list.add('/');%0A         list.add('%25');%0A         list.add('*');%0A         list.add('%5E');
 %0A         %0A     
@@ -1759,32 +1759,171 @@
                 
+ else if(list.contains(subformula.charAt(i)))%7B%0A                      leftOperandIndex=i;%0A                      break;%0A                    %7D
 %0A               
@@ -2252,20 +2252,34 @@
 ))&&
-Eindex+1=='-
+subformula.charAt(j-1)=='E
 '&&i
@@ -3133,131 +3133,543 @@
     
-%7D%0A               else%7B%0A                   leftTemp=leftTemp+subformula.charAt(j);%0A               %7D%0A           %7D%0A         %0A 
+    else if(list.contains(subformula.charAt(j)))%7B%0A                       operandType=subformula.charAt(j);%0A                       rightOperandIndex=j;%0A                       break;%0A                  %7D%0A               %7D%0A               else%7B%0A                   leftTemp=leftTemp+subformula.charAt(j);%0A               %7D%0A           %7D%0A       if(Configuration.deepTracing)%0A         System.out.println(%22leftTemp:%22+leftTemp+%22%5CnoperandType:%22+operandType+%22%5CnleftOperandIndex%22+leftOperandIndex+%22%5CnrightOperandIndex%22+rightOperandIndex+%22%5Cn%22);%0A      %0A
     
@@ -3829,29 +3829,16 @@
 n c=='-'
- ? true:false
 ;%0A    %7D%0A
@@ -3907,21 +3907,8 @@
 ='+'
- ? true:false
 ;%0A  

Update Eshortuct.java