/* * Created on Mar 17, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package fr.lifl.stc.stan.policy.defaultPolicy; import fr.lifl.stc.stan.policy.ClassPolicy; import fr.lifl.stc.stan.policy.Policy; import java.util.Vector; import java.util.Hashtable; import java.util.Enumeration; /** * @author dorina * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class DefaultClassPolicy implements ClassPolicy { private String className; Vector secretAttrs; //vector of ClassPolicy Hashtable superClasses; /** * * @param className */ public DefaultClassPolicy(String className) { super(); this.className = className; secretAttrs = new Vector(); superClasses = new Hashtable(); } /* (non-Javadoc) * @see fr.lifl.rd2p.jits.tools.ea.policy.ClassPolicy#findAttribute(java.lang.String) */ public int findAttribute(String attribute) { if(secretAttrs.contains(attribute)) return Policy.SECRET_ATTRIBUTE; Enumeration e = superClasses.keys(); while(e.hasMoreElements()){ ClassPolicy cp = superClasses.get(e.nextElement()); if(cp.findAttribute(attribute) == Policy.SECRET_ATTRIBUTE) return Policy.SECRET_ATTRIBUTE; } return Policy.PUBLIC_ATTRIBUTE; } public void add(String attribute) { if(secretAttrs.contains(attribute)) return; secretAttrs.add(attribute); } public String toString(){ String s = "**"+className+"**"; for(int i=0;i c){ for(Enumeration e = c.keys(); e.hasMoreElements(); ) this.addSuperClass( c.get(e.nextElement()) ); } public Hashtable getSuperClasses() { return this.superClasses; } public boolean hasSuperClass(String className) { if(this.getClassName() != className) return superClasses.containsKey(className); return false; } }