1 23 24 29 30 31 package com.sun.enterprise.admin.dottedname; 32 33 import java.util.HashSet ; 34 import java.util.Set ; 35 import java.util.List ; 36 import java.util.ArrayList ; 37 import java.util.Iterator ; 38 import java.util.regex.Pattern ; 39 40 import javax.management.ObjectName ; 41 42 43 46 47 public class DottedNameWildcardMatcherImpl implements DottedNameWildcardMatcher 48 { 49 final Set mSearchSet; 50 51 public 52 DottedNameWildcardMatcherImpl( final Set searchSet ) 53 { 54 mSearchSet = searchSet; 55 } 56 57 58 61 Set 62 resolveAll( final String wildcardedName, final Iterator iter ) 63 { 64 final HashSet resolvedSet = new HashSet (); 65 66 final Pattern pattern = Pattern.compile( wildcardedName ); 67 68 while ( iter.hasNext() ) 69 { 70 final String candidate = (String )iter.next(); 71 72 if ( pattern.matcher( candidate ).matches() ) 73 { 74 resolvedSet.add( candidate ); 75 } 76 } 77 78 return( resolvedSet ); 79 } 80 81 86 public Set 87 matchDottedNames( String dottedNameString ) 88 { 89 Set resolvedSet = null; 90 91 if ( dottedNameString.equals( ".*" ) ) 92 { 93 resolvedSet = new HashSet (); 95 resolvedSet.addAll( mSearchSet ); 96 } 97 else 98 { 99 resolvedSet = resolveAll( dottedNameString, mSearchSet.iterator() ); 100 } 101 102 return( resolvedSet ); 103 } 104 } 105 106 107 108 109 | Popular Tags |