package fr.lifl.stc.stan.dsl; import java.util.ArrayList; import org.apache.bcel.generic.Type; import org.apache.bcel.generic.ObjectType; abstract class Policy { protected ArrayList sources = new ArrayList(); protected ArrayList targets = new ArrayList(); void addSource(String s) { sources.add(new ObjectType(s)); } void addTarget(String t) { targets.add(new ObjectType(t)); } ArrayList getSources() { return sources; } ArrayList getTargets() { return targets; } public String toString() { String res = ""; for(Type s : sources) res += s + " "; res += "<-->"; for(Type t : targets) res += t + " "; return res.trim(); } } class ShareWith extends Policy { void addTarget(String t) { if ( t.equals("Static") ) targets.add(FlowSpecialType.STATIC); else if ( t.equals("Exception") ) targets.add(FlowSpecialType.EXCEPTION); else if ( t.equals("IO") ) targets.add(FlowSpecialType.IO); else targets.add(new ObjectType(t)); } } class Secret extends Policy { protected ArrayList targets = new ArrayList(); void addTarget(String t) { targets.add(t); } ArrayList getSecretFields() { return targets; } public String toString() { return sources + "<-->" + targets.toString(); } }