Coverage Report - net.sf.json.regexp.RegexpUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
RegexpUtils
0%
0/12
0%
0/6
2
 
 1  
 /*
 2  
  * Copyright 2002-2009 the original author or authors.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package net.sf.json.regexp;
 18  
 
 19  
 /**
 20  
  * Convenience utility for working withRegexpMatcher.<br>
 21  
  * 
 22  
  * @author Andres Almiray <aalmiray@users.sourceforge.net>
 23  
  */
 24  
 public class RegexpUtils {
 25  0
    private static String javaVersion = "1.3.1";
 26  
    static{
 27  0
       javaVersion = System.getProperty( "java.version" );
 28  0
    }
 29  
 
 30  
    /**
 31  
     * Returns a RegexpMatcher that works in a specific environment.<br>
 32  
     * When in a JVM 1.3.1 it will return a Perl5RegexpMatcher, if the JVM is
 33  
     * younger (1.4+) it will return a JdkRegexpMatcher.
 34  
     */
 35  
    public static RegexpMatcher getMatcher( String pattern ) {
 36  0
       if( isJDK13() ){
 37  0
          return new Perl5RegexpMatcher( pattern );
 38  
       }else{
 39  0
          return new JdkRegexpMatcher( pattern );
 40  
       }
 41  
    }
 42  
 
 43  
    /**
 44  
     * Returns a RegexpMatcher that works in a specific environment.<br>
 45  
     * When in a JVM 1.3.1 it will return a Perl5RegexpMatcher, if the JVM is
 46  
     * younger (1.4+) it will return a JdkRegexpMatcher.
 47  
     */
 48  
    public static RegexpMatcher getMatcher( String pattern, boolean multiline ) {
 49  0
       if( isJDK13() ){
 50  0
          return new Perl5RegexpMatcher( pattern, true );
 51  
       }else{
 52  0
          return new JdkRegexpMatcher( pattern, true );
 53  
       }
 54  
    }
 55  
    
 56  
    /**
 57  
     * Queries the environment for the supported JDK version.
 58  
     */
 59  
    public static boolean isJDK13() {
 60  0
       return javaVersion.indexOf( "1.3" ) != -1;
 61  
    }
 62  
 
 63  0
    private RegexpUtils() {
 64  
 
 65  0
    }
 66  
 }