Changeset 1938

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

beginning work on ticket:164 and ticket:165 - dictionary changes for dynamically labeling files at runtime and allowing file resources.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dictionary_changes/resources/dictionary/dictionary.fdic

    r1768 r1938  
    7575                        } 
    7676                } 
     77                new 
     78                [desc : "Create new file in directory"] 
     79                { 
     80                        resource { 
     81                                dir { read getattr lock search ioctl add_name remove_name write } 
     82                        } 
     83                        transition { 
     84                                dir 
     85                                file 
     86                        } 
     87                } 
     88        } 
     89} 
     90 
     91rdef file 
     92[desc: "a single file"] 
     93{ 
     94        requires { file } 
     95        owner { 
     96                resource { 
     97                        file { append  getattr ioctl link lock read rename setattr unlink write } 
     98                        lnk_file { append  getattr ioctl link lock read rename setattr unlink write } 
     99                } 
     100        } 
     101        read { 
     102                default { read } 
     103                read  
     104                [desc: "Read data from file"] 
     105                [backflow : 0 ] 
     106                { 
     107                        resource { 
     108                                file { read getattr } 
     109                                lnk_file { read } 
     110                        } 
     111                } 
     112                execute 
     113                [desc: "Execute file"] 
     114                [backflow : 0 ] 
     115                { 
     116                        resource { 
     117                                file { read getattr execute } 
     118                                lnk_file { read } 
     119                        } 
     120                } 
     121        } 
     122        write { 
     123                default { write } 
     124                write 
     125                [desc: "Write to file"] 
     126                [backflow : 1] 
     127                { 
     128                        resource { 
     129                                file { append lock write  } 
     130                                lnk_file { append lock write } 
     131                        } 
     132                } 
     133                append_only 
     134                [desc: "Append existing files"] 
     135                [backflow : 1] 
     136                { 
     137                        resource { 
     138                                file { append lock } 
     139                                lnk_file { append lock } 
     140                        } 
     141                } 
    77142        } 
    78143} 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/Compiler.java

    r1895 r1938  
    367367                        String policyFilename = (String) iter.next (); 
    368368                        System.out.println ("Parsing policy in " + polSourceFilenames); 
    369                         if (linkage != null && linkage.LNFILESPATH == null 
    370                                 && policyFilename.lastIndexOf ("/") > 0) 
    371                         { 
    372                                 linkage.LNFILESPATH = policyFilename 
    373                                         .substring (0, policyFilename.lastIndexOf ("/")); 
     369                        if (linkage != null) 
     370                        { 
     371                                if (policyFilename.lastIndexOf ("/") > 0) 
     372                                { 
     373                                        linkage.LNFILESPATH = policyFilename.substring (0, policyFilename.lastIndexOf ("/")); 
     374                                } 
    374375                        } 
    375376                        CLIErrorHandler policyHandler = new CLIErrorHandler (policyFilename); 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/ErrorHandler.java

    r1878 r1938  
    3737        static final public int ERROR_ENTRYPOINT_MISSING_FILE = 28; 
    3838        static final public int ERROR_DUPLICATE_ACCESS = 29; 
     39        static final public int ERROR_UNABLE_TO_GET_TYPE_FROM_PATH = 30; 
    3940         
    4041         
  • branches/dictionary_changes/src/com/tresys/framework/compiler/FSysGenerator.java

    r1878 r1938  
    6666                        return; 
    6767                 
    68                 Iterator rdefs = rdef_map.values().iterator(); 
    69                  
    70                 while (rdefs.hasNext())  
     68                for (Iterator rdefs = rdef_map.values().iterator(); rdefs.hasNext(); )  
    7169                { 
    7270                        Rdef rdef = (Rdef) rdefs.next(); 
    73                         if (rdef.GetSysResourceState(SystemResourceTypes.dir) == SysResourceState.No) 
     71                        if (rdef.GetSysResourceState(SystemResourceTypes.dir) == SysResourceState.No 
     72                                && rdef.GetSysResourceState (SystemResourceTypes.file) == SysResourceState.No) 
     73                        { 
    7474                                continue; 
     75                        } 
    7576 
    7677                        StringBuffer buff = new StringBuffer (); 
     
    114115                        return; 
    115116                 
    116                 Iterator rdefs = rdef_map.values().iterator(); 
    117                  
    118                 while (rdefs.hasNext())  
     117                for (Iterator rdefs = rdef_map.values().iterator(); rdefs.hasNext(); )  
    119118                { 
    120119                        Rdef rdef = (Rdef) rdefs.next(); 
    121                         if (rdef.GetSysResourceState(SystemResourceTypes.dir) == SysResourceState.No) 
     120                        if (rdef.GetSysResourceState(SystemResourceTypes.dir) == SysResourceState.No 
     121                                && rdef.GetSysResourceState (SystemResourceTypes.file) == SysResourceState.No) 
     122                        { 
    122123                                continue; 
    123  
     124                        } 
     125                         
    124126                        StringBuffer buff = new StringBuffer (); 
    125127                        buff.append(i_domain.getName()); 
     
    181183                        m_dataBuff.append("\""); 
    182184                        FileResource fres = (FileResource) iter.next(); 
    183                         m_dataBuff.append(fres.File.getPath()); 
     185                        m_dataBuff.append(fres.getFile ().getPath()); 
    184186 
    185187                        m_dataBuff.append("\" "); 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessDefn.java

    r1878 r1938  
    1515import com.tresys.framework.compiler.linkage.Linkage; 
    1616 
     17import java.util.Collection; 
     18import java.util.HashSet; 
    1719import java.util.Iterator; 
    1820import java.util.Map; 
     
    2022 
    2123/** 
    22  * This class represents an access definition in a Rdef. An AccessDefn in this 
    23  * case refers to one named set of information flow sub-groups.   
     24 * This class represents an access definition in a Rdef. An AccessDefn in this 
     25 * case refers to one named set of information flow sub-groups. 
    2426 * <p> 
    2527 * Syntactically:<br> 
     
    3032 *              }<br></code> 
    3133 *  
    32  * @see        NameValueGroup 
     34 * @see NameValueGroup 
    3335 * @see AccessTarget 
    3436 */ 
    35 public final class AccessDefn  
    36         implements Comparable/*<AccessDefn>*/, INameValue  
     37public final class AccessDefn 
     38        implements Comparable/* <AccessDefn> */, INameValue 
    3739{ 
    3840 
     
    4345 
    4446        // The information flow AccessTargets associated with this AccessDefn 
    45         protected final Map/*<Integer *//*Target*//*, AccessTarget>*/AccessTargets; 
     47        protected final Map/* <Integer *//* Target *//* , AccessTarget> */AccessTargets; 
     48 
     49        // The list of classes to generate type transitions for 
     50        protected final Collection /* <String> */m_Transitions = new HashSet /* <String> */ (); 
    4651 
    4752        // optional name value pairs object to associate w/ this access 
    48         protected final Map/*<String, NameValuePair<?>>*/NameValuePairs; 
     53        protected final Map/* <String, NameValuePair<?>> */NameValuePairs; 
    4954 
    5055        protected boolean unRevokable; 
     
    5358         * AccessDefn constructor creates AccessDefn object and assigns name. 
    5459         *  
    55          * @param token Token from the parser that identifies the AccessResource 
    56          * @param adg   The access definition group this access definition is a member of  
    57          */ 
    58         public AccessDefn(AbstractToken token, AccessDefnGroup adg) { 
    59                 this(token, adg, false); 
     60         * @param token 
     61         *            Token from the parser that identifies the AccessResource 
     62         * @param adg 
     63         *            The access definition group this access definition is a member 
     64         *            of 
     65         */ 
     66        public AccessDefn (AbstractToken token, AccessDefnGroup adg) 
     67        { 
     68                this (token, adg, false); 
    6069        } 
    6170 
     
    6372         * AccessDefn constructor creates AccessDefn object and assigns name. 
    6473         *  
    65          * @param token Token from the parser that identifies the AccessResource 
    66          * @param adg   The access definition group this access definition is a member of  
    67          */ 
    68         public AccessDefn(AbstractToken token, AccessDefnGroup adg, boolean unRevokable) { 
     74         * @param token 
     75         *            Token from the parser that identifies the AccessResource 
     76         * @param adg 
     77         *            The access definition group this access definition is a member 
     78         *            of 
     79         */ 
     80        public AccessDefn (AbstractToken token, AccessDefnGroup adg, boolean unRevokable) 
     81        { 
    6982                Token = token; 
    70                 AccessTargets = new TreeMap/*<Integer *//*Target*//*, AccessTarget>*/(); 
     83                AccessTargets = new TreeMap/* <Integer *//* Target *//* , AccessTarget> */(); 
    7184                AccessDefnGroup = adg; 
    72                 NameValuePairs = new TreeMap/*<String, NameValuePair<?>>*/(); 
     85                NameValuePairs = new TreeMap/* <String, NameValuePair<?>> */(); 
    7386                this.unRevokable = unRevokable; 
    7487        } 
    7588 
    7689        /** 
    77          * Add an AccessTarget to this AccessDefn.  
    78          *  
    79          * @param taget The AccessTarget to associate with this AccessDefn. 
    80          * @return              <code>true</code> if access target successfully  
    81          *                              inserted, <code>false</code> otherwise 
    82          */ 
    83         public boolean AddAccessTarget(AccessTarget target) { 
    84                 if(!AccessTargets.containsKey(target.TargetName)) { 
    85                         AccessTargets.put(target.TargetName, target); 
     90         * Add an AccessTarget to this AccessDefn. 
     91         *  
     92         * @param taget 
     93         *            The AccessTarget to associate with this AccessDefn. 
     94         * @return <code>true</code> if access target successfully inserted, 
     95         *         <code>false</code> otherwise 
     96         */ 
     97        public boolean AddAccessTarget (AccessTarget target) 
     98        { 
     99                if (!AccessTargets.containsKey (target.TargetName)) 
     100                { 
     101                        AccessTargets.put (target.TargetName, target); 
    86102                        return true; 
    87103                } 
     
    92108         * Get AccessTarget by Target 
    93109         *  
    94          * @param trgt  The Target for the desired AccessTarget 
    95          * @return              AcccessTarget if found, otherwise null 
    96          */ 
    97         public AccessTarget GetAccessTarget(Integer /*Target*/trgt) { 
    98                 return (AccessTarget) AccessTargets.get(trgt); 
     110         * @param trgt 
     111         *            The Target for the desired AccessTarget 
     112         * @return AcccessTarget if found, otherwise null 
     113         */ 
     114        public AccessTarget GetAccessTarget (Integer /* Target */trgt) 
     115        { 
     116                return (AccessTarget) AccessTargets.get (trgt); 
    99117        } 
    100118 
     
    102120         * Add a NameValuePair metadata object. 
    103121         *  
    104          * @param pair  NameValuePair to add 
    105          * @return      <code>true</code> when name/value inserted  
    106          *                              successfully.  <code>false</code> otherwise. 
    107          */ 
    108         public boolean AddNameValuePair(NameValuePair /*<?>*/pair) { 
     122         * @param pair 
     123         *            NameValuePair to add 
     124         * @return <code>true</code> when name/value inserted successfully. 
     125         *         <code>false</code> otherwise. 
     126         */ 
     127        public boolean AddNameValuePair (NameValuePair /* <?> */pair) 
     128        { 
    109129                // insert nvp into pairs map 
    110                 if(NameValuePairs.containsKey(pair.GetName())) { 
     130                if (NameValuePairs.containsKey (pair.GetName ())) 
     131                { 
    111132                        return false; 
    112133                } 
    113134 
    114                 NameValuePairs.put(pair.GetName(), pair); 
     135                NameValuePairs.put (pair.GetName (), pair); 
    115136                return true; 
    116137        } 
     
    119140         * Retrieve the name/value associated with the name. 
    120141         *  
    121          * @param name  String identifying pair to be returned 
    122          * @return              name/value pair indexed by name 
    123          */ 
    124         public NameValuePair /*<?>*/GetNameValuePair(String name) { 
    125                 return (NameValuePair /*<?>*/) NameValuePairs.get(name); 
     142         * @param name 
     143         *            String identifying pair to be returned 
     144         * @return name/value pair indexed by name 
     145         */ 
     146        public NameValuePair /* <?> */GetNameValuePair (String name) 
     147        { 
     148                return (NameValuePair /* <?> */) NameValuePairs.get (name); 
    126149        } 
    127150 
    128151        /** 
    129152         * Get the Map of name/value pairs. 
    130          * 
    131          * @return      NameValuePairs associated with object 
    132          */ 
    133         public Map/*<String, NameValuePair<?>>*/GetNameValuePairs() { 
     153         *  
     154         * @return NameValuePairs associated with object 
     155         */ 
     156        public Map/* <String, NameValuePair<?>> */GetNameValuePairs () 
     157        { 
    134158                return NameValuePairs; 
    135159        } 
    136160 
    137         /** 
    138          * Check to ensure this instance is a subset of another.  In other words, 
    139          * this method returns <code>true</code> when the parameter passed to this  
    140          * method is a superset of this instance.  
    141          *  
    142          * @param other Another AccessDefn instance to perform comparison against. 
    143          * @return              <code>true</code> if this instance is a subset of other, 
    144          *                              <code>false</code> otherwise. 
    145          */ 
    146         public boolean IsSubsetOf(AccessDefn other) { 
    147                 if(other == null) { 
     161        public void AddTransitionObjectClass (String i_sObjClass) 
     162        { 
     163                m_Transitions.add (i_sObjClass); 
     164        } 
     165         
     166        public Collection GetTransitionObjectClasses () 
     167        { 
     168                return m_Transitions; 
     169        } 
     170         
     171        /** 
     172         * Check to ensure this instance is a subset of another. In other words, 
     173         * this method returns <code>true</code> when the parameter passed to this 
     174         * method is a superset of this instance. 
     175         *  
     176         * @param other 
     177         *            Another AccessDefn instance to perform comparison against. 
     178         * @return <code>true</code> if this instance is a subset of other, 
     179         *         <code>false</code> otherwise. 
     180         */ 
     181        public boolean IsSubsetOf (AccessDefn other) 
     182        { 
     183                if (other == null) 
     184                { 
    148185                        return false; 
    149186                } 
    150187                // iterate over targets checking for superset 
    151                 /*for (Map.Entry<Integer *//*Target*//*, AccessTarget> mapEntry: this.AccessTargets.entrySet())*/ 
    152                 Iterator iter = this.AccessTargets.entrySet().iterator(); 
    153                 while(iter.hasNext()) { 
    154                         Map.Entry mapEntry = (Map.Entry) iter.next(); 
     188                /* for (Map.Entry<Integer *//* Target *//* 
     189                                                                                                 * , AccessTarget> mapEntry: 
     190                                                                                                 * this.AccessTargets.entrySet()) 
     191                                                                                                 */ 
     192                Iterator iter = this.AccessTargets.entrySet ().iterator (); 
     193                while (iter.hasNext ()) 
     194                { 
     195                        Map.Entry mapEntry = (Map.Entry) iter.next (); 
    155196                        // if it has a corresponding target check that target 
    156                         if(other.AccessTargets.containsKey(mapEntry.getKey())) { 
    157                                 if(!((AccessTarget) mapEntry.getValue()) 
    158                                         .IsSubsetOf((AccessTarget) other.AccessTargets.get(mapEntry 
    159                                                 .getKey()))) { 
     197                        if (other.AccessTargets.containsKey (mapEntry.getKey ())) 
     198                        { 
     199                                if (! ((AccessTarget) mapEntry.getValue ()) 
     200                                        .IsSubsetOf ((AccessTarget) other.AccessTargets.get (mapEntry.getKey ()))) 
     201                                { 
    160202                                        return false; 
    161203                                } 
    162204 
    163                         } else { 
     205                        } 
     206                        else 
     207                        { 
    164208                                return false; 
    165209                        } 
     
    170214        /** 
    171215         * Test AccessDefn for validity. 
    172          *   
    173          * @return              <code>true</code> if definition is valid. 
    174          */ 
    175         final boolean Validate(Linkage linkage) { 
     216         *  
     217         * @return <code>true</code> if definition is valid. 
     218         */ 
     219        final boolean Validate (Linkage linkage) 
     220        { 
    176221                boolean valid = true; 
    177222 
    178                 /*for (AccessTarget at:AccessTargets.values())*/ 
    179                 Iterator iter = AccessTargets.values().iterator(); 
    180                 while(iter.hasNext()) { 
    181                         AccessTarget at = (AccessTarget) iter.next(); 
    182                         valid &= at.Validate(linkage); 
     223                /* for (AccessTarget at:AccessTargets.values()) */ 
     224                Iterator iter = AccessTargets.values ().iterator (); 
     225                while (iter.hasNext ()) 
     226                { 
     227                        AccessTarget at = (AccessTarget) iter.next (); 
     228                        valid &= at.Validate (linkage); 
    183229                } 
    184230                return valid; 
    185231        } 
    186232 
    187         public int compareTo(Object o) { 
     233        public int compareTo (Object o) 
     234        { 
    188235                if (o instanceof AccessDefn) 
    189                         return this.getName().compareTo(((AccessDefn) o).getName()); 
     236                        return this.getName ().compareTo ( ((AccessDefn) o).getName ()); 
    190237                return -1; 
    191238        } 
    192239 
    193         public Map getAccessTargets() { 
     240        public Map getAccessTargets () 
     241        { 
    194242                return AccessTargets; 
    195243        } 
    196244 
    197         public String getName() { 
    198                 if(Token == null) 
    199                         return ""; 
     245        public String getName () 
     246        { 
     247                if (Token == null) 
     248                        return new String (); 
    200249                return Token.image; 
    201250        } 
    202251 
    203         public AbstractToken getToken() { 
     252        public AbstractToken getToken () 
     253        { 
    204254                return Token; 
    205255        } 
    206256 
    207         public AccessDefnGroup getAccessDefnGroup() { 
     257        public AccessDefnGroup getAccessDefnGroup () 
     258        { 
    208259                return AccessDefnGroup; 
    209260        } 
     
    212263         * @return the unRevokable 
    213264         */ 
    214         public boolean isUnRevokable() { 
     265        public boolean isUnRevokable () 
     266        { 
    215267                return unRevokable; 
    216268        } 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/AccessTarget.java

    r1396 r1938  
    138138        } 
    139139 
    140         public static AccessTarget MergeAccessTargets( 
    141                                                                                                        Collection/*<AccessTarget>*/targets)
     140        public static AccessTarget MergeAccessTargets (Collection/*<AccessTarget>*/targets)  
     141       
    142142                Map/*<String, Vector<PermVector>>*/pvMap = new TreeMap/*<String, Vector<PermVector>>*/(); 
    143143                Integer /*Target*/name = null; 
  • branches/dictionary_changes/src/com/tresys/framework/compiler/dictionary/DictionaryParser.jj

    r1825 r1938  
    44        STATIC = false; 
    55        JDK_VERSION = "1.4"; 
    6         //DEBUG_PARSER = true; 
    7         //DEBUG_TOKEN_MANAGER = true; 
     6        DEBUG_PARSER = false; 
     7        DEBUG_TOKEN_MANAGER = false; 
    88        OUTPUT_DIRECTORY="."; 
    99} 
     
    1414PARSER_BEGIN (DictionaryParser) 
    1515/* 
    16  * Copyright (C) 2005-2006 Tresys Technology, LLC 
     16 * Copyright (C) 2005-2008 Tresys Technology, LLC 
    1717 * License: refer to COPYING file for license information. 
    1818 * Authors:     Spencer Shimko <sshimko@tresys.com> 
    1919 *              James Athey <jathey@tresys.com> 
    2020 *              Brian Williams <bwilliams@tresys.com> 
     21 *                      Dave Sugar <dsugar@tresys.com> 
    2122 * 
    2223 * DictionaryParser: Lexical analyzer and parser generator source 
    23  * Version: @version@ 
     24 *  
     25 * $Rev$ 
     26 * $Date$ 
    2427 */ 
    2528  
     
    3336import com.tresys.framework.compiler.systemResources.SystemResourceTypes; 
    3437 
    35 /*@SuppressWarnings({"unchecked","unused", "serial"})*/ 
     38//@SuppressWarnings({"unchecked","unused", "serial"}) 
    3639 
    3740/** 
    3841 * This is the DictionaryParser class which drives the parser.   
    3942 */ 
    40 public final class DictionaryParser {   
     43public final class DictionaryParser  
     44{   
    4145 
    4246        // Dictionary object that will be filled as parsing occurs 
     
    5155         * @param errmsg        Error message to display 
    5256         */ 
    53         private void errorGenerate (Token tok, String errmsg){ 
     57        private void errorGenerate (Token tok, String errmsg) 
     58        { 
    5459                errorHandler.Error(errmsg, tok.beginLine, tok.beginColumn, tok.endColumn); 
    5560        } 
     
    6166         * @param errmsg        Error message to display 
    6267         */ 
    63         private void warnGenerate(Token tok, String errmsg) { 
     68        private void warnGenerate(Token tok, String errmsg)  
     69        { 
    6470                errorHandler.Warning(errmsg, tok.beginLine, tok.beginColumn, tok.endColumn); 
    6571        } 
    6672 
    67         private String parseErrorMessage(ParseException e) { 
     73        private String parseErrorMessage(ParseException e)  
     74        { 
    6875                String expected = new String (); 
    6976                int maxSize = 0; 
    70                 for (int i = 0; i < e.expectedTokenSequences.length; i++) { 
    71                         if (maxSize < e.expectedTokenSequences[i].length) { 
     77                for (int i = 0; i < e.expectedTokenSequences.length; i++)  
     78                { 
     79                        if (maxSize < e.expectedTokenSequences[i].length)  
     80                        { 
    7281                                maxSize = e.expectedTokenSequences[i].length; 
    7382                        } 
    7483                        int j; 
    75                         for (j = 0; j < (e.expectedTokenSequences[i].length - 1); j++) { 
     84                        for (j = 0; j < (e.expectedTokenSequences[i].length - 1); j++)  
     85                        { 
    7686                                expected += e.tokenImage[e.expectedTokenSequences[i][j]]; 
    7787                                expected += " "; 
     
    8494                                 
    8595                        if (i != (e.expectedTokenSequences.length - 1) && 
    86                                         e.expectedTokenSequences[i][e.expectedTokenSequences[i].length - 1] != 0) { 
     96                                        e.expectedTokenSequences[i][e.expectedTokenSequences[i].length - 1] != 0)  
     97                        { 
    8798                                expected += ", "; 
    8899                        } 
     
    90101                String message = new String ("Encountered \""); 
    91102                Token tok = e.currentToken.next; 
    92                 for (int i = 0; i < maxSize; i++) { 
     103                for (int i = 0; i < maxSize; i++)  
     104                { 
    93105                        if (i != 0 && i != (maxSize - 1)) 
    94106                                message += " "; 
    95                         if (tok.kind == 0) { 
     107                        if (tok.kind == 0)  
     108                        { 
    96109                                message += e.tokenImage[0]; 
    97110                                break; 
     
    100113                        tok = tok.next; 
    101114                } 
    102                 if (e.expectedTokenSequences.length == 1) { 
     115                if (e.expectedTokenSequences.length == 1)  
     116                { 
    103117                        message += "\", was expecting: "; 
    104                 } else { 
     118                } 
     119                else 
     120                { 
    105121                        message += "\", was expecting one of: "; 
    106122                } 
     
    116132         * @param str           String to process. 
    117133         */ 
    118         private String add_escapes(String str) { 
     134        private String add_escapes(String str) 
     135        { 
    119136                String retval = new String (); 
    120137                char[] chars = str.toCharArray(); 
     
    123140                { 
    124141                        char ch = chars[i]; 
    125                         switch (ch) { 
    126                         case 0 : 
    127                                 continue; 
    128                         case '\b': 
    129                                 retval += ("\\b"); 
    130                                 continue; 
    131                         case '\t': 
    132                                 retval += ("\\t"); 
    133                                 continue; 
    134                         case '\n': 
    135                                 retval += ("\\n"); 
    136                                 continue; 
    137                         case '\f': 
    138                                 retval += ("\\f"); 
    139                                 continue; 
    140                         case '\r': 
    141                                 retval += ("\\r"); 
    142                                 continue; 
    143                         case '\"': 
    144                                 retval += ("\\\""); 
    145                                 continue; 
    146                         case '\'': 
    147                                 retval += ("\\\'"); 
    148                                 continue; 
    149                         case '\\': 
    150                                 retval += ("\\\\"); 
    151                                 continue; 
    152                         default: 
    153                                 if (ch < 0x20 || ch > 0x7e) { 
    154                                         String s = "0000" + Integer.toString(ch, 16); 
    155                                         retval += ("\\u" + s.substring(s.length() - 4, s.length())); 
    156                                 } else { 
    157                                         retval += (ch); 
    158                                 } 
    159                                 continue; 
     142                        switch (ch) 
     143                        { 
     144                                case 0 : 
     145                                        continue; 
     146                                case '\b': 
     147                                        retval += ("\\b"); 
     148                                        continue; 
     149                                case '\t': 
     150                                        retval += ("\\t"); 
     151                                        continue; 
     152                                case '\n': 
     153                                        retval += ("\\n"); 
     154                                        continue; 
     155                                case '\f': 
     156                                        retval += ("\\f"); 
     157                                        continue; 
     158                                case '\r': 
     159                                        retval += ("\\r"); 
     160                                        continue; 
     161                                case '\"': 
     162                                        retval += ("\\\""); 
     163                                        continue; 
     164                                case '\'': 
     165                                        retval += ("\\\'"); 
     166                                        continue; 
     167                                case '\\': 
     168                                        retval += ("\\\\"); 
     169                                        continue; 
     170                                default: 
     171                                        if (ch < 0x20 || ch > 0x7e)  
     172                                        { 
     173                                                String s = "0000" + Integer.toString(ch, 16); 
     174                                                retval += ("\\u" + s.substring(s.length() - 4, s.length())); 
     175                                        } 
     176                                        else  
     177                                        { 
     178                                                retval += (ch); 
     179                                        } 
     180                                        continue; 
    160181                        } 
    161182                } 
     
    185206                errorHandler = handler; 
    186207 
    187                 try     { 
     208                try      
     209                { 
    188210                        // attempt to open Reader 
    189211                        ReInit(dictReader); 
    190                 } catch (TokenMgrError e) { 
     212                } 
     213                catch (TokenMgrError e)  
     214                { 
    191215                        errorHandler.CriticalError("Error tokenizing dictionary file: " + e.getMessage()); 
    192216                }  
     
    194218                // encloses parser call to catch all ParseExceptions not 
    195219                // handled internally 
    196                 try {                    
     220                try