1 19 package org.openharmonise.him.actions.rules; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 24 import org.openharmonise.vfs.*; 25 26 27 35 public class RuleGroup implements EnableRule { 36 37 boolean m_bComparator = true; 38 39 42 private ArrayList m_aEnableRules = new ArrayList (); 43 44 47 private String m_sGroupingType = "AND"; 48 49 52 public static String GROUPTYPE_OR = "OR"; 53 54 57 public static String GROUPTYPE_AND = "AND"; 58 59 62 public RuleGroup() { 63 super(); 64 } 65 66 69 public boolean isEnabled(VirtualFile vfFile) { 70 boolean bEnabled = true; 71 72 if(vfFile!=null) { 73 if(this.m_sGroupingType.equals(RuleGroup.GROUPTYPE_AND)) { 74 Iterator itor = this.m_aEnableRules.iterator(); 75 while(itor.hasNext()) { 76 if( !((EnableRule)itor.next()).isEnabled(vfFile) ) { 77 bEnabled = false; 78 } 79 } 80 } else { 81 bEnabled = false; 82 Iterator itor = this.m_aEnableRules.iterator(); 83 while(itor.hasNext()) { 84 if( ((EnableRule)itor.next()).isEnabled(vfFile) ) { 85 bEnabled = true; 86 } 87 } 88 } 89 } 90 91 return this.m_bComparator==bEnabled; 92 } 93 94 99 public void addEnableRule(EnableRule rule) { 100 this.m_aEnableRules.add(rule); 101 } 102 103 106 public void setResultComparator(boolean bComparator) { 107 this.m_bComparator = bComparator; 108 } 109 110 120 public void setGroupType(String sGroupType) { 121 if(sGroupType.equals(RuleGroup.GROUPTYPE_AND) || sGroupType.equals(RuleGroup.GROUPTYPE_OR)) { 122 this.m_sGroupingType = sGroupType; 123 } 124 } 125 126 } 127 | Popular Tags |