/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.activemq.util;

public final class JMXSupport {

    private JMXSupport() {
    }

    public static String encodeObjectNamePart(String part) {
        // return ObjectName.quote(part);
        String answer = part.replaceAll("[\\:\\,\\'\\\"]", "_");
        answer = answer.replaceAll("\\?", "&qe;");
        answer = answer.replaceAll("=", "&amp;");
        answer = answer.replaceAll("\\*", "&ast;");
        return answer;
    }
}

@@ -832,16 +832,49 @@
 .util;%0A%0A
+import java.util.regex.Pattern;%0A%0A
 public f
@@ -914,95 +914,302 @@
 ate 
-JMXSupport() %7B%0A    %7D%0A%0A    public static String encodeObjectNamePart(String pa
+static final Pattern PART_1 = Pattern.compile(%22%5B%5C%5C:%5C%5C,%5C%5C'%5C%5C%5C%22%5D%22);%0A    private static final Pattern PART_2 = Pattern.compile(%22%5C%5C?%22);%0A    private static final Pattern PART_3 = Pattern.compile(%22=%22);%0A    private static final Pattern PART_4 = Pattern.compile(%22%5C%5C*%22);%0A%0A    private JMXSuppo
 rt
+(
 ) %7B%0A    
     
@@ -1208,45 +1208,71 @@
     
+%7D%0A%0A
     
-// return ObjectName.quote(
+public static String encodeObjectNamePart(String 
 part)
-;
+ %7B
 %0A   
@@ -1292,20 +1292,36 @@
 nswer = 
+PART_1.matcher(
 part
+)
 .replace
@@ -1328,27 +1328,8 @@
 All(
-%22%5B%5C%5C:%5C%5C,%5C%5C'%5C%5C%5C%22%5D%22, 
 %22_%22)
@@ -1339,38 +1339,54 @@
        answer = 
+PART_2.matcher(
 answer
+)
 .replaceAll(%22%5C%5C?
@@ -1385,15 +1385,8 @@
 All(
-%22%5C%5C?%22, 
 %22&qe
@@ -1399,38 +1399,54 @@
        answer = 
+PART_3.matcher(
 answer
+)
 .replaceAll(%22=%22,
@@ -1445,13 +1445,8 @@
 All(
-%22=%22, 
 %22&am
@@ -1468,22 +1468,38 @@
 nswer = 
+PART_4.matcher(
 answer
+)
 .replace
@@ -1506,15 +1506,8 @@
 All(
-%22%5C%5C*%22, 
 %22&as
@@ -1541,10 +1541,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Use pre compiled pattern when doing string replaceAll as its faster.