OpenLayers OpenLayers

Changeset 5308

Show
Ignore:
Timestamp:
12/01/07 05:44:20 (1 year ago)
Author:
ahocevar
Message:

fixed value2regex, improved NaturalDocs comments

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/ahocevar/styles/lib/OpenLayers/Rule/Comparison.js

    r5305 r5308  
    118118     
    119119    /** 
    120      * Function: value2regExp 
    121      * Converts a the value of this rule into a regular expression string, 
    122      * according to the wildcard characters specified. 
    123      *  
    124      * Parameters: 
    125      * wildCard   - {<Char>} wildcard character in the above value 
     120     * APIMethod: value2regex 
     121     * Converts the value of this rule into a regular expression string, 
     122     * according to the wildcard characters specified. This method has to 
     123     * be called after instantiation of this class, if the value is not a 
     124     * regular expression already. 
     125     *  
     126     * Parameters: 
     127     * wildCard   - {<Char>} wildcard character in the above value, default 
     128     *              is "*" 
    126129     * singleChar - {<Char>) single-character wildcard in the above value 
    127      * escape     - {<Char>) escape character in the above value 
     130     *              default is "." 
     131     * escape     - {<Char>) escape character in the above value, default is 
     132     *              "!" 
    128133     *  
    129134     * Returns: 
     
    132137    value2regex: function(wildCard, singleChar, escapeChar) { 
    133138        if (wildCard == ".") { 
    134             var msg = "'.' is an unsupported wildCard character in "+ 
    135                     "the OpenLayers SLD parser."; 
     139            var msg = "'.' is an unsupported wildCard character for "+ 
     140                    "OpenLayers.Rule.Comparison"; 
    136141            OpenLayers.Console.error(msg); 
    137142            return null; 
    138143        } 
    139         var escape = "[^\\"+escapeChar+"]\\"; 
    140         this.value = this.value.replace(new RegExp(escape+singleChar, "g"), 
    141                 "."); 
    142         this.value = this.value.replace(new RegExp(escape+wildCard, "g"), 
    143                 ".*"); 
    144         this.value = this.value.replace(new RegExp(escapeChar, "g"), "\\"); 
     144         
     145        // set UMN MapServer defaults for unspecified parameters 
     146        wildCard = wildCard ? wildCard : "*"; 
     147        singleChar = singleChar ? singleChar : "."; 
     148        escapeChar = escapeChar ? escapeChar : "!"; 
     149         
     150        this.value = this.value.replace( 
     151                new RegExp("\\"+escapeChar, "g"), "\\"); 
     152        this.value = this.value.replace( 
     153                new RegExp("\\"+singleChar, "g"), "."); 
     154        this.value = this.value.replace( 
     155                new RegExp("\\"+wildCard, "g"), ".*"); 
     156        this.value = this.value.replace( 
     157                new RegExp("\\\\.\\*", "g"), "\\"+wildCard); 
     158        this.value = this.value.replace( 
     159                new RegExp("\\\\\\.", "g"), "\\"+singleChar); 
    145160         
    146161        return this.value;