FileDocCategorySizeDatePackage
CombinedPatternMatcher.javaAPI DocGlassfish v2 API5470Fri May 04 22:33:16 BST 2007com.sun.enterprise.admin.common

CombinedPatternMatcher

public class CombinedPatternMatcher extends Object implements com.sun.enterprise.admin.util.IPatternMatcher

Fields Summary
private String
mPattern
private String
mTestString
private com.sun.enterprise.admin.util.IPatternMatcher
mRealMatcher
private static com.sun.enterprise.admin.util.SOMLocalStringsManager
localizedStrMgr
Constructors Summary
public CombinedPatternMatcher(String patternString, String testString)
Creates new CombinedPatternMatcher with pattern string and string on which the patten has to be matched. None of the strings may be null.

param
patternString the Pattern string.
param
testString the string on which pattern should be applied.


	 		      		           		   				    		         	
    
	    
	
        if (patternString == null || testString == null)
        {
			String msg = localizedStrMgr.getString( "admin.common.combinedpattermatcher_null_arg" );
            throw new IllegalArgumentException( msg );
        }
		mPattern	= patternString;
		mTestString	= testString;
        if (isJDK14())
        {
//            Logger.log("using the jdk 1.4 regular expression facility");
            mPattern = translateFromJMXToJDK14(patternString);
            mRealMatcher = new RegExpMatcher(mPattern, testString);
        }
        else
        {
//            Logger.log("using pattern matcher without jdk 1.4");
            mRealMatcher = new GeneralPatternMatcher(patternString, testString);
        }
    
Methods Summary
private java.lang.StringescapeDots(java.lang.String aString)

        char escape      = Tokens.kEscapeChar;
        char dot         = Tokens.kDelimiterChar;
        return ( insertCharBefore(aString, escape, dot) );
    
private java.lang.StringinsertCharBefore(java.lang.String aString, char insChar, char beforeChar)

        StringBuffer    destBuffer  = new StringBuffer();
        char[]          srcArray    = aString.toCharArray();
        for (int i = 0 ; i < srcArray.length ; i++)
        {
            char ch = srcArray[i];
            if (ch == beforeChar)
            {
                destBuffer.append(insChar);
            }
            destBuffer.append(ch);
        }
        return ( destBuffer.toString() );
    
private java.lang.StringinsertDotBeforeQM(java.lang.String aString)

        char dot        = Tokens.kDelimiterChar;
        char qm         = ObjectNames.kSingleMatchChar;
        
        return ( insertCharBefore(aString, dot, qm) );
    
private java.lang.StringinsertDotBeforeStar(java.lang.String aString)

        char dot        = Tokens.kDelimiterChar;
        char star       = Tokens.kWildCardChar;
        
        return ( insertCharBefore(aString, dot, star) );
    
public booleanisJDK14()

		String javaSpecVersion = System.getProperty("java.specification.version");
		
		return ( javaSpecVersion.startsWith("1.4") );
	
public booleanmatches()

        return ( mRealMatcher.matches() );
	
private java.lang.StringtranslateFromJMXToJDK14(java.lang.String aString)

        String dotEscpapedString    = escapeDots(aString);
        String starReplacedString   = insertDotBeforeStar(dotEscpapedString);
        String qmReplacedString     = insertDotBeforeQM(starReplacedString);
        return ( qmReplacedString );