Changeset 1946
- Timestamp:
- 02/22/08 08:55:15 (9 months ago)
- Files:
-
- branches/dictionary_changes/src/com/tresys/framework/compiler/CLIProjectErrorHandler.java (modified) (1 diff)
- branches/dictionary_changes/src/com/tresys/framework/compiler/Compiler.java (modified) (5 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/ErrorHandler.java (modified) (1 diff)
- branches/dictionary_changes/src/com/tresys/framework/compiler/ProjectErrorHandler.java (modified) (1 diff)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefn.java (modified) (3 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefnGroup.java (modified) (5 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessTarget.java (modified) (3 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Dictionary.java (modified) (3 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/DictionaryValidator.java (added)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/EntryAccessDefn.java (modified) (7 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/EntryAccessTarget.java (modified) (3 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Entrypoint.java (modified) (4 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/IDictionaryVisitable.java (deleted)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/PermVector.java (modified) (3 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Rdef.java (modified) (4 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/TranslatorDictionary.java (deleted)
- branches/dictionary_changes/src/com/tresys/framework/compiler/translator/SELinuxDictionary.java (added)
- branches/dictionary_changes/src/com/tresys/framework/compiler/translator/SELinuxPolicy.java (moved) (moved from branches/dictionary_changes/src/com/tresys/framework/compiler/translator/TranslatorSELinux.java) (2 diffs)
- branches/dictionary_changes/src/com/tresys/framework/plugin/builder/FrameworkNature.java (modified) (3 diffs)
- branches/dictionary_changes/src/com/tresys/framework/plugin/builder/GUIErrorHandler.java (modified) (1 diff)
- branches/dictionary_changes/src/com/tresys/framework/plugin/builder/GUIProjectErrorHandler.java (modified) (5 diffs)
- branches/dictionary_changes/src/com/tresys/framework/plugin/builder/SELinuxSystem.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dictionary_changes/src/com/tresys/framework/compiler/CLIProjectErrorHandler.java
r1825 r1946 6 6 * 7 7 * Compiler: Compiler main 8 * Version: @version@ 9 */package com.tresys.framework.compiler; 8 * 9 * $Rev$ 10 * $Date$ 11 */ 10 12 11 p ublic class CLIProjectErrorHandler implements ProjectErrorHandler {13 package com.tresys.framework.compiler; 12 14 13 public void ProjectError(String message) { 14 System.err.println("error: " + message); 15 System.exit(1); 15 public class CLIProjectErrorHandler 16 extends ProjectErrorHandler 17 { 18 19 public void ProjectError (String message) 20 { 21 System.err.println ("error: " + message); 22 m_nErrorCount ++; 16 23 } 17 24 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 ++; 20 29 } 21 30 31 public void CriticalError (String message) 32 { 33 ProjectError (message); 34 System.exit (1); 35 } 36 22 37 } branches/dictionary_changes/src/com/tresys/framework/compiler/Compiler.java
r1942 r1946 23 23 24 24 import com.tresys.framework.compiler.dictionary.Dictionary; 25 import com.tresys.framework.compiler.dictionary. TranslatorDictionary;25 import com.tresys.framework.compiler.dictionary.DictionaryValidator; 26 26 import com.tresys.framework.compiler.linkage.Linkage; 27 27 import com.tresys.framework.compiler.policy.Policy; 28 28 import com.tresys.framework.compiler.systemResources.SystemResources; 29 import com.tresys.framework.compiler.translator.TranslatorSELinux; 29 import com.tresys.framework.compiler.translator.SELinuxDictionary; 30 import com.tresys.framework.compiler.translator.SELinuxPolicy; 30 31 31 32 /** … … 317 318 Linkage linkage = null; 318 319 // the translator 319 TranslatorSELinuxtranslator = null;320 SELinuxPolicy translator = null; 320 321 321 322 dictSourceFilenames = new Vector/* <String> */(); … … 364 365 365 366 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 ()) 367 373 { 368 374 ErrorExit ("Dictionary validation failed, exiting..."); … … 451 457 if (dictionarySupportFile != null) 452 458 { 453 TranslatorDictionary dictTrans = new TranslatorDictionary ();459 SELinuxDictionary dictTrans = new SELinuxDictionary (); 454 460 dictionary.Accept (dictTrans); 455 461 … … 470 476 471 477 } 472 translator = new TranslatorSELinux(linkage, moduleName, fcFile);478 translator = new SELinuxPolicy (linkage, moduleName, fcFile); 473 479 474 480 policy.Accept (translator); branches/dictionary_changes/src/com/tresys/framework/compiler/ErrorHandler.java
r1938 r1946 38 38 static final public int ERROR_DUPLICATE_ACCESS = 29; 39 39 static final public int ERROR_UNABLE_TO_GET_TYPE_FROM_PATH = 30; 40 41 40 41 42 42 protected int warningCount = 0; 43 43 branches/dictionary_changes/src/com/tresys/framework/compiler/ProjectErrorHandler.java
r1825 r1946 1 1 /* 2 * Copyright (C) 2005-200 6Tresys Technology, LLC2 * Copyright (C) 2005-2008 Tresys Technology, LLC 3 3 * License: refer to COPYING file for license information. 4 4 * Author: James Athey <jathey@tresys.com> 5 5 * 6 6 * Compiler: Compiler main 7 * Version: @version@ 7 * 8 * $Rev$ 9 * $Date$ 8 10 */ 9 11 10 12 package com.tresys.framework.compiler; 11 13 12 public interface ProjectErrorHandler { 13 public void ProjectWarning(String message); 14 public abstract class ProjectErrorHandler 15 { 16 protected int m_nWarningCount = 0; 17 protected int m_nErrorCount = 0; 14 18 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 } 16 34 } branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefn.java
r1942 r1946 13 13 14 14 import com.tresys.framework.compiler.AbstractToken; 15 import com.tresys.framework.compiler.linkage.Linkage;16 15 17 16 import java.util.Collection; … … 36 35 */ 37 36 public final class AccessDefn 38 implements Comparable/* <AccessDefn> */, INameValue , IDictionaryVisitable37 implements Comparable/* <AccessDefn> */, INameValue 39 38 { 40 39 … … 225 224 } 226 225 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 246 226 public int compareTo (Object o) 247 227 { branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefnGroup.java
r1942 r1946 21 21 22 22 import com.tresys.framework.compiler.AbstractToken; 23 import com.tresys.framework.compiler.linkage.Linkage;24 23 25 24 /** 26 * This class represents a group of access definitions in a FObject. An27 * 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). 28 27 * <p> 29 28 * 30 29 * @see AccessDefn 31 * @see AccessTarget 32 * @see PermVector30 * @see AccessTarget 31 * @see PermVector 33 32 * @see Verb 34 33 */ 35 public final class AccessDefnGroup 36 implements IDictionaryVisitable 34 public final class AccessDefnGroup 37 35 { 38 36 39 37 /** The verb associated with the AccessDefnGroup */ 40 protected final Integer /* Verb*/verb;38 protected final Integer /* Verb */verb; 41 39 42 40 /** The fobejct this group is part of */ … … 46 44 47 45 // AccessResource definitions associated with this group 48 protected final Map/* <String, AccessDefn>*/accessDefns;46 protected final Map/* <String, AccessDefn> */accessDefns; 49 47 50 protected List/* <Token>*/defaultAccessDefns;48 protected List/* <Token> */defaultAccessDefns; 51 49 52 50 /** 53 51 * The default constructor requires a verb. 54 52 * 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 58 58 */ 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); 61 62 nameToken = tok; 62 accessDefns = new HashMap/* <String, AccessDefn>*/();63 defaultAccessDefns = new Vector/* <Token>*/();63 accessDefns = new HashMap/* <String, AccessDefn> */(); 64 defaultAccessDefns = new Vector/* <Token> */(); 64 65 this.rdef = rdef; 65 66 } … … 68 69 * Add an AccessDefn to this group. 69 70 * 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 74 76 */ 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 { 77 81 return 1; 78 82 } 79 accessDefns.put (ad.getName(), ad);83 accessDefns.put (ad.getName (), ad); 80 84 return 0; 81 85 } 82 86 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"); 91 97 return false; 92 98 } 93 99 } 94 100 95 defaultAccessDefns.add (access);101 defaultAccessDefns.add (access); 96 102 return true; 97 103 } … … 100 106 * Lookup an AccessDefn in this group. 101 107 * 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 106 113 */ 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); 109 117 } 110 118 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> */(); 113 122 AccessDefn defn; 114 123 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); 122 133 } 123 134 } … … 125 136 return defns; 126 137 } 127 138 128 139 public void Accept (IDictionaryVisitor i_visitor) 129 140 { 130 141 i_visitor.PreVisit (this); 131 132 for (Iterator itr = accessDefns.values ().iterator (); itr.hasNext (); )142 143 for (Iterator itr = accessDefns.values ().iterator (); itr.hasNext ();) 133 144 { 134 145 AccessDefn ad = (AccessDefn) itr.next (); 135 146 ad.Accept (i_visitor); 136 147 } 137 148 138 149 i_visitor.PostVisit (this); 139 150 } 140 151 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 { 172 154 return nameToken; 173 155 } 174 156 175 public Rdef getRdef() { 157 public Rdef getRdef () 158 { 176 159 return rdef; 177 160 } 178 161 179 public Integer getVerb() { 162 public Integer getVerb () 163 { 180 164 return verb; 181 165 } 182 166 183 public Map getAccessDefns() { 167 public Map getAccessDefns () 168 { 184 169 return accessDefns; 185 170 } 186 171 187 public String getName() { 172 public String getName () 173 { 188 174 return nameToken.image; 189 175 } branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessTarget.java
r1942 r1946 16 16 import java.util.TreeMap; 17 17 import java.util.Vector; 18 19 import com.tresys.framework.compiler.linkage.Linkage;20 18 21 19 /** … … 34 32 */ 35 33 public final class AccessTarget 36 implements IDictionaryVisitable37 34 { 38 35 … … 157 154 } 158 155 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 178 156 public static AccessTarget MergeAccessTargets (Collection/* <AccessTarget> */targets) 179 157 { branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Dictionary.java
r1942 r1946 13 13 14 14 import com.tresys.framework.compiler.ErrorHandler; 15 import com.tresys.framework.compiler.Utility;16 import com.tresys.framework.compiler.linkage.Linkage;17 15 18 16 import java.util.HashMap; … … 33 31 */ 34 32 public final class Dictionary 35 implements IDictionaryVisitable36 33 { 37 34 // A dictionary contains a set of rdefs … … 196 193 i_visitor.PostVisit (this); 197 194 } 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 entrypoint217 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 }226 195 } branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/EntryAccessDefn.java
r1942 r1946 17 17 18 18 import com.tresys.framework.compiler.AbstractToken; 19 import com.tresys.framework.compiler.linkage.Linkage;20 19 21 20 /** 22 21 * TODO: add javadoc commenting 23 22 */ 24 public final class EntryAccessDefn 25 implements Comparable/* <EntryAccessDefn>*/, INameValue , IDictionaryVisitable23 public final class EntryAccessDefn 24 implements Comparable/* <EntryAccessDefn> */, INameValue 26 25 { 27 26 … … 31 30 protected final AbstractToken m_Token; 32 31 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 */(); 34 36 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 */(); 36 41 37 /*38 private EntryAccessDefn() {39 Token = null;40 Name = "";41 }42 */43 42 /** 44 43 * AccessDefn constructor creates AccessDefn object and assigns name. 45 44 * 46 * @param n String value used to identify the AccessResource 45 * @param n 46 * String value used to identify the AccessResource 47 47 */ 48 public EntryAccessDefn(AbstractToken token) { 48 public EntryAccessDefn (AbstractToken token) 49 { 49 50 m_Token = token; 50 51 m_sName = token.image; … … 54 55 * Get EntryAccessTarget by EntryTarget 55 56 * 56 * @return AccessTarget if found, otherwise null57 * @return AccessTarget if found, otherwise null 57 58 */ 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); 60 62 } 61 63 62 64 /** 63 * Add an AccessTarget to this AccessDefn. 65 * Add an AccessTarget to this AccessDefn. 64 66 * 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 68 71 */ 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 { 71 76 return false; 72 77 } 73 EntryAccessTargets.put (targ.FlowTarget, targ);78 EntryAccessTargets.put (targ.FlowTarget, targ); 74 79 return true; 75 80 } … … 78 83 * Add a NameValuePair metadata object. 79 84 * 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. 83 89 */ 84 public boolean AddNameValuePair(NameValuePair /*<?>*/pair) { 90 public boolean AddNameValuePair (NameValuePair /* <?> */pair) 91 { 85 92 // insert nvp into pairs map 86 if(NameValuePairs.containsKey(pair.GetName())) { 93 if (NameValuePairs.containsKey (pair.GetName ())) 94 { 87 95 return false; 88 96 } 89 97 90 NameValuePairs.put (pair.GetName(), pair);98 NameValuePairs.put (pair.GetName (), pair); 91 99 return true; 92 100 } … … 95 103 * Retrieve the name/value associated with the name. 96 104 * 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 99 108 */ 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); 102 112 } 103 113 104 114 /** 105 115 * Get the Map of name/value pairs. 106 * 107 * @return NameValuePairs associated with object116 * 117 * @return NameValuePairs associated with object 108 118 */ 109 public Map/*<String, NameValuePair<?>>*/GetNameValuePairs() { 119 public Map/* <String, NameValuePair<?>> */GetNameValuePairs () 120 { 110 121 return NameValuePairs; 111 122 } 112 123 113 124 /** 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. 117 128 * 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. 121 134 */ 122 public boolean IsSubsetOf(EntryAccessDefn other) { 123 if(other == null) { 135 public boolean IsSubsetOf (EntryAccessDefn other) 136 { 137 if (other == null) 138 { 124 139 return false; 125 140 } 126 141 // 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 (); 131 150 // 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 { 136 157 return false; 137 158 } 138 159 139 } else { 160 } 161 else 162 { 140 163 return false; 141 164 } … … 147 170 { 148 171 i_visitor.PreVisit (this); 149 150 for (Iterator itr = EntryAccessTargets.values ().iterator (); itr.hasNext (); )172 173 for (Iterator itr = EntryAccessTargets.values ().iterator (); itr.hasNext ();) 151 174 { 152 175 EntryAccessTarget eat = (EntryAccessTarget) itr.next (); 153 176 eat.Accept (i_visitor); 154 177 } 155 178 156 179 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;174 180 } 175 181 … … 178 184 return m_sName; 179 185 } 180 186 181 187 public AbstractToken getToken () 182 188 { 183 189 return m_Token; 184 190 } 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); 188 195 } 189 196 } branches/dictionary_changes/src/com/tresys/framework/compiler/
