ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r781818 - /ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/SystemUtils.java
Date Thu, 04 Jun 2009 18:11:57 GMT
Author: midon
Date: Thu Jun  4 18:11:56 2009
New Revision: 781818

URL: http://svn.apache.org/viewvc?rev=781818&view=rev
Log:
better usage of regex Pattern

Modified:
    ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/SystemUtils.java

Modified: ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/SystemUtils.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/SystemUtils.java?rev=781818&r1=781817&r2=781818&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/SystemUtils.java
(original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/SystemUtils.java
Thu Jun  4 18:11:56 2009
@@ -27,8 +27,9 @@
  */
 
 public class SystemUtils {
+    private static final Pattern PROPERTY_PATTERN = Pattern.compile("\\$\\{([^\\}]+)\\}");
 
-	/**
+    /**
 	 * @see System#getProperties()
 	 */
 	public static String javaVersion() {
@@ -146,13 +147,12 @@
 	 * e.g., "The java version is ${java.version}" ==> "The java version is 1.5.0_11"
 	 */
 	public static String replaceSystemProperties(String str) {
-		Pattern pattern = Pattern.compile("\\$\\{[^\\}]+\\}");
-		int start = 0;
+        int start = 0;
 		while (true) {
-			Matcher match = pattern.matcher(str);
+			Matcher match = PROPERTY_PATTERN.matcher(str);
 			if (!match.find(start))
 				break;
-			String property = str.substring(match.start() + 2, match.end() - 1);
+			String property = match.group(1);
 			String value = System.getProperty(property);
 			if (value != null) {
 				str = match.replaceFirst(Matcher.quoteReplacement(value));



Mime
View raw message