Updated OBR's VersionRange to match the Framework's VersionRange...duplication
is bad. As a result, OBR's VersionRange will now accept whitespace in its
version range. (FELIX-389)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@581718 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/VersionRange.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/VersionRange.java
index 7c81c15..b4fb9ac 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/VersionRange.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/VersionRange.java
@@ -26,6 +26,8 @@
     private boolean m_isLowInclusive = false;
     private Version m_high = null;
     private boolean m_isHighInclusive = false;
+    private String m_toString = null;
+    public static final VersionRange infiniteRange = new VersionRange(Version.emptyVersion, true, null, true);
 
     public VersionRange(Version low, boolean isLowInclusive,
         Version high, boolean isHighInclusive)
@@ -84,8 +86,8 @@
         if (range.indexOf(',') >= 0)
         {
             String s = range.substring(1, range.length() - 1);
-            String vlo = s.substring(0, s.indexOf(','));
-            String vhi = s.substring(s.indexOf(',') + 1, s.length());
+            String vlo = s.substring(0, s.indexOf(',')).trim();
+            String vhi = s.substring(s.indexOf(',') + 1, s.length()).trim();
             return new VersionRange (
                 new Version(vlo), (range.charAt(0) == '['),
                 new Version(vhi), (range.charAt(range.length() - 1) == ']'));
@@ -95,4 +97,26 @@
             return new VersionRange(new Version(range), true, null, false);
         }
     }
-}
\ No newline at end of file
+
+    public String toString()
+    {
+        if (m_toString == null)
+        {
+            if (m_high != null)
+            {
+                StringBuffer sb = new StringBuffer();
+                sb.append(m_isLowInclusive ? '[' : '(');
+                sb.append(m_low.toString());
+                sb.append(',');
+                sb.append(m_high.toString());
+                sb.append(m_isHighInclusive ? ']' : ')');
+                m_toString = sb.toString();
+            }
+            else
+            {
+                m_toString = m_low.toString();
+            }
+        }
+        return m_toString;
+    }
+}