mirror of https://github.com/apache/activemq.git
AMQ-4010: Use pre compiled pattern when doing string replaceAll as its faster.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1379761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3092051699
commit
0e724cd53f
|
@ -16,17 +16,24 @@
|
|||
*/
|
||||
package org.apache.activemq.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class JMXSupport {
|
||||
|
||||
private static final Pattern PART_1 = Pattern.compile("[\\:\\,\\'\\\"]");
|
||||
private static final Pattern PART_2 = Pattern.compile("\\?");
|
||||
private static final Pattern PART_3 = Pattern.compile("=");
|
||||
private static final Pattern PART_4 = Pattern.compile("\\*");
|
||||
|
||||
private JMXSupport() {
|
||||
}
|
||||
|
||||
public static String encodeObjectNamePart(String part) {
|
||||
// return ObjectName.quote(part);
|
||||
String answer = part.replaceAll("[\\:\\,\\'\\\"]", "_");
|
||||
answer = answer.replaceAll("\\?", "&qe;");
|
||||
answer = answer.replaceAll("=", "&");
|
||||
answer = answer.replaceAll("\\*", "*");
|
||||
String answer = PART_1.matcher(part).replaceAll("_");
|
||||
answer = PART_2.matcher(answer).replaceAll("&qe;");
|
||||
answer = PART_3.matcher(answer).replaceAll("&");
|
||||
answer = PART_4.matcher(answer).replaceAll("*");
|
||||
return answer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue