Changeset 1946

Show
Ignore:
Timestamp:
02/22/08 08:55:15 (9 months ago)
Author:
dsugar
Message:

Move dictionary validation into visitor - DictionaryValidator?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dictionary_changes/src/com/tresys/framework/compiler/CLIProjectErrorHandler.java

    r1825 r1946  
    66 *   
    77 * Compiler: Compiler main 
    8  * Version: @version@ 
    9  */package com.tresys.framework.compiler; 
     8 *  
     9 * $Rev$ 
     10 * $Date$ 
     11 */ 
    1012 
    11 public class CLIProjectErrorHandler implements ProjectErrorHandler { 
     13package com.tresys.framework.compiler; 
    1214 
    13         public void ProjectError(String message) { 
    14                 System.err.println("error: " + message); 
    15                 System.exit(1); 
     15public class CLIProjectErrorHandler 
     16        extends ProjectErrorHandler 
     17
     18         
     19        public void ProjectError (String message) 
     20        { 
     21                System.err.println ("error: " + message); 
     22                m_nErrorCount ++; 
    1623        } 
    1724 
    18         public void ProjectWarning(String message) { 
    19                 System.err.println("warning: " + message); 
     25        public void ProjectWarning (String message) 
     26        { 
     27                System.err.println ("warning: " + message); 
     28                m_nWarningCount ++; 
    2029        } 
    2130 
     31        public void CriticalError (String message) 
     32        { 
     33                ProjectError (message); 
     34                System.exit (1); 
     35        } 
     36         
    2237} 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/Compiler.java

    r1942 r1946  
    2323 
    2424import com.tresys.framework.compiler.dictionary.Dictionary; 
    25 import com.tresys.framework.compiler.dictionary.TranslatorDictionary
     25import com.tresys.framework.compiler.dictionary.DictionaryValidator
    2626import com.tresys.framework.compiler.linkage.Linkage; 
    2727import com.tresys.framework.compiler.policy.Policy; 
    2828import com.tresys.framework.compiler.systemResources.SystemResources; 
    29 import com.tresys.framework.compiler.translator.TranslatorSELinux; 
     29import com.tresys.framework.compiler.translator.SELinuxDictionary; 
     30import com.tresys.framework.compiler.translator.SELinuxPolicy; 
    3031 
    3132/** 
     
    317318                Linkage linkage = null; 
    318319                // the translator 
    319                 TranslatorSELinux translator = null; 
     320                SELinuxPolicy translator = null; 
    320321 
    321322                dictSourceFilenames = new Vector/* <String> */(); 
     
    364365 
    365366                System.out.println ("Validating dictionary..."); 
    366                 if (!dictionary.Validate (linkage)) 
     367                 
     368                DictionaryValidator validator = new DictionaryValidator (linkage, new CLIProjectErrorHandler ()); 
     369                dictionary.Accept (validator); 
     370                 
     371//              if (!dictionary.Validate (linkage)) 
     372                if (validator.hasError ()) 
    367373                { 
    368374                        ErrorExit ("Dictionary validation failed, exiting..."); 
     
    451457                if (dictionarySupportFile != null) 
    452458                { 
    453                         TranslatorDictionary dictTrans = new TranslatorDictionary (); 
     459                        SELinuxDictionary dictTrans = new SELinuxDictionary (); 
    454460                        dictionary.Accept (dictTrans); 
    455461                         
     
    470476                         
    471477                } 
    472                 translator = new TranslatorSELinux (linkage, moduleName, fcFile); 
     478                translator = new SELinuxPolicy (linkage, moduleName, fcFile); 
    473479 
    474480                policy.Accept (translator); 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/ErrorHandler.java

    r1938 r1946  
    3838        static final public int ERROR_DUPLICATE_ACCESS = 29; 
    3939        static final public int ERROR_UNABLE_TO_GET_TYPE_FROM_PATH = 30; 
    40          
    41          
     40 
     41 
    4242        protected int warningCount = 0; 
    4343 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/ProjectErrorHandler.java

    r1825 r1946  
    11/* 
    2  * Copyright (C) 2005-2006 Tresys Technology, LLC 
     2 * Copyright (C) 2005-2008 Tresys Technology, LLC 
    33 * License: refer to COPYING file for license information. 
    44 * Author:      James Athey <jathey@tresys.com> 
    55 *   
    66 * Compiler: Compiler main 
    7  * Version: @version@ 
     7 *  
     8 * $Rev$ 
     9 * $Date$ 
    810 */ 
    911 
    1012package com.tresys.framework.compiler; 
    1113 
    12 public interface ProjectErrorHandler { 
    13         public void ProjectWarning(String message); 
     14public abstract class ProjectErrorHandler  
     15
     16        protected int m_nWarningCount = 0; 
     17        protected int m_nErrorCount = 0; 
    1418 
    15         public void ProjectError(String message); 
     19        public abstract void ProjectWarning(String message); 
     20 
     21        public abstract void ProjectError(String message); 
     22         
     23        public abstract void CriticalError (String message); 
     24         
     25        public int GetErrorCount () 
     26        { 
     27                return m_nErrorCount; 
     28        } 
     29         
     30        public int GetWarningCount () 
     31        { 
     32                return m_nWarningCount; 
     33        } 
    1634} 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefn.java

    r1942 r1946  
    1313 
    1414import com.tresys.framework.compiler.AbstractToken; 
    15 import com.tresys.framework.compiler.linkage.Linkage; 
    1615 
    1716import java.util.Collection; 
     
    3635 */ 
    3736public final class AccessDefn 
    38         implements Comparable/* <AccessDefn> */, INameValue, IDictionaryVisitable 
     37        implements Comparable/* <AccessDefn> */, INameValue 
    3938{ 
    4039 
     
    225224        } 
    226225         
    227         /** 
    228          * Test AccessDefn for validity. 
    229          *  
    230          * @return <code>true</code> if definition is valid. 
    231          */ 
    232         final boolean Validate (Linkage linkage) 
    233         { 
    234                 boolean valid = true; 
    235  
    236                 /* for (AccessTarget at:AccessTargets.values()) */ 
    237                 Iterator iter = AccessTargets.values ().iterator (); 
    238                 while (iter.hasNext ()) 
    239                 { 
    240                         AccessTarget at = (AccessTarget) iter.next (); 
    241                         valid &= at.Validate (linkage); 
    242                 } 
    243                 return valid; 
    244         } 
    245  
    246226        public int compareTo (Object o) 
    247227        { 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefnGroup.java

    r1942 r1946  
    2121 
    2222import com.tresys.framework.compiler.AbstractToken; 
    23 import com.tresys.framework.compiler.linkage.Linkage; 
    2423 
    2524/** 
    26  * This class represents a group of access definitions in a FObject. An  
    27  * AccessDefnGroup refers to one named verb and its AccessDefn(s).   
     25 * This class represents a group of access definitions in a FObject. An 
     26 * AccessDefnGroup refers to one named verb and its AccessDefn(s). 
    2827 * <p> 
    2928 *  
    3029 * @see AccessDefn 
    31  * @see AccessTarget  
    32  * @see        PermVector 
     30 * @see AccessTarget 
     31 * @see PermVector 
    3332 * @see Verb 
    3433 */ 
    35 public final class AccessDefnGroup  
    36         implements IDictionaryVisitable 
     34public final class AccessDefnGroup 
    3735{ 
    3836 
    3937        /** The verb associated with the AccessDefnGroup */ 
    40         protected final Integer /*Verb*/verb; 
     38        protected final Integer /* Verb */verb; 
    4139 
    4240        /** The fobejct this group is part of */ 
     
    4644 
    4745        // AccessResource definitions associated with this group 
    48         protected final Map/*<String, AccessDefn>*/accessDefns; 
     46        protected final Map/* <String, AccessDefn> */accessDefns; 
    4947 
    50         protected List/*<Token>*/defaultAccessDefns; 
     48        protected List/* <Token> */defaultAccessDefns; 
    5149 
    5250        /** 
    5351         * The default constructor requires a verb. 
    5452         *  
    55          * @param v             Verb to be associated with this AccessDefnGroup 
    56          * @param rdef  Rdef this group belongs to. 
    57          * @see         Verb 
     53         * @param v 
     54         *            Verb to be associated with this AccessDefnGroup 
     55         * @param rdef 
     56         *            Rdef this group belongs to. 
     57         * @see Verb 
    5858         */ 
    59         public AccessDefnGroup(int /*Verb*/v, Rdef rdef, AbstractToken tok) { 
    60                 verb = new Integer(v); 
     59        public AccessDefnGroup (int /* Verb */v, Rdef rdef, AbstractToken tok) 
     60        { 
     61                verb = new Integer (v); 
    6162                nameToken = tok; 
    62                 accessDefns = new HashMap/*<String, AccessDefn>*/(); 
    63                 defaultAccessDefns = new Vector/*<Token>*/(); 
     63                accessDefns = new HashMap/* <String, AccessDefn> */(); 
     64                defaultAccessDefns = new Vector/* <Token> */(); 
    6465                this.rdef = rdef; 
    6566        } 
     
    6869         * Add an AccessDefn to this group. 
    6970         *  
    70          * @param ad    The AccessDefn to add to this group. 
    71          * @return              Zero on success, one if AccessDefn w/ same name  
    72          *                              already exists in this AccessDefnGroup. 
    73          * @see                 AccessDefn 
     71         * @param ad 
     72         *            The AccessDefn to add to this group. 
     73         * @return Zero on success, one if AccessDefn w/ same name already exists in 
     74         *         this AccessDefnGroup. 
     75         * @see AccessDefn 
    7476         */ 
    75         public int AddAccessDefn(AccessDefn ad) { 
    76                 if(accessDefns.containsKey(ad.getName())) { 
     77        public int AddAccessDefn (AccessDefn ad) 
     78        { 
     79                if (accessDefns.containsKey (ad.getName ())) 
     80                { 
    7781                        return 1; 
    7882                } 
    79                 accessDefns.put(ad.getName(), ad); 
     83                accessDefns.put (ad.getName (), ad); 
    8084                return 0; 
    8185        } 
    8286 
    83         public boolean AddDefaultAccess(AbstractToken access) { 
    84                 /*for (Token currtok : defaultAccessDefns)*/ 
    85                 Iterator iter = defaultAccessDefns.iterator(); 
    86                 while(iter.hasNext()) { 
    87                         AbstractToken currtok = (AbstractToken) iter.next(); 
    88                         if(currtok.image == access.image) { 
    89                                 access 
    90                                         .Error("AccessResource already defined for in defaults list"); 
     87        public boolean AddDefaultAccess (AbstractToken access) 
     88        { 
     89                /* for (Token currtok : defaultAccessDefns) */ 
     90                Iterator iter = defaultAccessDefns.iterator (); 
     91                while (iter.hasNext ()) 
     92                { 
     93                        AbstractToken currtok = (AbstractToken) iter.next (); 
     94                        if (currtok.image == access.image) 
     95                        { 
     96                                access.Error ("AccessResource already defined for in defaults list"); 
    9197                                return false; 
    9298                        } 
    9399                } 
    94100 
    95                 defaultAccessDefns.add(access); 
     101                defaultAccessDefns.add (access); 
    96102                return true; 
    97103        } 
     
    100106         * Lookup an AccessDefn in this group. 
    101107         *  
    102          * @param name  A string identifying the AccessDefn w/ in this  
    103          *                              AccessDefnGroup. 
    104          * @return              AccessDefn if found, <code>null</code> otherwise. 
    105          * @see                 AccessDefn 
     108         * @param name 
     109         *            A string identifying the AccessDefn w/ in this 
     110         *            AccessDefnGroup. 
     111         * @return AccessDefn if found, <code>null</code> otherwise. 
     112         * @see AccessDefn 
    106113         */ 
    107         public AccessDefn GetAccessDefn(String name) { 
    108                 return (AccessDefn) accessDefns.get(name); 
     114        public AccessDefn GetAccessDefn (String name) 
     115        { 
     116                return (AccessDefn) accessDefns.get (name); 
    109117        } 
    110118 
    111         public Set/*<AccessDefn>*/GetDefaultAccessDefns() { 
    112                 Set/*<AccessDefn>*/defns = new TreeSet/*<AccessDefn>*/(); 
     119        public Set/* <AccessDefn> */GetDefaultAccessDefns () 
     120        { 
     121                Set/* <AccessDefn> */defns = new TreeSet/* <AccessDefn> */(); 
    113122                AccessDefn defn; 
    114123 
    115                 /*for (Token tok : defaultAccessDefns)*/ 
    116                 Iterator iter = defaultAccessDefns.iterator(); 
    117                 while(iter.hasNext()) { 
    118                         AbstractToken tok = (AbstractToken) iter.next(); 
    119                         defn = GetAccessDefn(tok.image); 
    120                         if(defn != null) { 
    121                                 defns.add(defn); 
     124                /* for (Token tok : defaultAccessDefns) */ 
     125                Iterator iter = defaultAccessDefns.iterator (); 
     126                while (iter.hasNext ()) 
     127                { 
     128                        AbstractToken tok = (AbstractToken) iter.next (); 
     129                        defn = GetAccessDefn (tok.image); 
     130                        if (defn != null) 
     131                        { 
     132                                defns.add (defn); 
    122133                        } 
    123134                } 
     
    125136                return defns; 
    126137        } 
    127          
     138 
    128139        public void Accept (IDictionaryVisitor i_visitor) 
    129140        { 
    130141                i_visitor.PreVisit (this); 
    131                  
    132                 for (Iterator itr = accessDefns.values ().iterator (); itr.hasNext ();
     142 
     143                for (Iterator itr = accessDefns.values ().iterator (); itr.hasNext ();
    133144                { 
    134145                        AccessDefn ad = (AccessDefn) itr.next (); 
    135146                        ad.Accept (i_visitor); 
    136147                } 
    137                  
     148 
    138149                i_visitor.PostVisit (this); 
    139150        } 
    140151 
    141         /** 
    142          * Test AccessDefnGroup for validity. 
    143          *   
    144          * @return              <code>true</code> if group is valid. 
    145          */ 
    146         final boolean Validate(Linkage linkage) { 
    147                 boolean valid = true; 
    148                 Iterator iter; 
    149  
    150                 /*for (AccessDefn ad:AccessDefns.values())*/ 
    151                 iter = accessDefns.values().iterator(); 
    152                 while(iter.hasNext()) { 
    153                         AccessDefn ad = (AccessDefn) iter.next(); 
    154                         valid &= ad.Validate(linkage); 
    155                 } 
    156  
    157                 /*for (Token currAccess : defaultAccessDefns)*/ 
    158                 iter = defaultAccessDefns.iterator(); 
    159                 while(iter.hasNext()) { 
    160                         AbstractToken currAccess = (AbstractToken) iter.next(); 
    161                         if(!accessDefns.containsKey(currAccess.image)) { 
    162                                 valid &= false; 
    163                                 currAccess 
    164                                         .Error("No AccessResource Definition with this name has been defined"); 
    165                         } 
    166                 } 
    167  
    168                 return valid; 
    169         } 
    170  
    171         public AbstractToken getToken() { 
     152        public AbstractToken getToken () 
     153        { 
    172154                return nameToken; 
    173155        } 
    174156 
    175         public Rdef getRdef() { 
     157        public Rdef getRdef () 
     158        { 
    176159                return rdef; 
    177160        } 
    178161 
    179         public Integer getVerb() { 
     162        public Integer getVerb () 
     163        { 
    180164                return verb; 
    181165        } 
    182166 
    183         public Map getAccessDefns() { 
     167        public Map getAccessDefns () 
     168        { 
    184169                return accessDefns; 
    185170        } 
    186171 
    187         public String getName() { 
     172        public String getName () 
     173        { 
    188174                return nameToken.image; 
    189175        } 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessTarget.java

    r1942 r1946  
    1616import java.util.TreeMap; 
    1717import java.util.Vector; 
    18  
    19 import com.tresys.framework.compiler.linkage.Linkage; 
    2018 
    2119/** 
     
    3432 */ 
    3533public final class AccessTarget 
    36         implements IDictionaryVisitable 
    3734{ 
    3835 
     
    157154        } 
    158155 
    159         /** 
    160          * Test AccessTarget for validity. 
    161          *  
    162          * @return <code>true</code> if target is valid. 
    163          */ 
    164         final boolean Validate (Linkage linkage) 
    165         { 
    166                 boolean valid = true; 
    167  
    168                 /* for (PermVector pv:permvectors.values()) */ 
    169                 Iterator iter = permvectors.values ().iterator (); 
    170                 while (iter.hasNext ()) 
    171                 { 
    172                         PermVector pv = (PermVector) iter.next (); 
    173                         valid &= pv.Validate (linkage); 
    174                 } 
    175                 return valid; 
    176         } 
    177  
    178156        public static AccessTarget MergeAccessTargets (Collection/* <AccessTarget> */targets) 
    179157        { 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Dictionary.java

    r1942 r1946  
    1313 
    1414import com.tresys.framework.compiler.ErrorHandler; 
    15 import com.tresys.framework.compiler.Utility; 
    16 import com.tresys.framework.compiler.linkage.Linkage; 
    1715 
    1816import java.util.HashMap; 
     
    3331 */ 
    3432public final class Dictionary 
    35         implements IDictionaryVisitable 
    3633{ 
    3734        // A dictionary contains a set of rdefs 
     
    196193                i_visitor.PostVisit (this); 
    197194        } 
    198  
    199         /** 
    200          * Test dictionary for validity. 
    201          *  
    202          * @return <code>true</code> if dictionary is valid. 
    203          */ 
    204         public final boolean Validate (Linkage linkage) 
    205         { 
    206                 boolean valid = true; 
    207  
    208                 /* for (Rdef rdef:rdefs.values()) */ 
    209                 Iterator iter = rdefs.values ().iterator (); 
    210                 while (iter.hasNext ()) 
    211                 { 
    212                         Rdef rdef = (Rdef) iter.next (); 
    213                         valid &= rdef.Validate (linkage); 
    214                 } 
    215  
    216                 // validate entrypoint 
    217                 if (Entrypoint == null) 
    218                 { 
    219                         Utility.ProjectError ("There is no Entrypoint defined in the Dictionary"); 
    220                         return false; 
    221                 } 
    222  
    223                 valid &= Entrypoint.Validate (linkage); 
    224                 return valid; 
    225         } 
    226195} 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/EntryAccessDefn.java

    r1942 r1946  
    1717 
    1818import com.tresys.framework.compiler.AbstractToken; 
    19 import com.tresys.framework.compiler.linkage.Linkage; 
    2019 
    2120/** 
    2221 * TODO: add javadoc commenting 
    2322 */ 
    24 public final class EntryAccessDefn  
    25         implements Comparable/*<EntryAccessDefn>*/, INameValue , IDictionaryVisitabl
     23public final class EntryAccessDefn 
     24        implements Comparable/* <EntryAccessDefn> */, INameValu
    2625{ 
    2726 
     
    3130        protected final AbstractToken m_Token; 
    3231 
    33         public final Map/*<Integer, EntryAccessTarget>*/EntryAccessTargets = new TreeMap/*<Integer, EntryAccessTarget>*/(); 
     32        public final Map/* <Integer, EntryAccessTarget> */EntryAccessTargets = new TreeMap/* 
     33                                                                                                                                                                         * <Integer, 
     34                                                                                                                                                                         * EntryAccessTarget> 
     35                                                                                                                                                                         */(); 
    3436 
    35         private final Map/*<String, NameValuePair<?>>*/NameValuePairs = new TreeMap/*<String, NameValuePair<?>>*/(); 
     37        private final Map/* <String, NameValuePair<?>> */NameValuePairs = new TreeMap/* 
     38                                                                                                                                                                 * <String, 
     39                                                                                                                                                                 * NameValuePair<?>> 
     40                                                                                                                                                                 */(); 
    3641 
    37 /*       
    38         private EntryAccessDefn() { 
    39                 Token = null; 
    40                 Name = ""; 
    41         } 
    42 */ 
    4342        /** 
    4443         * AccessDefn constructor creates AccessDefn object and assigns name. 
    4544         *  
    46          * @param n             String value used to identify the AccessResource 
     45         * @param n 
     46         *            String value used to identify the AccessResource 
    4747         */ 
    48         public EntryAccessDefn(AbstractToken token) { 
     48        public EntryAccessDefn (AbstractToken token) 
     49        { 
    4950                m_Token = token; 
    5051                m_sName = token.image; 
     
    5455         * Get EntryAccessTarget by EntryTarget 
    5556         *  
    56          * @return             AccessTarget if found, otherwise null 
     57         * @return AccessTarget if found, otherwise null 
    5758         */ 
    58         public EntryAccessTarget GetEntryAccessTarget(EntryTarget et) { 
    59                 return (EntryAccessTarget) EntryAccessTargets.get(et); 
     59        public EntryAccessTarget GetEntryAccessTarget (EntryTarget et) 
     60        { 
     61                return (EntryAccessTarget) EntryAccessTargets.get (et); 
    6062        } 
    6163 
    6264        /** 
    63          * Add an AccessTarget to this AccessDefn.  
     65         * Add an AccessTarget to this AccessDefn. 
    6466         *  
    65          * @param group The EntryAccessTarget to associate with this EntryAccessDefn. 
    66          * @return                      <code>true</code> if access target successfully  
    67          *                                      inserted, <code>false</code> otherwise 
     67         * @param group 
     68         *            The EntryAccessTarget to associate with this EntryAccessDefn. 
     69         * @return <code>true</code> if access target successfully inserted, 
     70         *         <code>false</code> otherwise 
    6871         */ 
    69         public boolean AddEntryAccessTarget(EntryAccessTarget targ) { 
    70                 if(EntryAccessTargets.containsKey(targ.FlowTarget)) { 
     72        public boolean AddEntryAccessTarget (EntryAccessTarget targ) 
     73        { 
     74                if (EntryAccessTargets.containsKey (targ.FlowTarget)) 
     75                { 
    7176                        return false; 
    7277                } 
    73                 EntryAccessTargets.put(targ.FlowTarget, targ); 
     78                EntryAccessTargets.put (targ.FlowTarget, targ); 
    7479                return true; 
    7580        } 
     
    7883         * Add a NameValuePair metadata object. 
    7984         *  
    80          * @param pair  NameValuePair to add 
    81          * @return      <code>true</code> when name/value inserted  
    82          *                              successfully.  <code>false</code> otherwise. 
     85         * @param pair 
     86         *            NameValuePair to add 
     87         * @return <code>true</code> when name/value inserted successfully. 
     88         *         <code>false</code> otherwise. 
    8389         */ 
    84         public boolean AddNameValuePair(NameValuePair /*<?>*/pair) { 
     90        public boolean AddNameValuePair (NameValuePair /* <?> */pair) 
     91        { 
    8592                // insert nvp into pairs map 
    86                 if(NameValuePairs.containsKey(pair.GetName())) { 
     93                if (NameValuePairs.containsKey (pair.GetName ())) 
     94                { 
    8795                        return false; 
    8896                } 
    8997 
    90                 NameValuePairs.put(pair.GetName(), pair); 
     98                NameValuePairs.put (pair.GetName (), pair); 
    9199                return true; 
    92100        } 
     
    95103         * Retrieve the name/value associated with the name. 
    96104         *  
    97          * @param name  String identifying pair to be returned 
    98          * @return              name/value pair indexed by name 
     105         * @param name 
     106         *            String identifying pair to be returned 
     107         * @return name/value pair indexed by name 
    99108         */ 
    100         public NameValuePair /*<?>*/GetNameValuePair(String name) { 
    101                 return (NameValuePair) NameValuePairs.get(name); 
     109        public NameValuePair /* <?> */GetNameValuePair (String name) 
     110        { 
     111                return (NameValuePair) NameValuePairs.get (name); 
    102112        } 
    103113 
    104114        /** 
    105115         * Get the Map of name/value pairs. 
    106          * 
    107          * @return     NameValuePairs associated with object 
     116         *  
     117         * @return NameValuePairs associated with object 
    108118         */ 
    109         public Map/*<String, NameValuePair<?>>*/GetNameValuePairs() { 
     119        public Map/* <String, NameValuePair<?>> */GetNameValuePairs () 
     120        { 
    110121                return NameValuePairs; 
    111122        } 
    112123 
    113124        /** 
    114          * Check to ensure this instance is a subset of another. In other words, 
    115          * this method returns <code>true</code> when the parameter passed to this  
    116          * method is a superset of this instance.  
     125         * Check to ensure this instance is a subset of another. In other words, 
     126         * this method returns <code>true</code> when the parameter passed to this 
     127         * method is a superset of this instance. 
    117128         *  
    118          * @param other Another EntryAccessDefn instance to perform comparison against. 
    119          * @return              <code>true</code> if this instance is a subset of other, 
    120          *                              <code>false</code> otherwise. 
     129         * @param other 
     130         *            Another EntryAccessDefn instance to perform comparison 
     131         *            against. 
     132         * @return <code>true</code> if this instance is a subset of other, 
     133         *         <code>false</code> otherwise. 
    121134         */ 
    122         public boolean IsSubsetOf(EntryAccessDefn other) { 
    123                 if(other == null) { 
     135        public boolean IsSubsetOf (EntryAccessDefn other) 
     136        { 
     137                if (other == null) 
     138                { 
    124139                        return false; 
    125140                } 
    126141                // iterate over targets checking for superset 
    127                 /*for (Map.Entry<Integer, EntryAccessTarget> mapEntry: EntryAccessTargets.entrySet())*/ 
    128                 Iterator iter = EntryAccessTargets.entrySet().iterator(); 
    129                 while(iter.hasNext()) { 
    130                         Map.Entry mapEntry = (Map.Entry) iter.next(); 
     142                /* 
     143                 * for (Map.Entry<Integer, EntryAccessTarget> mapEntry: 
     144                 * EntryAccessTargets.entrySet()) 
     145                 */ 
     146                Iterator iter = EntryAccessTargets.entrySet ().iterator (); 
     147                while (iter.hasNext ()) 
     148                { 
     149                        Map.Entry mapEntry = (Map.Entry) iter.next (); 
    131150                        // if it has a corresponding target check that target 
    132                         if(other.EntryAccessTargets.containsKey(mapEntry.getKey())) { 
    133                                 if(!((EntryAccessTarget) mapEntry.getValue()) 
    134                                         .IsSubsetOf((EntryAccessTarget) other.EntryAccessTargets 
    135                                                 .get(mapEntry.getKey()))) { 
     151                        if (other.EntryAccessTargets.containsKey (mapEntry.getKey ())) 
     152                        { 
     153                                if (! ((EntryAccessTarget) mapEntry.getValue ()) 
     154                                        .IsSubsetOf ((EntryAccessTarget) other.EntryAccessTargets.get (mapEntry 
     155                                                .getKey ()))) 
     156                                { 
    136157                                        return false; 
    137158                                } 
    138159 
    139                         } else { 
     160                        } 
     161                        else 
     162                        { 
    140163                                return false; 
    141164                        } 
     
    147170        { 
    148171                i_visitor.PreVisit (this); 
    149                  
    150                 for (Iterator itr = EntryAccessTargets.values ().iterator (); itr.hasNext ();
     172 
     173                for (Iterator itr = EntryAccessTargets.values ().iterator (); itr.hasNext ();
    151174                { 
    152175                        EntryAccessTarget eat = (EntryAccessTarget) itr.next (); 
    153176                        eat.Accept (i_visitor); 
    154177                } 
    155                  
     178 
    156179                i_visitor.PostVisit (this); 
    157         } 
    158          
    159         /** 
    160          * Test EntryAccessDefn for validity. 
    161          *   
    162          * @return              <code>true</code> if access is valid. 
    163          */ 
    164         final boolean Validate(Linkage linkage) { 
    165                 boolean valid = true; 
    166  
    167                 /*for (EntryAccessTarget eat: EntryAccessTargets.values())*/ 
    168                 Iterator iter = EntryAccessTargets.values().iterator(); 
    169                 while(iter.hasNext()) { 
    170                         EntryAccessTarget eat = (EntryAccessTarget) iter.next(); 
    171                         valid &= eat.Validate(linkage); 
    172                 } 
    173                 return valid; 
    174180        } 
    175181 
     
    178184                return m_sName; 
    179185        } 
    180          
     186 
    181187        public AbstractToken getToken () 
    182188        { 
    183189                return m_Token; 
    184190        } 
    185          
    186         public int compareTo(Object o) { 
    187                 return m_sName.compareTo(((EntryAccessDefn) o).m_sName); 
     191 
     192        public int compareTo (Object o) 
     193        { 
     194                return m_sName.compareTo ( ((EntryAccessDefn) o).m_sName); 
    188195        } 
    189196} 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/