FileDocCategorySizeDatePackage
ObjectNameQueryImpl.javaAPI DocGlassfish v2 API7277Fri May 04 22:31:04 BST 2007com.sun.appserv.management.util.jmx

ObjectNameQueryImpl

public class ObjectNameQueryImpl extends Object implements ObjectNameQuery

Fields Summary
Constructors Summary
public ObjectNameQueryImpl()

	
Methods Summary
java.util.regex.Pattern[]createPatterns(java.lang.String[] patternStrings, int numItems)

		final Pattern []	patterns	= new Pattern [ numItems ];
		
		if ( patternStrings == null )
		{
			for( int i = 0; i < numItems; ++i )
			{
				patterns[ i ]	= null;
			}
			
			return( patterns );
		}
			
		
		for( int i = 0; i < numItems; ++i )
		{
			// consider null to match anything
			
			if ( patternStrings[ i ] == null )
			{
				patterns[ i ]	= null;
			}
			else
			{
				patterns[ i ]	= Pattern.compile( patternStrings[ i ] );
			}
		}
		
		return( patterns );
	
booleanmatch(java.util.Hashtable properties, java.util.regex.Pattern propertyPattern, java.util.regex.Pattern valuePattern)
Return true if one (or more) of the properties match the regular expressions for both name and value. Return false if no property/value combinations match. A null pattern matches anything.

		final Iterator	keys	= new EnumerationIterator( properties.keys() );
		boolean	matches	= false;
		
		while ( keys.hasNext() )
		{
			final String	key	= (String)keys.next();
			
			if ( propertyPattern == null || propertyPattern.matcher( key ).matches() )
			{
				if ( valuePattern == null )
				{
					matches	= true;
					break;
				}

				// see if value matches
				final String	value	= (String)properties.get( key );
				
				if ( valuePattern.matcher( value ).matches() )
				{
					matches	= true;
					break;
				}
			}
		}
		
		return( matches );
	
booleanmatchAll(javax.management.ObjectName name, java.util.regex.Pattern[] propertyPatterns, java.util.regex.Pattern[] valuePatterns)
Match all property/value expressions against the ObjectName. Return true if for each property/value regular expression pair there is at least one property within the ObjectName whose property name and value match their respective patterns. A null regex indicates "match anything".

		boolean	matches	= true;
		
		final Hashtable	properties	= name.getKeyPropertyList();
		
		for( int i = 0; i < propertyPatterns.length; ++i )
		{
			if ( ! match( properties, propertyPatterns[ i ], valuePatterns[ i ] ) )
			{
				matches	= false;
				break;
			}
		}
		
		return( matches );
	
public java.util.SetmatchAll(java.util.Set startingSet, java.lang.String[] regexNames, java.lang.String[] regexValues)

		return( matchEither( new MatchAllMatcher(), startingSet, regexNames, regexValues ) );
	
booleanmatchAny(javax.management.ObjectName name, java.util.regex.Pattern[] propertyPatterns, java.util.regex.Pattern[] valuePatterns)
Match all property/value expressions against the ObjectName. Return true if there is at least one property/value regular expression pair that matches a property/value pair within the ObjectName. A null regex indicates "match anything".

		boolean	matches	= false;
		
		final Hashtable	properties	= name.getKeyPropertyList();
		
		for( int i = 0; i < propertyPatterns.length; ++i )
		{
			if ( match( properties, propertyPatterns[ i ], valuePatterns[ i ] ) )
			{
				matches	= true;
				break;
			}
		}
		
		return( matches );
	
public java.util.SetmatchAny(java.util.Set startingSet, java.lang.String[] regexNames, java.lang.String[] regexValues)

		return( matchEither( new MatchAnyMatcher(), startingSet, regexNames, regexValues ) );
	
java.util.SetmatchEither(com.sun.appserv.management.util.jmx.ObjectNameQueryImpl$Matcher matcher, java.util.Set startingSet, java.lang.String[] regexNames, java.lang.String[] regexValues)

		if ( regexNames == null && regexValues == null )
		{
			// both null => matches entire original set
			return( startingSet );
		}
		
		final Set<ObjectName> results	= new HashSet<ObjectName>();
		
		int	numMatches	= 0;
		if ( regexNames != null )
		{
			numMatches	= regexNames.length;
		}
		else
		{
			numMatches	= regexValues.length;
		}

		final Pattern [] namePatterns	= createPatterns( regexNames, numMatches );
		final Pattern [] valuePatterns	= createPatterns( regexValues, numMatches );
		
		for( final ObjectName name : startingSet )
		{
			if ( matcher.match( name, namePatterns, valuePatterns ) )
			{
				results.add( name );
			}
		}

		return( results );