Changeset 1942
- Timestamp:
- 02/21/08 07:25:57 (9 months ago)
- Files:
-
- branches/dictionary_changes/src/com/tresys/framework/compiler/Compiler.java (modified) (5 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefn.java (modified) (2 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefnGroup.java (modified) (2 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessTarget.java (modified) (4 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Dictionary.java (modified) (8 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/EntryAccessDefn.java (modified) (2 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/EntryAccessTarget.java (modified) (2 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Entrypoint.java (modified) (5 diffs)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/IDictionaryVisitable.java (added)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/IDictionaryVisitor.java (added)
- branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/PermVector.java (modified) (2 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 (added)
- branches/dictionary_changes/src/com/tresys/framework/compiler/translator/TranslatorSELinux.java (modified) (15 diffs)
- branches/dictionary_changes/src/com/tresys/framework/plugin/builder/SELinuxSystem.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dictionary_changes/src/com/tresys/framework/compiler/Compiler.java
r1938 r1942 23 23 24 24 import com.tresys.framework.compiler.dictionary.Dictionary; 25 import com.tresys.framework.compiler.dictionary.TranslatorDictionary; 25 26 import com.tresys.framework.compiler.linkage.Linkage; 26 27 import com.tresys.framework.compiler.policy.Policy; … … 52 53 static String ifFilename = null; 53 54 55 static String dictionarySupportFile = null; 56 54 57 static String libPath = System.getProperty ("user.dir") + "/libselinuxjava/libselinuxjava.so"; 55 58 … … 169 172 fcOutputFilename = args[x]; 170 173 } 174 else 175 { 176 printUsage (); 177 System.exit (1); 178 } 179 } 180 else if (args[x].equals ("-do")) 181 { 182 x++; 183 if (x < args.length) 184 dictionarySupportFile = args[x]; 171 185 else 172 186 { … … 250 264 private static void printUsage () 251 265 { 252 System.out.println (" SEFramework compiler usage:\n");266 System.out.println ("CDSFramework compiler usage:\n"); 253 267 System.out.println ("java com.tresys.framework.compiler.Compiler [-h] [-v]\n" 254 268 + "[-lib <dir/libselinuxjava.so>]\n" + "[-fc <file_context>] -pc <policy.conf>\n" 255 269 + "[-ds <dictionary source> [-do <dictionary output>]]\n" 256 + "[- dc <compiled dictionary>]\n" + "[-p <policy>] [-po output]\n"270 + "[-p <policy>] [-po output]\n" 257 271 + "[-s <system resource source>] [-sf <generated file context output file>]"); 258 System.out.println ("\nGeneral arguments:"); 272 System.out.println (); 273 System.out.println ("General arguments:"); 259 274 System.out.println (" -h display this message and exit"); 260 275 System.out.println (" -v display verbose output"); 261 System.out 262 .println (" -lib <libselinuxjava.so> specify path to libselinuxjava.so library to be loaded"); 263 System.out.println ("\nGlobal arguments:"); 276 System.out.println (" -lib <libselinuxjava.so> specify path to libselinuxjava.so library to be"); 277 System.out.println (" loaded"); 278 System.out.println (); 279 System.out.println ("Global arguments:"); 264 280 System.out.println (" -pc <flaskPath> specify path to base policy flask directory"); 265 281 System.out.println (" -fc <file_context> specify base policy file_context"); 266 System.out.println ("\nDictionary arguments:"); 282 System.out.println (); 283 System.out.println ("Dictionary arguments:"); 267 284 System.out.println (" -ds <dictionary source> specify source file for dictionary"); 268 System.out.println ("\nPolicy arguments:"); 285 System.out.println (); 286 System.out.println ("Policy arguments:"); 269 287 System.out.println (" -p <policy source> specify source file for policy parsing"); 270 System.out 271 .println (" -po <output file> specify output file for translated policy output (defaults to stdout if not specified)"); 272 System.out 273 .println (" -if <interface file> specify interface file for linkage to reference policy and exposing an external API (defaults to stdout if not specified)"); 274 System.out.println ("\nSystem resource arguments:"); 288 System.out.println (" -po <output file> specify output file for translated policy output"); 289 System.out.println (" (defaults to stdout if not specified)"); 290 System.out.println (" -if <interface file> specify interface file for linkage to reference policy"); 291 System.out.println (" and exposing an external API (defaults to stdout if not specified)"); 292 System.out.println (); 293 System.out.println ("System resource arguments:"); 275 294 System.out.println (" -s <system resource source> specify source file for system parsing"); 276 System.out 277 .println (" -sf <fcoutput file> specify output file for file context output (defaults to stdout if not specified)"); 278 System.out.println ("\nOutput arguments (repeated here for reference):"); 279 System.out 280 .println (" -do <dictionary output> specify destination file for dictionary storage"); 281 System.out 282 .println (" -po <output file> specify output file for translated policy output (defaults to stdout if not specified)"); 283 System.out 284 .println (" -sf <fcoutput file> specify output file for file context output (defaults to stdout if not specified)"); 285 System.out 286 .println (" -if <interface file> specify interface file for linkage to reference policy and exposing an external API (defaults to stdout if not specified)"); 287 System.out.println ("\nA dictionary file must be specified."); 295 System.out.println (" -sf <fcoutput file> specify output file for file context output"); 296 System.out.println (" (defaults to stdout if not specified)"); 297 System.out.println (); 298 System.out.println ("Output arguments (repeated here for reference):"); 299 System.out.println (" -do <dictionary output> specify destination for dictionary (spt) support file"); 300 System.out.println (" -po <output file> specify output file for translated policy output"); 301 System.out.println (" (defaults to stdout if not specified)"); 302 System.out.println (" -sf <fcoutput file> specify output file for file context output"); 303 System.out.println (" (defaults to stdout if not specified)"); 304 System.out.println (" -if <interface file> specify interface file for linkage to reference policy"); 305 System.out.println (" and exposing an external API (defaults to stdout if not specified)"); 306 System.out.println (); 307 System.out.println ("A dictionary file must be specified."); 288 308 } 289 309 … … 429 449 moduleName = moduleName.substring (slash + 1); 430 450 451 if (dictionarySupportFile != null) 452 { 453 TranslatorDictionary dictTrans = new TranslatorDictionary (); 454 dictionary.Accept (dictTrans); 455 456 PrintStream streamDictionary = null; 457 try 458 { 459 streamDictionary = new PrintStream (new FileOutputStream (dictionarySupportFile)); 460 System.out.println ("Writing dictionary translation to " + dictionarySupportFile + "..."); 461 streamDictionary.print (dictTrans.getDictionary ().toString ()); 462 streamDictionary.flush (); 463 streamDictionary.close (); 464 } 465 catch (FileNotFoundException e) 466 { 467 // ErrorExit (e.getMessage ()); 468 469 } 470 471 } 431 472 translator = new TranslatorSELinux (linkage, moduleName, fcFile); 432 473 433 474 policy.Accept (translator); 434 475 476 435 477 final OutputStream teData = translator.GetPolicy (); 436 478 final OutputStream ifData = translator.GetInterfaces (); branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefn.java
r1938 r1942 36 36 */ 37 37 public final class AccessDefn 38 implements Comparable/* <AccessDefn> */, INameValue 38 implements Comparable/* <AccessDefn> */, INameValue, IDictionaryVisitable 39 39 { 40 40 … … 212 212 } 213 213 214 public void Accept (IDictionaryVisitor i_visitor) 215 { 216 i_visitor.PreVisit (this); 217 218 for (Iterator itr = getAccessTargets ().values ().iterator (); itr.hasNext (); ) 219 { 220 AccessTarget target = (AccessTarget) itr.next (); 221 target.Accept (i_visitor); 222 } 223 224 i_visitor.PostVisit (this); 225 } 226 214 227 /** 215 228 * Test AccessDefn for validity. branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefnGroup.java
r1878 r1942 34 34 */ 35 35 public final class AccessDefnGroup 36 implements IDictionaryVisitable 36 37 { 37 38 … … 124 125 return defns; 125 126 } 127 128 public void Accept (IDictionaryVisitor i_visitor) 129 { 130 i_visitor.PreVisit (this); 131 132 for (Iterator itr = accessDefns.values ().iterator (); itr.hasNext (); ) 133 { 134 AccessDefn ad = (AccessDefn) itr.next (); 135 ad.Accept (i_visitor); 136 } 137 138 i_visitor.PostVisit (this); 139 } 126 140 127 141 /** branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessTarget.java
r1938 r1942 5 5 * 6 6 * AccessTarget.java: AccessResource target class 7 * Version: @version@ 7 * 8 * $Rev$ 9 * $Date$ 8 10 */ 9 11 package com.tresys.framework.compiler.dictionary; … … 18 20 19 21 /** 20 * This class represents an access target definition in a FObject. An22 * This class represents an access target definition in a FObject. An 21 23 * AccessTarget refers to one named information flow sub-group and its 22 * PermVector(s). 24 * PermVector(s). 23 25 * <p> 24 26 * Syntatically (each line is a separate AccessTarget):<br> 25 * <code>resource { file { read getattr lock } dir { search read } }<br>27 * <code>resource { file { read getattr lock } dir { search read } }<br> 26 28 * self { PermVectors... }<br> 27 29 * other verb { PermVectors... }<br> 28 30 * </code> 29 31 * 30 * @see PermVector32 * @see PermVector 31 33 * @see AccessDefn 32 34 */ 33 public final class AccessTarget { 35 public final class AccessTarget 36 implements IDictionaryVisitable 37 { 34 38 35 39 /** The info. flow target associated with the instance of the class */ 36 protected final/* Target*/Integer TargetName;40 protected final/* Target */Integer TargetName; 37 41 38 42 /** Map of PermVectors (default comparison operator used) */ 39 private final Map/* <String, PermVector>*/permvectors;43 private final Map/* <String, PermVector> */permvectors; 40 44 41 45 /** 42 46 * Default constructor for AccessTarget. 43 * 44 * @param target Information flow target. 45 */ 46 public AccessTarget(Integer /*Target*/target) { 47 permvectors = new TreeMap/*<String, PermVector>*/(); 47 * 48 * @param target 49 * Information flow target. 50 */ 51 public AccessTarget (Integer /* Target */target) 52 { 53 permvectors = new TreeMap/* <String, PermVector> */(); 48 54 TargetName = target; 49 55 } … … 51 57 /** 52 58 * Add a PermVector to this object. 53 * 54 * @param vector is the PermVector to add to the AccessType 55 * @return <code>true</code> if permission vector successfully 56 * inserted, <code>false</code> otherwise 57 * @see PermVector 58 */ 59 public boolean AddPermVector(PermVector vector) { 59 * 60 * @param vector 61 * is the PermVector to add to the AccessType 62 * @return <code>true</code> if permission vector successfully inserted, 63 * <code>false</code> otherwise 64 * @see PermVector 65 */ 66 public boolean AddPermVector (PermVector vector) 67 { 60 68 // add if TEVector has not been previously defined for this component 61 if(permvectors.containsKey(vector.getObjectClass())) { 69 if (permvectors.containsKey (vector.getObjectClass ())) 70 { 62 71 return false; 63 72 } 64 permvectors.put (vector.getObjectClass(), vector);73 permvectors.put (vector.getObjectClass (), vector); 65 74 return true; 66 75 } 67 76 68 public Integer getTargetName() { 77 public Integer getTargetName () 78 { 69 79 return TargetName; 70 80 } 71 81 72 82 /** 73 * Get Permission Vectors(s) 74 * 75 * @return Map of PermVector(s) 76 */ 77 public Map/*<String, PermVector>*/GetPermVectors() { 83 * Get Permission Vectors(s) 84 * 85 * @return Map of PermVector(s) 86 */ 87 public Map/* <String, PermVector> */GetPermVectors () 88 { 78 89 return permvectors; 79 90 } 80 91 81 92 /** 82 * Get Permission Vector by object class 83 * 84 * @param objClass The object class for this PermVector 85 * @return PermVector if found, null otherwise 86 */ 87 public PermVector GetPermVector(String objClass) { 88 return (PermVector) permvectors.get(objClass); 89 } 90 91 /** 92 * Check to ensure this instance is a subset of another. In other words, 93 * this method returns <code>true</code> when the parameter passed to this 94 * method is a superset of this instance. 95 * 96 * @param other Another AccessTarget instance to perform comparison against. 97 * @return <code>true</code> if this instance is a subset of other, 98 * <code>false</code> otherwise. 99 */ 100 public boolean IsSubsetOf(AccessTarget other) { 101 if(other == null) { 93 * Get Permission Vector by object class 94 * 95 * @param objClass 96 * The object class for this PermVector 97 * @return PermVector if found, null otherwise 98 */ 99 public PermVector GetPermVector (String objClass) 100 { 101 return (PermVector) permvectors.get (objClass); 102 } 103 104 /** 105 * Check to ensure this instance is a subset of another. In other words, 106 * this method returns <code>true</code> when the parameter passed to this 107 * method is a superset of this instance. 108 * 109 * @param other 110 * Another AccessTarget instance to perform comparison against. 111 * @return <code>true</code> if this instance is a subset of other, 112 * <code>false</code> otherwise. 113 */ 114 public boolean IsSubsetOf (AccessTarget other) 115 { 116 if (other == null) 117 { 102 118 return false; 103 119 } 104 120 // iterate over perm vectors checking for superset 105 /*for (Map.Entry<String, PermVector> mapEntry: this.permvectors.entrySet())*/ 106 Iterator iter = this.permvectors.entrySet().iterator(); 107 while(iter.hasNext()) { 108 Map.Entry mapEntry = (Map.Entry) iter.next(); 121 /* 122 * for (Map.Entry<String, PermVector> mapEntry: 123 * this.permvectors.entrySet()) 124 */ 125 Iterator iter = this.permvectors.entrySet ().iterator (); 126 while (iter.hasNext ()) 127 { 128 Map.Entry mapEntry = (Map.Entry) iter.next (); 109 129 // if it has a corresponding permVector check that permVector 110 if(other.permvectors.containsKey(mapEntry.getKey())) { 111 if(!((AccessTarget) mapEntry.getValue()) 112 .IsSubsetOf((AccessTarget) other.permvectors.get(mapEntry 113 .getKey()))) { 130 if (other.permvectors.containsKey (mapEntry.getKey ())) 131 { 132 if (! ((AccessTarget) mapEntry.getValue ()) 133 .IsSubsetOf ((AccessTarget) other.permvectors.get (mapEntry.getKey ()))) 134 { 114 135 return false; 115 136 } 116 } else { 137 } 138 else 139 { 117 140 return false; 118 141 } … … 121 144 } 122 145 146 public void Accept (IDictionaryVisitor i_visitor) 147 { 148 i_visitor.PreVisit (this); 149 150 for (Iterator itr = GetPermVectors ().values ().iterator (); itr.hasNext ();) 151 { 152 PermVector perms = (PermVector) itr.next (); 153 perms.Accept (i_visitor); 154 } 155 156 i_visitor.PostVisit (this); 157 } 158 123 159 /** 124 160 * Test AccessTarget for validity. 125 * 126 * @return <code>true</code> if target is valid. 127 */ 128 final boolean Validate(Linkage linkage) { 161 * 162 * @return <code>true</code> if target is valid. 163 */ 164 final boolean Validate (Linkage linkage) 165 { 129 166 boolean valid = true; 130 167 131 /*for (PermVector pv:permvectors.values())*/ 132 Iterator iter = permvectors.values().iterator(); 133 while(iter.hasNext()) { 134 PermVector pv = (PermVector) iter.next(); 135 valid &= pv.Validate(linkage); 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); 136 174 } 137 175 return valid; 138 176 } 139 177 140 public static AccessTarget MergeAccessTargets (Collection/*<AccessTarget>*/targets) 141 { 142 Map/*<String, Vector<PermVector>>*/pvMap = new TreeMap/*<String, Vector<PermVector>>*/(); 143 Integer /*Target*/name = null; 144 145 /*for (AccessTarget target:targets)*/ 146 Iterator iter = targets.iterator(); 147 while(iter.hasNext()) { 148 AccessTarget target = (AccessTarget) iter.next(); 149 if(name == null) { 178 public static AccessTarget MergeAccessTargets (Collection/* <AccessTarget> */targets) 179 { 180 Map/* <String, Vector<PermVector>> */pvMap = new TreeMap/* 181 * <String, 182 * Vector<PermVector>> 183 */(); 184 Integer /* Target */name = null; 185 186 /* for (AccessTarget target:targets) */ 187 Iterator iter = targets.iterator (); 188 while (iter.hasNext ()) 189 { 190 AccessTarget target = (AccessTarget) iter.next (); 191 if (name == null) 192 { 150 193 name = target.TargetName; 151 194 } // assuming all targets have the same TargetName 152 195 153 /*for (PermVector pv:target.GetPermVectors().values())*/ 154 Iterator iter2 = target.GetPermVectors().values().iterator(); 155 while(iter2.hasNext()) { 156 PermVector pv = (PermVector) iter2.next(); 157 Vector/*<PermVector>*/unmergedVectors; 158 159 if((unmergedVectors = (Vector) pvMap.get(pv.getObjectClass())) == null) { 160 unmergedVectors = new Vector/*<PermVector>*/(); 161 pvMap.put(pv.getObjectClass(), unmergedVectors); 196 /* for (PermVector pv:target.GetPermVectors().values()) */ 197 Iterator iter2 = target.GetPermVectors ().values ().iterator (); 198 while (iter2.hasNext ()) 199 { 200 PermVector pv = (PermVector) iter2.next (); 201 Vector/* <PermVector> */unmergedVectors; 202 203 if ( (unmergedVectors = (Vector) pvMap.get (pv.getObjectClass ())) == null) 204 { 205 unmergedVectors = new Vector/* <PermVector> */(); 206 pvMap.put (pv.getObjectClass (), unmergedVectors); 162 207 } 163 208 164 unmergedVectors.add(pv); 165 } 166 } 167 168 AccessTarget merged = new AccessTarget(name); 169 170 /*for (Vector<PermVector> unmergedVectors:pvMap.values())*/ 171 iter = pvMap.values().iterator(); 172 while(iter.hasNext()) { 173 Vector unmergedVectors = (Vector) iter.next(); 174 try { 175 merged.AddPermVector(PermVector 176 .MergePermVectors(unmergedVectors)); 177 } catch (Exception ex) { } 209 unmergedVectors.add (pv); 210 } 211 } 212 213 AccessTarget merged = new AccessTarget (name); 214 215 /* for (Vector<PermVector> unmergedVectors:pvMap.values()) */ 216 iter = pvMap.values ().iterator (); 217 while (iter.hasNext ()) 218 { 219 Vector unmergedVectors = (Vector) iter.next (); 220 try 221 { 222 merged.AddPermVector (PermVector.MergePermVectors (unmergedVectors)); 223 } 224 catch (Exception ex) 225 {} 178 226 } 179 227 branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/Dictionary.java
r1710 r1942 6 6 * 7 7 * Dictionary.java: Contains all objects from a single dictionary 8 * Version: @version@ 8 * 9 * $Rev$ 10 * $Date$ 9 11 */ 10 12 package com.tresys.framework.compiler.dictionary; … … 23 25 24 26 /** 25 * The Dictionary class represents an entire SEFramework 26 * dictionary file: the FObjects, the entrypoints, and any27 * other information that is part of adictionary.28 * 27 * The Dictionary class represents an entire SEFramework dictionary file: the 28 * FObjects, the entrypoints, and any other information that is part of a 29 * dictionary. 30 * 29 31 * @see AccessDefn 30 32 * @see Rdef 31 33 */ 32 public final class Dictionary { 34 public final class Dictionary 35 implements IDictionaryVisitable 36 { 33 37 // A dictionary contains a set of rdefs 34 private final Map/* <String, Rdef>*/rdefs;38 private final Map/* <String, Rdef> */rdefs; 35 39 36 40 /** A single entrypoint object */ … … 38 42 39 43 /** 40 * Dictionary object constructor 41 */ 42 public Dictionary() { 44 * Dictionary object constructor 45 */ 46 public Dictionary () 47 { 43 48 // initialize the dictionary contents 44 rdefs = new HashMap/* <String, Rdef>*/();49 rdefs = new HashMap/* <String, Rdef> */(); 45 50 } 46 51 … … 48 53 * Add the FObjects in a dictionary source file to the Dictionary. 49 54 * 50 * @param dictFilename dictionary filename 51 * @param outFilename dictionary output filename or <code>null</code> 52 * if compiled dictionary file is not to be created. 53 * @param errorHandler error handler for the given stream 54 */ 55 public void AddDictionaryFile(String dictFilename, ErrorHandler errorHandler) { 56 try { 57 DictionaryParser parser = new DictionaryParser(this); 58 File dictFile = new File(dictFilename); 59 if(dictFile.exists() && dictFile.isFile() && dictFile.canRead()) 60 parser.Parse(new FileReader(dictFilename), errorHandler); 55 * @param dictFilename 56 * dictionary filename 57 * @param outFilename 58 * dictionary output filename or <code>null</code> if compiled 59 * dictionary file is not to be created. 60 * @param errorHandler 61 * error handler for the given stream 62 */ 63 public void AddDictionaryFile (String dictFilename, ErrorHandler errorHandler) 64 { 65 try 66 { 67 DictionaryParser parser = new DictionaryParser (this); 68 File dictFile = new File (dictFilename); 69 if (dictFile.exists () && dictFile.isFile () && dictFile.canRead ()) 70 parser.Parse (new FileReader (dictFilename), errorHandler); 61 71 else 62 errorHandler.CriticalError("Critical error opening file: " 63 + dictFilename + " not found or is not a file"); 64 } catch (java.io.FileNotFoundException e) { 65 errorHandler.CriticalError(e.toString() 66 + "\nCritical error opening file: " + dictFilename 67 + " not found"); 68 } catch (Exception e) { 69 errorHandler.CriticalError(e.toString() 70 + "\nCritical error opening file: " + dictFilename); 72 errorHandler.CriticalError ("Critical error opening file: " + dictFilename 73 + " not found or is not a file"); 74 } 75 catch (java.io.FileNotFoundException e) 76 { 77 errorHandler.CriticalError (e.toString () + "\nCritical error opening file: " 78 + dictFilename + " not found"); 79 } 80 catch (Exception e) 81 { 82 errorHandler.CriticalError (e.toString () + "\nCritical error opening file: " 83 + dictFilename); 71 84 } 72 85 } … … 75 88 * Add the FObjects in a dictionary stream to the Dictionary. 76 89 * 77 * @param dictStream dictionary input stream 78 * @param errorHandler error handler for the given stream 79 */ 80 public void AddDictionaryReader(Reader dictReader, ErrorHandler errorHandler) { 81 try { 82 DictionaryParser parser = new DictionaryParser(this); 83 84 parser.Parse(dictReader, errorHandler); 85 } catch (Exception e) { 86 errorHandler.CriticalError(e.getMessage()); 90 * @param dictStream 91 * dictionary input stream 92 * @param errorHandler 93 * error handler for the given stream 94 */ 95 public void AddDictionaryReader (Reader dictReader, ErrorHandler errorHandler) 96 { 97 try 98 { 99 DictionaryParser parser = new DictionaryParser (this); 100 101 parser.Parse (dictReader, errorHandler); 102 } 103 catch (Exception e) 104 { 105 errorHandler.CriticalError (e.getMessage ()); 87 106 } 88 107 } … … 91 110 * Adds a Rdef to the dictionary. 92 111 * 93 * @param rdef Rdef to be inserted into dictionary object 94 * @return <code>true</code> on successful insertion, 95 * <code>false</code> otherwise. 96 * @see Rdef 97 */ 98 public boolean Add(Rdef rdef) { 99 String _name = rdef.GetName(); 112 * @param rdef 113 * Rdef to be inserted into dictionary object 114 * @return <code>true</code> on successful insertion, <code>false</code> 115 * otherwise. 116 * @see Rdef 117 */ 118 public boolean Add (Rdef rdef) 119 { 120 String _name = rdef.GetName (); 100 121 101 122 // test for duplicate name 102 if (rdefs.containsKey(_name)) {103 rdef.GetToken().Error(104 "Failed to insert Rdef in dictionary. Duplicate found");123 if (rdefs.containsKey (_name)) 124 { 125 rdef.GetToken ().Error ("Failed to insert Rdef in dictionary. Duplicate found"); 105 126 return false; 106 127 } 107 128 // insert unique rdef 108 rdefs.put (_name, rdef);129 rdefs.put (_name, rdef); 109 130 return true; 110 131 } … … 112 133 /** 113 134 * Check to see if Dictionary contains dictionary object. 114 * 115 * @param name String identifying dictionary object to be referenced 116 * @return Boolean <code>true</code> if dictionary object identified by name 117 * is found in Dictionary, <code>false</code> otherwise 118 * @see IDictionaryObject 119 * @see Rdef 120 * @see Extern 121 */ 122 public boolean ContainsDictionaryObject(String name) { 123 return(rdefs.containsKey(name)); 124 } 125 126 /** 127 * Lookup a Rdef in the Dictionary. 128 * 129 * @param name String identifying Rdef to retrieve 130 * @return Rdef identified by name or <code>null</code> 131 * if name not found 132 * @see Rdef 133 */ 134 public Rdef GetRdef(String name) { 135 return (Rdef) rdefs.get(name); 136 } 137 138 public Entrypoint GetEntrypoint() { 135 * 136 * @param name 137 * String identifying dictionary object to be referenced 138 * @return Boolean <code>true</code> if dictionary object identified by 139 * name is found in Dictionary, <code>false</code> otherwise 140 * @see IDictionaryObject 141 * @see Rdef 142 * @see Extern 143 */ 144 public boolean ContainsDictionaryObject (String name) 145 { 146 return (rdefs.containsKey (name)); 147 } 148 149 /** 150 * Lookup a Rdef in the Dictionary. 151 * 152 * @param name 153 * String identifying Rdef to retrieve 154 * @return Rdef identified by name or <code>null</code> if name not found 155 * @see Rdef 156 */ 157 public Rdef GetRdef (String name) 158 { 159 return (Rdef) rdefs.get (name); 160 } 161 162 public Entrypoint GetEntrypoint () 163 { 139 164 return Entrypoint; 140 165 } … … 144 169 Entrypoint = i_ep; 145 170 } 171 172 /** 173 * Get all rdefs in the Dictionary. 174 * 175 * @return A Map<String, Rdef> of rdefs 176 * @see Rdef 177 */ 178 public Map/* <String, Rdef> */GetRdefs () 179 { 180 return rdefs; 181 } 146 182 147 /** 148 * Get all rdefs in the Dictionary. 149 * 150 * @return A Map<String, Rdef> of rdefs 151 * @see Rdef 152 */ 153 public Map/*<String, Rdef>*/GetRdefs() { 154 return rdefs; 183 public void Accept (IDictionaryVisitor i_visitor) 184 { 185 i_visitor.PreVisit (this); 186 187  
