jdk/src/share/classes/javax/management/ObjectName.java
changeset 1156 bbc2d15aaf7a
parent 1005 1a39b4e3f2fc
child 1225 6ef6227d36eb
equal deleted inserted replaced
1155:a9a142fcf1b5 1156:bbc2d15aaf7a
    25 
    25 
    26 package javax.management;
    26 package javax.management;
    27 
    27 
    28 import com.sun.jmx.mbeanserver.GetPropertyAction;
    28 import com.sun.jmx.mbeanserver.GetPropertyAction;
    29 import com.sun.jmx.mbeanserver.Util;
    29 import com.sun.jmx.mbeanserver.Util;
       
    30 import com.sun.jmx.namespace.serial.JMXNamespaceContext;
       
    31 
    30 import java.io.IOException;
    32 import java.io.IOException;
    31 import java.io.InvalidObjectException;
    33 import java.io.InvalidObjectException;
    32 import java.io.ObjectInputStream;
    34 import java.io.ObjectInputStream;
    33 import java.io.ObjectOutputStream;
    35 import java.io.ObjectOutputStream;
    34 import java.io.ObjectStreamField;
    36 import java.io.ObjectStreamField;
   221  */
   223  */
   222 @SuppressWarnings("serial") // don't complain serialVersionUID not constant
   224 @SuppressWarnings("serial") // don't complain serialVersionUID not constant
   223 public class ObjectName implements Comparable<ObjectName>, QueryExp {
   225 public class ObjectName implements Comparable<ObjectName>, QueryExp {
   224 
   226 
   225     /**
   227     /**
       
   228      * The sequence of characters used to separate name spaces in a name space
       
   229      * path.
       
   230      *
       
   231      * @see javax.management.namespace
       
   232      * @since 1.7
       
   233      **/
       
   234     public static final String NAMESPACE_SEPARATOR = "//";
       
   235     private static final int NAMESPACE_SEPARATOR_LENGTH =
       
   236             NAMESPACE_SEPARATOR.length();
       
   237 
       
   238     /**
   226      * A structure recording property structure and
   239      * A structure recording property structure and
   227      * proposing minimal services
   240      * proposing minimal services
   228      */
   241      */
   229     private static class Property {
   242     private static class Property {
   230 
   243 
   249         }
   262         }
   250 
   263 
   251         /**
   264         /**
   252          * Returns a key string for receiver key
   265          * Returns a key string for receiver key
   253          */
   266          */
   254         String getKeyString(String name) {
   267         String getKeyString(String name, int offset) {
   255             return name.substring(_key_index, _key_index + _key_length);
   268             final int start = _key_index+offset;
       
   269             return name.substring(start, start + _key_length);
   256         }
   270         }
   257 
   271 
   258         /**
   272         /**
   259          * Returns a value string for receiver key
   273          * Returns a value string for receiver key
   260          */
   274          */
   261         String getValueString(String name) {
   275         String getValueString(String name, int offset) {
   262             int in_begin = _key_index + _key_length + 1;
   276             final int in_begin = _key_index + offset + _key_length + 1;
   263             int out_end = in_begin + _value_length;
   277             final int out_end = in_begin + _value_length;
   264             return name.substring(in_begin, out_end);
   278             return name.substring(in_begin, out_end);
   265         }
   279         }
   266     }
   280     }
   267 
   281 
   268     /**
   282     /**
   391      * boolean that declares if this ObjectName contains a pattern on the
   405      * boolean that declares if this ObjectName contains a pattern on the
   392      * value of at least one key property
   406      * value of at least one key property
   393      */
   407      */
   394     private transient boolean _property_value_pattern = false;
   408     private transient boolean _property_value_pattern = false;
   395 
   409 
       
   410     private ObjectName(String newDomain, ObjectName aname)
       
   411         throws MalformedObjectNameException{
       
   412         copyToOtherDomain(newDomain,aname);
       
   413     }
       
   414 
       
   415     private void copyToOtherDomain(String domain, ObjectName aname)
       
   416         throws MalformedObjectNameException, NullPointerException {
       
   417 
       
   418         // The domain cannot be null
       
   419         if (domain == null)
       
   420             throw new NullPointerException("domain cannot be null");
       
   421 
       
   422         // The key property list cannot be null
       
   423         if (aname == null)
       
   424             throw new MalformedObjectNameException(
       
   425                         "key property list cannot be empty");
       
   426 
       
   427         // checks domain validity. A side effect of this method is also to
       
   428         // set the _domain_pattern flag.
       
   429         if (!isDomain(domain))
       
   430             throw new MalformedObjectNameException("Invalid domain: " + domain);
       
   431 
       
   432         // init canonicalname
       
   433         _domain_length = domain.length();
       
   434 
       
   435         _canonicalName = (domain +
       
   436              aname._canonicalName.substring(aname._domain_length)).intern();
       
   437         _kp_array = aname._kp_array;
       
   438         _ca_array = aname._ca_array;
       
   439         _propertyList = aname._propertyList;
       
   440         _property_list_pattern = aname._property_list_pattern;
       
   441         _property_value_pattern = aname._property_value_pattern;
       
   442         // TODO remove this hack
       
   443         // if (toString().endsWith("//javax.management.service:type1=event_client_delegeate_mbean,type2=default")) {
       
   444         //    Thread.currentThread().dumpStack();
       
   445         //    throw new Error("************************ Gotcha!");
       
   446         //}
       
   447     }
       
   448 
   396     // Instance private fields <=======================================
   449     // Instance private fields <=======================================
   397 
   450 
   398     // Private fields <========================================
   451     // Private fields <========================================
   399 
   452 
   400 
   453 
   433             _property_value_pattern = false;
   486             _property_value_pattern = false;
   434             return;
   487             return;
   435         }
   488         }
   436 
   489 
   437         // initialize parsing of the string
   490         // initialize parsing of the string
   438         char[] name_chars = name.toCharArray();
   491         final char[] name_chars = name.toCharArray();
   439         int len = name_chars.length;
   492         final int len = name_chars.length;
   440         char[] canonical_chars = new char[len]; // canonical form will be same
   493         final char[] canonical_chars = new char[len]; // canonical form will
   441                                                 // length at most
   494                                                       // be same length at most
   442         int cname_index = 0;
   495         int cname_index = 0;
   443         int index = 0;
   496         int index = 0;
   444         char c, c1;
   497         char c, c1;
   445 
   498 
   446         // parses domain part
   499         // parses domain part
   635                                                   "Invalid ending comma");
   688                                                   "Invalid ending comma");
   636             } else in_index++;
   689             } else in_index++;
   637 
   690 
   638             // we got the key and value part, prepare a property for this
   691             // we got the key and value part, prepare a property for this
   639             if (!value_pattern) {
   692             if (!value_pattern) {
   640                 prop = new Property(key_index, key_length, value_length);
   693                 prop = new Property(key_index-_domain_length,
       
   694                                     key_length, value_length);
   641             } else {
   695             } else {
   642                 _property_value_pattern = true;
   696                 _property_value_pattern = true;
   643                 prop = new PatternProperty(key_index, key_length, value_length);
   697                 prop = new PatternProperty(key_index-_domain_length,
       
   698                                     key_length, value_length);
   644             }
   699             }
   645             key_name = name.substring(key_index, key_index + key_length);
   700             key_name = name.substring(key_index, key_index + key_length);
   646 
   701 
   647             if (property_index == keys.length) {
   702             if (property_index == keys.length) {
   648                 String[] tmp_string_array = new String[property_index + 10];
   703                 String[] tmp_string_array = new String[property_index + 10];
   723             keys[i] = key;
   778             keys[i] = key;
   724             sb.append("=");
   779             sb.append("=");
   725             boolean value_pattern = checkValue(value);
   780             boolean value_pattern = checkValue(value);
   726             sb.append(value);
   781             sb.append(value);
   727             if (!value_pattern) {
   782             if (!value_pattern) {
   728                 prop = new Property(key_index,
   783                 prop = new Property(key_index-_domain_length,
   729                                     key.length(),
   784                                     key.length(),
   730                                     value.length());
   785                                     value.length());
   731             } else {
   786             } else {
   732                 _property_value_pattern = true;
   787                 _property_value_pattern = true;
   733                 prop = new PatternProperty(key_index,
   788                 prop = new PatternProperty(key_index-_domain_length,
   734                                            key.length(),
   789                                            key.length(),
   735                                            value.length());
   790                                            value.length());
   736             }
   791             }
   737             addProperty(prop, i, keys_map, key);
   792             addProperty(prop, i, keys_map, key);
   738             i++;
   793             i++;
   808             Property prop;
   863             Property prop;
   809             for (int i = 0; i <= last_index; i++) {
   864             for (int i = 0; i <= last_index; i++) {
   810                 prop = _ca_array[i];
   865                 prop = _ca_array[i];
   811                 // length of prop including '=' char
   866                 // length of prop including '=' char
   812                 prop_len = prop._key_length + prop._value_length + 1;
   867                 prop_len = prop._key_length + prop._value_length + 1;
   813                 System.arraycopy(specified_chars, prop._key_index,
   868                 System.arraycopy(specified_chars, prop._key_index+_domain_length,
   814                                  canonical_chars, prop_index, prop_len);
   869                                  canonical_chars, prop_index, prop_len);
   815                 prop.setKeyIndex(prop_index);
   870                 prop.setKeyIndex(prop_index-_domain_length);
   816                 prop_index += prop_len;
   871                 prop_index += prop_len;
   817                 if (i != last_index) {
   872                 if (i != last_index) {
   818                     canonical_chars[prop_index] = ',';
   873                     canonical_chars[prop_index] = ',';
   819                     prop_index++;
   874                     prop_index++;
   820                 }
   875                 }
  1029         if (endKey < len) throw new
  1084         if (endKey < len) throw new
  1030             MalformedObjectNameException("Invalid character in value: `" +
  1085             MalformedObjectNameException("Invalid character in value: `" +
  1031                                          k[endKey] + "'");
  1086                                          k[endKey] + "'");
  1032     }
  1087     }
  1033 
  1088 
  1034     /*
       
  1035      * Tests whether string s is matched by pattern p.
       
  1036      * Supports "?", "*" each of which may be escaped with "\";
       
  1037      * Not yet supported: internationalization; "\" inside brackets.<P>
       
  1038      * Wildcard matching routine by Karl Heuer.  Public Domain.<P>
       
  1039      */
       
  1040     private static boolean wildmatch(char[] s, char[] p, int si, int pi) {
       
  1041         char c;
       
  1042         final int slen = s.length;
       
  1043         final int plen = p.length;
       
  1044 
       
  1045         while (pi < plen) { // While still string
       
  1046             c = p[pi++];
       
  1047             if (c == '?') {
       
  1048                 if (++si > slen) return false;
       
  1049             } else if (c == '*') { // Wildcard
       
  1050                 if (pi >= plen) return true;
       
  1051                 do {
       
  1052                     if (wildmatch(s,p,si,pi)) return true;
       
  1053                 } while (++si < slen);
       
  1054                 return false;
       
  1055             } else {
       
  1056                 if (si >= slen || c != s[si++]) return false;
       
  1057             }
       
  1058         }
       
  1059         return (si == slen);
       
  1060     }
       
  1061 
  1089 
  1062     // Category : Internal utilities <==============================
  1090     // Category : Internal utilities <==============================
  1063 
  1091 
  1064     // Category : Internal accessors ------------------------------>
  1092     // Category : Internal accessors ------------------------------>
  1065 
  1093 
  1175             //
  1203             //
  1176             in.defaultReadObject();
  1204             in.defaultReadObject();
  1177             cn = (String)in.readObject();
  1205             cn = (String)in.readObject();
  1178         }
  1206         }
  1179 
  1207 
       
  1208         final JMXNamespaceContext ctxt =
       
  1209                 JMXNamespaceContext.getDeserializationContext();
  1180         try {
  1210         try {
  1181             construct(cn);
  1211             construct(changeContext(ctxt,cn));
  1182         } catch (NullPointerException e) {
  1212         } catch (NullPointerException e) {
       
  1213             throw new InvalidObjectException(e.toString());
       
  1214         } catch (IllegalArgumentException e) {
  1183             throw new InvalidObjectException(e.toString());
  1215             throw new InvalidObjectException(e.toString());
  1184         } catch (MalformedObjectNameException e) {
  1216         } catch (MalformedObjectNameException e) {
  1185             throw new InvalidObjectException(e.toString());
  1217             throw new InvalidObjectException(e.toString());
  1186         }
  1218         }
  1187     }
  1219     }
  1188 
  1220 
       
  1221     private String changeContext(JMXNamespaceContext context, String nameString) {
       
  1222         final String old = context.prefixToRemove;
       
  1223         final String nw  = context.prefixToAdd;
       
  1224         final int ol = old.length();
       
  1225         if (nameString.startsWith(NAMESPACE_SEPARATOR)) return nameString;
       
  1226         if (ol>0) {
       
  1227             if (!nameString.startsWith(old) ||
       
  1228                     !nameString.startsWith(NAMESPACE_SEPARATOR,ol))
       
  1229                 throw new IllegalArgumentException(
       
  1230                         "Serialized ObjectName does not start with " + old +
       
  1231                         ": " + nameString);
       
  1232             nameString = nameString.substring(ol+NAMESPACE_SEPARATOR_LENGTH);
       
  1233         }
       
  1234         if (!nw.equals("")) {
       
  1235             nameString = nw + NAMESPACE_SEPARATOR + nameString;
       
  1236         }
       
  1237         // TODO remove this hack
       
  1238         // if (nameString.endsWith("//javax.management.service:type1=event_client_delegeate_mbean,type2=default")) {
       
  1239         //    System.err.println("old="+old+", nw="+nw);
       
  1240         //    Thread.currentThread().dumpStack();
       
  1241         //    throw new Error("************************ Gotcha!");
       
  1242         // }
       
  1243         return nameString;
       
  1244     }
  1189 
  1245 
  1190     /**
  1246     /**
  1191      * Serializes an {@link ObjectName} to an {@link ObjectOutputStream}.
  1247      * Serializes an {@link ObjectName} to an {@link ObjectOutputStream}.
  1192      * @serialData <ul>
  1248      * @serialData <ul>
  1193      *               <li>In the current serial form (value of property
  1249      *               <li>In the current serial form (value of property
  1246      *             </ul>
  1302      *             </ul>
  1247      */
  1303      */
  1248     private void writeObject(ObjectOutputStream out)
  1304     private void writeObject(ObjectOutputStream out)
  1249             throws IOException {
  1305             throws IOException {
  1250 
  1306 
       
  1307       final JMXNamespaceContext ctxt =
       
  1308                 JMXNamespaceContext.getSerializationContext();
       
  1309 
  1251       if (compat)
  1310       if (compat)
  1252       {
  1311       {
  1253         // Serializes this instance in the old serial form
  1312         // Serializes this instance in the old serial form
  1254         // Read CR 6441274 before making any changes to this code
  1313         // Read CR 6441274 before making any changes to this code
  1255         ObjectOutputStream.PutField fields = out.putFields();
  1314         ObjectOutputStream.PutField fields = out.putFields();
  1256         fields.put("domain", _canonicalName.substring(0, _domain_length));
  1315         final String domain =
       
  1316                 changeContext(ctxt,_canonicalName.substring(0, _domain_length));
       
  1317         final String cn =
       
  1318                 changeContext(ctxt,_canonicalName);
       
  1319         fields.put("domain", domain);
  1257         fields.put("propertyList", getKeyPropertyList());
  1320         fields.put("propertyList", getKeyPropertyList());
  1258         fields.put("propertyListString", getKeyPropertyListString());
  1321         fields.put("propertyListString", getKeyPropertyListString());
  1259         fields.put("canonicalName", _canonicalName);
  1322         fields.put("canonicalName", cn);
  1260         fields.put("pattern", (_domain_pattern || _property_list_pattern));
  1323         fields.put("pattern", (_domain_pattern || _property_list_pattern));
  1261         fields.put("propertyPattern", _property_list_pattern);
  1324         fields.put("propertyPattern", _property_list_pattern);
  1262         out.writeFields();
  1325         out.writeFields();
  1263       }
  1326       }
  1264       else
  1327       else
  1265       {
  1328       {
  1266         // Serializes this instance in the new serial form
  1329         // Serializes this instance in the new serial form
  1267         //
  1330         //
  1268         out.defaultWriteObject();
  1331         out.defaultWriteObject();
  1269         out.writeObject(getSerializedNameString());
  1332 
       
  1333         out.writeObject(changeContext(ctxt,getSerializedNameString()));
  1270       }
  1334       }
  1271     }
  1335     }
  1272 
  1336 
  1273     //  Category : Serialization <===================================
  1337     //  Category : Serialization <===================================
  1274 
  1338 
  1392     public static ObjectName getInstance(ObjectName name)
  1456     public static ObjectName getInstance(ObjectName name)
  1393             throws NullPointerException {
  1457             throws NullPointerException {
  1394         if (name.getClass().equals(ObjectName.class))
  1458         if (name.getClass().equals(ObjectName.class))
  1395             return name;
  1459             return name;
  1396         return Util.newObjectName(name.getSerializedNameString());
  1460         return Util.newObjectName(name.getSerializedNameString());
       
  1461     }
       
  1462 
       
  1463     /**
       
  1464      * Returns an {@code ObjectName} that is the same as this one but
       
  1465      * with the specified domain.
       
  1466      * This method preserves the original key order in the new instance.
       
  1467      * If the provided name has a key property pattern, it will also be
       
  1468      * preserved in the returned instance.
       
  1469      *
       
  1470      * @param newDomain The new domain for the returned instance;
       
  1471      *        must not be null.
       
  1472      * @return A new {@code ObjectName} that is the same as {@code this}
       
  1473      *         except the domain is {@code newDomain}.
       
  1474      * @throws NullPointerException if {@code newDomain} is null.
       
  1475      * @throws MalformedObjectNameException if the new domain is syntactically
       
  1476      *         illegal.
       
  1477      * @since 1.7
       
  1478      **/
       
  1479     public final ObjectName withDomain(String newDomain)
       
  1480             throws NullPointerException, MalformedObjectNameException {
       
  1481         return new ObjectName(newDomain, this);
  1397     }
  1482     }
  1398 
  1483 
  1399     /**
  1484     /**
  1400      * Construct an object name from the given string.
  1485      * Construct an object name from the given string.
  1401      *
  1486      *
  1548         throws NullPointerException, IllegalArgumentException {
  1633         throws NullPointerException, IllegalArgumentException {
  1549         if (property == null)
  1634         if (property == null)
  1550             throw new NullPointerException("key property can't be null");
  1635             throw new NullPointerException("key property can't be null");
  1551         for (int i = 0; i < _ca_array.length; i++) {
  1636         for (int i = 0; i < _ca_array.length; i++) {
  1552             Property prop = _ca_array[i];
  1637             Property prop = _ca_array[i];
  1553             String key = prop.getKeyString(_canonicalName);
  1638             String key = prop.getKeyString(_canonicalName,_domain_length);
  1554             if (key.equals(property))
  1639             if (key.equals(property))
  1555                 return (prop instanceof PatternProperty);
  1640                 return (prop instanceof PatternProperty);
  1556         }
  1641         }
  1557         throw new IllegalArgumentException("key property not found");
  1642         throw new IllegalArgumentException("key property not found");
  1558     }
  1643     }
  1628                 _propertyList = new HashMap<String,String>();
  1713                 _propertyList = new HashMap<String,String>();
  1629                 int len = _ca_array.length;
  1714                 int len = _ca_array.length;
  1630                 Property prop;
  1715                 Property prop;
  1631                 for (int i = len - 1; i >= 0; i--) {
  1716                 for (int i = len - 1; i >= 0; i--) {
  1632                     prop = _ca_array[i];
  1717                     prop = _ca_array[i];
  1633                     _propertyList.put(prop.getKeyString(_canonicalName),
  1718                     _propertyList.put(prop.getKeyString(_canonicalName,
  1634                                       prop.getValueString(_canonicalName));
  1719                                             _domain_length),
       
  1720                                       prop.getValueString(_canonicalName,
       
  1721                                             _domain_length));
  1635                 }
  1722                 }
  1636             }
  1723             }
  1637         }
  1724         }
  1638         return _propertyList;
  1725         return _propertyList;
  1639     }
  1726     }
  1714                 dest_chars[end]   = ',';
  1801                 dest_chars[end]   = ',';
  1715                 dest_chars[end+1] = '*';
  1802                 dest_chars[end+1] = '*';
  1716             }
  1803             }
  1717         }
  1804         }
  1718 
  1805 
  1719         return new String(dest_chars);
  1806         final String name = new String(dest_chars);
       
  1807         return name;
  1720     }
  1808     }
  1721 
  1809 
  1722     /**
  1810     /**
  1723      * <p>Write a string representation of the list of key
  1811      * <p>Write a string representation of the list of key
  1724      * properties specified at creation time in the given array, starting
  1812      * properties specified at creation time in the given array, starting
  1732     private int writeKeyPropertyListString(char[] canonicalChars,
  1820     private int writeKeyPropertyListString(char[] canonicalChars,
  1733                                            char[] data, int offset)  {
  1821                                            char[] data, int offset)  {
  1734         if (_kp_array.length == 0) return offset;
  1822         if (_kp_array.length == 0) return offset;
  1735 
  1823 
  1736         final char[] dest_chars = data;
  1824         final char[] dest_chars = data;
  1737         final char[] value = _canonicalName.toCharArray();
  1825         final char[] value = canonicalChars;
  1738 
  1826 
  1739         int index = offset;
  1827         int index = offset;
  1740         final int len = _kp_array.length;
  1828         final int len = _kp_array.length;
  1741         final int last = len - 1;
  1829         final int last = len - 1;
  1742         for (int i = 0; i < len; i++) {
  1830         for (int i = 0; i < len; i++) {
  1743             final Property prop = _kp_array[i];
  1831             final Property prop = _kp_array[i];
  1744             final int prop_len = prop._key_length + prop._value_length + 1;
  1832             final int prop_len = prop._key_length + prop._value_length + 1;
  1745             System.arraycopy(value, prop._key_index, dest_chars, index,
  1833             System.arraycopy(value, prop._key_index+_domain_length, dest_chars, index,
  1746                              prop_len);
  1834                              prop_len);
  1747             index += prop_len;
  1835             index += prop_len;
  1748             if (i < last ) dest_chars[index++] = ',';
  1836             if (i < last ) dest_chars[index++] = ',';
  1749         }
  1837         }
  1750         return index;
  1838         return index;
  1814 
  1902 
  1815         // equality when canonical names are the same
  1903         // equality when canonical names are the same
  1816         // (because usage of intern())
  1904         // (because usage of intern())
  1817         ObjectName on = (ObjectName) object;
  1905         ObjectName on = (ObjectName) object;
  1818         String on_string = on._canonicalName;
  1906         String on_string = on._canonicalName;
  1819         if (_canonicalName == on_string) return true;
  1907         if (_canonicalName == on_string) return true;  // ES: OK
  1820 
  1908 
  1821         // Because we are sharing canonical form between object names,
  1909         // Because we are sharing canonical form between object names,
  1822         // we have finished the comparison at this stage ==> unequal
  1910         // we have finished the comparison at this stage ==> unequal
  1823         return false;
  1911         return false;
  1824    }
  1912    }
  1995     }
  2083     }
  1996 
  2084 
  1997     private final boolean matchDomains(ObjectName name) {
  2085     private final boolean matchDomains(ObjectName name) {
  1998         if (_domain_pattern) {
  2086         if (_domain_pattern) {
  1999             // wildmatch domains
  2087             // wildmatch domains
  2000             final char[] dom_pattern = getDomain().toCharArray();
  2088             // This ObjectName is the pattern
  2001             final char[] dom_string  = name.getDomain().toCharArray();
  2089             // The other ObjectName is the string.
  2002             return wildmatch(dom_string,dom_pattern,0,0);
  2090             return Util.wildpathmatch(name.getDomain(),getDomain());
  2003         }
  2091         }
  2004         return getDomain().equals(name.getDomain());
  2092         return getDomain().equals(name.getDomain());
  2005     }
  2093     }
  2006 
  2094 
  2007     private final boolean matchKeys(ObjectName name) {
  2095     private final boolean matchKeys(ObjectName name) {
  2023             for (int i = props.length - 1; i >= 0 ; i--) {
  2111             for (int i = props.length - 1; i >= 0 ; i--) {
  2024                 // Find value in given object name for key at current
  2112                 // Find value in given object name for key at current
  2025                 // index in receiver
  2113                 // index in receiver
  2026                 //
  2114                 //
  2027                 final Property p = props[i];
  2115                 final Property p = props[i];
  2028                 final String   k = p.getKeyString(cn);
  2116                 final String   k = p.getKeyString(cn,_domain_length);
  2029                 final String   v = nameProps.get(k);
  2117                 final String   v = nameProps.get(k);
  2030                 // Did we find a value for this key ?
  2118                 // Did we find a value for this key ?
  2031                 //
  2119                 //
  2032                 if (v == null) return false;
  2120                 if (v == null) return false;
  2033                 // If this property is ok (same key, same value), go to next
  2121                 // If this property is ok (same key, same value), go to next
  2034                 //
  2122                 //
  2035                 if (_property_value_pattern && (p instanceof PatternProperty)) {
  2123                 if (_property_value_pattern && (p instanceof PatternProperty)) {
  2036                     // wildmatch key property values
  2124                     // wildmatch key property values
  2037                     final char[] val_pattern =
  2125                     // p is the property pattern, v is the string
  2038                             p.getValueString(cn).toCharArray();
  2126                     if (Util.wildmatch(v,p.getValueString(cn,_domain_length)))
  2039                     final char[] val_string  = v.toCharArray();
       
  2040                     if (wildmatch(val_string,val_pattern,0,0))
       
  2041                         continue;
  2127                         continue;
  2042                     else
  2128                     else
  2043                         return false;
  2129                         return false;
  2044                 }
  2130                 }
  2045                 if (v.equals(p.getValueString(cn))) continue;
  2131                 if (v.equals(p.getValueString(cn,_domain_length))) continue;
  2046                 return false;
  2132                 return false;
  2047             }
  2133             }
  2048             return true;
  2134             return true;
  2049         }
  2135         }
  2050 
  2136 
  2107      *         specified ObjectName.
  2193      *         specified ObjectName.
  2108      *
  2194      *
  2109      * @since 1.6
  2195      * @since 1.6
  2110      */
  2196      */
  2111     public int compareTo(ObjectName name) {
  2197     public int compareTo(ObjectName name) {
       
  2198         // Quick optimization:
       
  2199         //
       
  2200         if (name == this) return 0;
       
  2201 
  2112         // (1) Compare domains
  2202         // (1) Compare domains
  2113         //
  2203         //
  2114         int domainValue = this.getDomain().compareTo(name.getDomain());
  2204         int domainValue = this.getDomain().compareTo(name.getDomain());
  2115         if (domainValue != 0)
  2205         if (domainValue != 0)
  2116             return domainValue;
  2206             return domainValue;