This patch adds the missing 1.6 methods to ObjectName.
Now we just need to be able to apply the new patterns...

Changelog:

2007-04-07  Andrew John Hughes  <[EMAIL PROTECTED]>

        * javax/management/ObjectName.java:
        (propertyValuePattern): New cache variable.
        (parse(String)): Record in propertyListPattern
        not propertyPattern and set propertyValuePattern.
        (isPropertyPattern()): Semantics altered to be the
        OR of isPropertyListPattern() and isPropertyValuePattern().
        (isPropertyListPattern()): Implemented.
        (isPropertyValuePattern()): Implemented.
        (isPropertyValuePattern(String)): Implemented.

-- 
Andrew :-)

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: javax/management/ObjectName.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.14
diff -u -3 -p -u -r1.14 ObjectName.java
--- javax/management/ObjectName.java	7 Apr 2007 22:48:02 -0000	1.14
+++ javax/management/ObjectName.java	9 Apr 2007 13:23:43 -0000
@@ -71,7 +71,7 @@ import java.io.ObjectOutputStream;
  * is separated by commas, and largely consists of unordered key-value
  * pairs, separated by an equals sign ('=').  At most one element may
  * be an asterisk ('*'), which turns the [EMAIL PROTECTED] ObjectName} instance
- * into a <emph>property pattern</emph>.  In this situation, the pattern
+ * into a <emph>property list pattern</emph>.  In this situation, the pattern
  * matches a name if the name contains at least those key-value pairs
  * given and has the same domain.
  * </p>
@@ -89,6 +89,13 @@ import java.io.ObjectOutputStream;
  * (after expansion) are considered part of the value.
  * </p>
  * <p>
+ * Both quoted and unquoted values may contain the wildcard characters
+ * '?' and '*'.  A name with at least one value containing a wildcard
+ * character is known as a <emph>property value pattern</emph>.  A
+ * name is generally a <emph>property pattern</emph> if it is either
+ * a <emph>property list pattern</emph> or <emph>property value pattern</emph>.
+ * </p>
+ * <p>
  * Spaces are maintained within the different parts of the name.  Thus,
  * '<code>domain: key1 = value1 </code>' has a key ' key1 ' with value
  * ' value1 '.  Newlines are disallowed, except where escaped in quoted
@@ -127,9 +134,14 @@ public class ObjectName
   private transient String propertyListString;
 
   /**
-   * True if this object name is a property pattern.
+   * True if this object name is a property list pattern.
    */
-  private transient boolean propertyPattern;
+  private transient boolean propertyListPattern;
+
+  /**
+   * True if this object name is a property value pattern.
+   */
+  private transient boolean propertyValuePattern;
 
   /**
    * The management server associated with this object name.
@@ -201,7 +213,7 @@ public class ObjectName
       {
 	if (pairs[a].equals("*"))
 	  {
-	    propertyPattern = true;
+	    propertyListPattern = true;
 	    continue;
 	  }
 	int sep = pairs[a].indexOf('=');
@@ -322,7 +334,10 @@ public class ObjectName
 		throw new MalformedObjectNameException("A value contains " +
 						       "a '" + valchars[a] + "' " +
 						       "character.");
+	    
 	  }
+	if (value.indexOf('*') != -1 || value.indexOf('?') != -1)
+	  propertyValuePattern = true;
       }
   }
 
@@ -685,14 +700,60 @@ public class ObjectName
   }
 
   /**
-   * Returns true if this object name is a property pattern.  This is
-   * the case if the list of properties contains an '*'.
+   * Returns true if this object name is a property list
+   * pattern, a property value pattern or both.
    *
-   * @return true if this is a property pattern.
+   * @return true if the properties of this name contain a pattern.
+   * @see #isPropertyListPattern
+   * @see #isPropertyValuePattern
    */
   public boolean isPropertyPattern()
   {
-    return propertyPattern;
+    return propertyListPattern || propertyValuePattern;
+  }
+
+  /**
+   * Returns true if this object name is a property list pattern.  This is
+   * the case if the list of properties contains an '*'.
+   *
+   * @return true if this is a property list pattern.
+   * @since 1.6
+   */
+  public boolean isPropertyListPattern()
+  {
+    return propertyListPattern;
+  }
+
+  /**
+   * Returns true if this object name is a property value pattern.  This is
+   * the case if one of the values contains a wildcard character,
+   * '?' or '*'.
+   *
+   * @return true if this is a property value pattern.
+   * @since 1.6
+   */
+  public boolean isPropertyValuePattern()
+  {
+    return propertyValuePattern;
+  }
+
+  /**
+   * Returns true if the value of the given key is a pattern.  This is
+   * the case if the value contains a wildcard character, '?' or '*'.
+   *
+   * @param key the key whose value should be checked.
+   * @return true if the value of the given key is a pattern.
+   * @since 1.6
+   * @throws NullPointerException if [EMAIL PROTECTED] key} is [EMAIL PROTECTED] null}.
+   * @throws IllegalArgumentException if [EMAIL PROTECTED] key} is not a valid
+   *                                  property.
+   */
+  public boolean isPropertyValuePattern(String key)
+  {
+    String value = getKeyProperty(key);
+    if (value == null)
+      throw new IllegalArgumentException(key + " is not a valid property.");
+    return value.indexOf('?') != -1 || value.indexOf('*') != -1;
   }
 
   /**

Attachment: signature.asc
Description: Digital signature

Reply via email to