Update to use the new Bindex version. Fix the Id bug.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@600988 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java b/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java
index 6d0be6e..01cc719 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java
@@ -33,7 +33,7 @@
 import org.osgi.impl.bundle.obr.resource.RepositoryImpl;

 import org.osgi.impl.bundle.obr.resource.RequirementImpl;

 import org.osgi.impl.bundle.obr.resource.ResourceImpl;

-import org.osgi.impl.bundle.obr.resource.VersionImpl;

+import org.osgi.impl.bundle.obr.resource.VersionRange;

 

 /**

  * this class is used to configure bindex and get information built by bindex about targeted bundle.

@@ -121,7 +121,7 @@
                         if (value instanceof Number) {

                             type = "number";

                         } else { 

-                            if (value.getClass() == VersionImpl.class) { type = "version"; }

+                            if (value.getClass() == VersionRange.class) { type = "version"; }

                         }

                         if (type != null) {

                             p.setT(type);

@@ -238,5 +238,17 @@
             return null;

         }

     }

+    

+    /**

+     * extract source from bindex information.

+     * @return bundle source

+     */

+    public String getId() {

+        if (m_resource.getId() != null) {

+            return m_resource.getId();

+        } else {

+            return null;

+        }

+    }

 

 }

diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java b/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java
index 4809951..dd7f45a 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java
@@ -100,11 +100,6 @@
     private Document m_repoDoc;

 

     /**

-     * used to determine the first free id.

-     */

-    private boolean[] m_idTab;

-

-    /**

      * first Node on repository descriptor tree.

      */

     private Node m_root;

@@ -143,8 +138,6 @@
         this.m_logger = log;

 

         this.m_userConfig = userConfig;

-        // init the tab

-        m_idTab = new boolean[0];

 

         m_resourceBundle = new ResourcesBundle(log);

 

@@ -153,7 +146,6 @@
         } else {

             this.m_repo = repoFilename;

         }

-        // System.err.println("Construct: "+repoFilename.getAbsoluteFilename());

     }

 

     /**

@@ -217,15 +209,7 @@
         if (!walkOnTree(m_root)) {

             // the correct resource node was not found, we must create it

             // we compute the new id

-            int id = -1;

-            for (int i = 1; i < m_idTab.length; i++) {

-                if (!m_idTab[i]) {

-                    id = i;

-                    break;

-                }

-            }

-            if (id == -1) { id = m_idTab.length; }

-

+            String id = m_resourceBundle.getId();

             searchRepository(m_root, id);

         }

 

@@ -263,7 +247,6 @@
         if (!fout.exists()) {

             // create the repository.xml

             try {

-

             	fout.createNewFile();

                 m_logger.info("Created "+fout.getAbsolutePath());

             } catch (IOException e) {

@@ -465,12 +448,12 @@
      * @param node Node on the xml file

      * @param id id of the bundle ressource

      */

-    private void searchRepository(Node node, int id) {

+    private void searchRepository(Node node, String id) {

         if (node.getNodeName().compareTo("repository") == 0) {

-            m_resourceBundle.setId(String.valueOf(id));

             node.appendChild(m_resourceBundle.getNode(m_repoDoc));

             return;

         } else {

+            System.out.println("Second branch...");

             NodeList list = node.getChildNodes();

             if (list.getLength() > 0) {

                 for (int i = 0; i < list.getLength(); i++) {

@@ -489,25 +472,10 @@
     private boolean resource(Node node) {

 

         // this part save all the id free if we need to add resource

-        int id = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue());

-        if (id >= m_idTab.length) {

-            // resize tab

-            boolean[] bt = new boolean[id + 1];

-            for (int i = 0; i < id + 1; i++) {

-                if (m_idTab.length > i && m_idTab[i]) {

-                    bt[i] = true;

-                } else {

-                    bt[i] = false;

-                }

-            }

-

-            m_idTab = bt;

-        }

-        m_idTab[id] = true;

-

+        String id = node.getAttributes().getNamedItem("id").getNodeValue();

         NamedNodeMap map = node.getAttributes();

 

-        if (m_resourceBundle.isSameBundleResource(map.getNamedItem("symbolicname").getNodeValue(), map.getNamedItem("presentationname").getNodeValue(), map.getNamedItem("version").getNodeValue())) {

+        if (m_resourceBundle.isSameBundleResource(map.getNamedItem("symbolicname").getNodeValue(), map.getNamedItem("version").getNodeValue())) {

             m_resourceBundle.setId(String.valueOf(id));

             node.getParentNode().replaceChild(m_resourceBundle.getNode(m_repoDoc), node);

             return true;

diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java b/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java
index 5d006f1..f86fa44 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java
@@ -332,6 +332,10 @@
         } else {

             this.setVersion(project.getVersion());

         }

+        

+        if (ebi.getId() != null) {

+            this.setId(ebi.getId());

+        }

 

         if (ebi.getDescription() != null) {

             this.setDescription(ebi.getDescription());

@@ -427,7 +431,7 @@
      * @return false if an information is missing, else true

      */

     public boolean isValid() {

-        // we must verify require properties are present

+        // we must verify required properties are present

         return this.getPresentationName() != null 

             && this.getSymbolicName() != null

             && this.getVersion() != null 

@@ -436,18 +440,15 @@
     }

 

     /**

-     * test if this bundle has the same symbolicname, presentationname and version number.

+     * test if this bundle has the same symbolicname, and version number.

      * @param symbolicName symbolicName to compare with current bundle

      * @param presentationName presentationName to compare with current bundlde

      * @param version version to compare with current bundle

      * @return true if the information are the same, else false

      */

-    public boolean isSameBundleResource(String symbolicName, String presentationName, String version) {

+    public boolean isSameBundleResource(String symbolicName, String version) {

         if (this.isValid()) {

-            boolean result;

-            result = (symbolicName.compareTo(this.getSymbolicName()) == 0) && (version.compareTo(this.getVersion()) == 0) && (presentationName.compareTo(this.getPresentationName()) == 0);

-            return result;

-

+            return (symbolicName.compareTo(this.getSymbolicName()) == 0) && (version.compareTo(this.getVersion()) == 0);

         } else {

             return false;

         }

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java
index 5da803b..2e68a9a 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java
@@ -1,3 +1,20 @@
+/*

+ * $Id: BundleInfo.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.io.*;

@@ -11,7 +28,7 @@
  * Convert a bundle to a generic resource description and store its local

  * dependencies (like for example a license file in the JAR) in a zip file.

  * 

- * @version $Revision: 1.18 $

+ * @version $Revision: 44 $

  */

 public class BundleInfo {

 	Manifest	manifest;

@@ -191,8 +208,8 @@
 				ri.setComment("Import Service " + entry.getName());

 

 				// TODO the following is arbitrary

-				ri.setOptional(true);

-				ri.setMultiple(false);

+				ri.setOptional(false);

+				ri.setMultiple(true);

 				resource.addRequirement(ri);

 			}

 		}

@@ -326,22 +343,21 @@
 		filter.append("=");

 		filter.append(pack.getName());

 		filter.append(")");

-		VersionImpl version = pack.getVersion();

+		VersionRange version = pack.getVersion();

 		if (version != null) {

-			VersionRange range = version.getRange();

-			if (range != null) {

+			if ( version.isRange() ) {

 				filter.append("(version");

 				filter.append(">");

-				if (range.getIncludeMinimum())

+				if (version.includeLow())

 					filter.append("=");

-				filter.append(range.getMinimum());

+				filter.append(version.low);

 				filter.append(")");

 

 				filter.append("(version");

 				filter.append("<");

-				if (range.getIncludeMaximum())

+				if (version.includeHigh())

 					filter.append("=");

-				filter.append(range.getMaximum());

+				filter.append(version.high);

 				filter.append(")");

 			}

 			else {

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java
index 34b0460..45d2d1b 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java
@@ -1,3 +1,20 @@
+/*

+ * $Id: CapabilityImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.util.*;

@@ -28,7 +45,7 @@
 				if ( "nummeric".equals(type))

 					v = new Long(value);

 				else if ( "version".equals(type))

-					v = new VersionImpl(value);

+					v = new VersionRange(value);

 				addProperty(name,v);

 			}

 			parser.next();

@@ -70,7 +87,7 @@
 				String type = null;

 				if (value instanceof Number )

 					type = "number";

-				else if (value.getClass() == VersionImpl.class)

+				else if (value.getClass() == VersionRange.class)

 					type = "version";

 				if (type != null)

 					p.addAttribute("t", type);

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java
index d6fc637..bc12314 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java
@@ -1,15 +1,21 @@
-/**

+/*

+ * $Id: FilterImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

  * Copyright (c) 2000 Gatespace AB. All Rights Reserved.

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

  *

- * Gatespace grants Open Services Gateway Initiative (OSGi) an irrevocable,

- * perpetual, non-exclusive, worldwide, paid-up right and license to

- * reproduce, display, perform, prepare and have prepared derivative works

- * based upon and distribute and sublicense this material and derivative

- * works thereof as set out in the OSGi MEMBER AGREEMENT as of January 24

- * 2000, for use in accordance with Section 2.2 of the BY-LAWS of the

- * OSGi MEMBER AGREEMENT.

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.lang.reflect.*;

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java
index 25b0e12..01c3f51 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java
@@ -1,12 +1,28 @@
+/*

+ * $Id: Manifest.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.io.*;

 import java.util.*;

 

-import org.osgi.impl.bundle.obr.resource.VersionImpl;

-

 

 public class Manifest extends Hashtable {

+	static final long	serialVersionUID	= 1L;

 	List				imports;

 	List				exports;

 	ManifestEntry		name;

@@ -18,7 +34,7 @@
 	Vector				duplicates	= new Vector();

 	final static String	wordparts	= "~!@#$%^&*_:/?><.-+";

 	ManifestEntry		bsn;

-	VersionImpl			version;

+	VersionRange			version;

 	ManifestEntry		host;

 	List				require;

 

@@ -91,10 +107,10 @@
 				}

 				if (header.equals("bundle-version")) {

 					try {

-						version = new VersionImpl(value.trim());

+						version = new VersionRange(value.trim());

 					}

 					catch (Exception e) {

-						version = new VersionImpl("0");

+						version = new VersionRange("0");

 						System.err.println("Invalid version attr for: " + bsn

 								+ " value is " + value);

 					}

@@ -295,9 +311,9 @@
 			return null;

 	}

 

-	public VersionImpl getVersion() {

+	public VersionRange getVersion() {

 		if (version == null)

-			return new VersionImpl("0");

+			return new VersionRange("0");

 		return version;

 	}

 

@@ -305,12 +321,10 @@
 		ManifestEntry bsn = getBsn();

 

 		if (bsn == null) {

-			//nox if the symbolic name is not define in manifest fils, we take the 

-			//artefactId from the pom.xml file

-			/*String name = getValue("Bundle-Name");

+			String name = getValue("Bundle-Name");

 			if (name == null)

-				name = "Untitled-" + hashCode();*/

-			return null;

+				name = "Untitled-" + hashCode();

+			return name;

 		}

 		else

 			return bsn.getName();

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java
index f26f22f..2dc3e69 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java
@@ -1,13 +1,28 @@
+/*

+ * $Id: ManifestEntry.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.util.*;

 

-import org.osgi.impl.bundle.obr.resource.VersionImpl;

-

 

 public class ManifestEntry implements Comparable {

 	String		name;

-	VersionImpl	version;

+	VersionRange	version;

 	Map			attributes;

 	public Map	directives;

 	public Set	uses;

@@ -16,7 +31,7 @@
 		this.name = name;

 	}

 

-	public ManifestEntry(String name, VersionImpl version) {

+	public ManifestEntry(String name, VersionRange version) {

 		this.name = name;

 		this.version = version;

 	}

@@ -31,10 +46,10 @@
 		return name;

 	}

 

-	public VersionImpl getVersion() {

+	public VersionRange getVersion() {

 		if (version != null)

 			return version;

-		return new VersionImpl("0");

+		return new VersionRange("0");

 	}

 

 	/*

@@ -74,7 +89,7 @@
 				if (parameter.key.equalsIgnoreCase("version")

 						|| parameter.key

 								.equalsIgnoreCase("specification-version"))

-					this.version = new VersionImpl(parameter.value);

+					this.version = new VersionRange(parameter.value);

 				break;

 

 			case Parameter.DIRECTIVE :

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java
index 1edfb7e..5038132 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java
@@ -1,30 +1,20 @@
 /*

- * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/Parameter.java,v 1.1 2006/07/27 10:31:02 pkriens Exp $

+ * $Id: Parameter.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

  * 

- * Copyright (c) The OSGi Alliance (2005). All Rights Reserved.

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

  * 

- * Implementation of certain elements of the OSGi Specification may be subject

- * to third party intellectual property rights, including without limitation,

- * patent rights (such a third party may or may not be a member of the OSGi

- * Alliance). The OSGi Alliance is not responsible and shall not be held

- * responsible in any manner for identifying or failing to identify any or all

- * such third party intellectual property rights.

- * 

- * This document and the information contained herein are provided on an "AS IS"

- * basis and THE OSGI ALLIANCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,

- * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION

- * HEREIN WILL NOT INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF

- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE

- * OSGI ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF

- * USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR

- * EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN

- * CONNECTION WITH THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF

- * ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.

- * 

- * All Company, brand and product names may be trademarks that are the sole

- * property of their respective owners. All rights reserved.

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 class Parameter {

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java
index 0c27962..bc6953b 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java
@@ -1,28 +1,19 @@
 /*

- * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/RepositoryImpl.java,v 1.11 2006/04/27 09:00:16 pkriens Exp $

+ * $Id: RepositoryImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

  * 

- * Copyright (c) The OSGi Alliance (2005). All Rights Reserved.

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

  * 

- * Implementation of certain elements of the OSGi Specification may be subject

- * to third party intellectual property rights, including without limitation,

- * patent rights (such a third party may or may not be a member of the OSGi

- * Alliance). The OSGi Alliance is not responsible and shall not be held

- * responsible in any manner for identifying or failing to identify any or all

- * such third party intellectual property rights.

- * 

- * This document and the information contained herein are provided on an "AS IS"

- * basis and THE OSGI ALLIANCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,

- * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION

- * HEREIN WILL NOT INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF

- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE

- * OSGI ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF

- * USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR

- * EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN

- * CONNECTION WITH THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF

- * ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.

- * 

- * All Company, brand and product names may be trademarks that are the sole

- * property of their respective owners. All rights reserved.

+ * Licensed 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.osgi.impl.bundle.obr.resource;

@@ -33,16 +24,14 @@
 import java.util.zip.*;

 

 import org.kxml2.io.KXmlParser;

-import org.osgi.service.obr.Repository;

-import org.osgi.service.obr.Resource;

-

+import org.osgi.service.obr.*;

 import org.xmlpull.v1.*;

 

 /**

  * Implements the basic repository. A repository holds a set of resources.

  * 

  * 

- * @version $Revision: 1.11 $

+ * @version $Revision: 44 $

  */

 public class RepositoryImpl implements Repository {

 	transient Set			resources		= new HashSet();

@@ -184,10 +173,10 @@
 						sb.append(")");

 						String version = parser.getAttributeValue(null,

 								"specification-version");

-						VersionImpl v = new VersionImpl("0");

+						VersionRange v = new VersionRange("0");

 						if (version != null) {

 							sb.append("(version=");

-							sb.append(v= new VersionImpl(version));

+							sb.append(v= new VersionRange(version));

 							sb.append(")");

 						}

 						sb.append(")");

@@ -205,7 +194,7 @@
 						String version = parser.getAttributeValue(null,

 								"specification-version");

 						if (version != null) {

-							capability.addProperty("version", new VersionImpl(

+							capability.addProperty("version", new VersionRange(

 									version));

 						}

 						resource.addCapability(capability);

@@ -228,7 +217,7 @@
 							resource.setPresentationName(value);

 						}

 						else if (key.equals("bundle-version"))

-							resource.setVersion(new VersionImpl(value));

+							resource.setVersion(new VersionRange(value));

 						else {

 							resource.put(key, value);

 						}

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java
index 97032a7..146618a 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java
@@ -1,3 +1,20 @@
+/*

+ * $Id: RequirementImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import org.osgi.service.obr.*;

@@ -9,7 +26,7 @@
  * Implements the Requirement interface.

  * 

  * 

- * @version $Revision: 1.8 $

+ * @version $Revision: 44 $

  */

 public class RequirementImpl implements Requirement {

 	int		id;

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java
index beedc0d..55cd298 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java
@@ -1,3 +1,20 @@
+/*

+ * $Id: ResourceImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.io.File;

@@ -13,7 +30,7 @@
 	List			requirements	= new ArrayList();

 	URL				url;

 	String			symbolicName;

-	VersionImpl		version;

+	VersionRange		version;

 	List			categories		= new ArrayList();

 	long			size			= -1;

 	String			id;

@@ -23,13 +40,12 @@
 	String			presentationName;

 	File			file;

 

-	{

-		id = Integer.toString(ID++);

-	}

 

 	public ResourceImpl(RepositoryImpl repository, String name,

-			VersionImpl version) {

+			VersionRange version) {

 		this.version = version;

+		if ( version == null)

+			this.version = new VersionRange("0");

 		this.symbolicName = name;

 		this.repository = repository;

 	}

@@ -49,9 +65,9 @@
 			map.put(PRESENTATION_NAME, presentationName);

 		String v = parser.getAttributeValue(null, "version");

 		if (v == null)

-			setVersion(new VersionImpl("0"));

+			setVersion(new VersionRange("0"));

 		else

-			setVersion(new VersionImpl(v));

+			setVersion(new VersionRange(v));

 

 		setURL(toURL(parser.getAttributeValue(null, "uri")));

 

@@ -221,13 +237,13 @@
 

 	public Version getVersion() {

 		if (version == null)

-			version = new VersionImpl("0");

-		return version;

+			version = new VersionRange("0");

+		return version.low;

 	}

 

-	void setVersion(VersionImpl version) {

+	void setVersion(VersionRange version) {

 		if (version == null)

-			this.version = new VersionImpl("0");

+			this.version = new VersionRange("0");

 		else

 			this.version = version;

 	}

@@ -308,7 +324,9 @@
 		return Collections.unmodifiableMap(map);

 	}

 

-	public String getId() {

+	public synchronized String getId() {

+		if ( id == null )

+			id = symbolicName + "/" + version;

 		return id;

 	}

 

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java
index d69958d..d2bbd5d 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java
@@ -1,35 +1,28 @@
 /*

- * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/StringSet.java,v 1.1 2006/01/03 16:22:46 pkriens Exp $

+ * $Id: StringSet.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

  * 

- * Copyright (c) The OSGi Alliance (2006). All Rights Reserved.

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

  * 

- * Implementation of certain elements of the OSGi Specification may be subject

- * to third party intellectual property rights, including without limitation,

- * patent rights (such a third party may or may not be a member of the OSGi

- * Alliance). The OSGi Alliance is not responsible and shall not be held

- * responsible in any manner for identifying or failing to identify any or all

- * such third party intellectual property rights.

- * 

- * This document and the information contained herein are provided on an "AS IS"

- * basis and THE OSGI ALLIANCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,

- * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION

- * HEREIN WILL NOT INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF

- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE

- * OSGI ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF

- * USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR

- * EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN

- * CONNECTION WITH THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF

- * ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.

- * 

- * All Company, brand and product names may be trademarks that are the sole

- * property of their respective owners. All rights reserved.

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.util.*;

 

 public class StringSet extends HashSet {

+	static final long	serialVersionUID	= 1L;

 

 	public StringSet(String set) {

 		StringTokenizer st = new StringTokenizer(set, ",");

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java
index e077969..3c1375f 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java
@@ -1,3 +1,20 @@
+/*

+ * $Id: Tag.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $

+ * 

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

 import java.io.*;

@@ -267,7 +284,7 @@
 	 */

 	String escape(String s) {

 		if  ( s == null )

-			System.out.println("??");

+			return "?null?";

 		

 		StringBuffer sb = new StringBuffer();

 		for (int i = 0; i < s.length(); i++) {

diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionImpl.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionImpl.java
deleted file mode 100644
index 8071166..0000000
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*

- * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/VersionImpl.java,v 1.3 2006/02/15 16:36:57 pkriens Exp $

- * 

- * Copyright (c) OSGi Alliance (2004, 2005). All Rights Reserved.

- * 

- * This program and the accompanying materials are made available under the

- * terms of the Eclipse Public License v1.0 which accompanies this 

- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.

- */

-

-package org.osgi.impl.bundle.obr.resource;

-

-import org.osgi.framework.Version;

-

-/**

- * Version identifier for bundles and packages.

- * 

- * <p>

- * Version identifiers have four components.

- * <ol>

- * <li>Major version. A non-negative integer.</li>

- * <li>Minor version. A non-negative integer.</li>

- * <li>Micro version. A non-negative integer.</li>

- * <li>Qualifier. A text string. See <code>Version(String)</code> for the

- * format of the qualifier string.</li>

- * </ol>

- * 

- * <p>

- * <code>Version</code> objects are immutable.

- * 

- * @version $Revision: 1.3 $

- * @since 1.3

- */

-

-public class VersionImpl extends Version {

-	VersionRange	range;

-

-	/**

-	 * Creates a version identifier from the specified numerical components.

-	 * 

-	 * <p>

-	 * The qualifier is set to the empty string.

-	 * 

-	 * @param major Major component of the version identifier.

-	 * @param minor Minor component of the version identifier.

-	 * @param micro Micro component of the version identifier.

-	 * @throws IllegalArgumentException If the numerical components are

-	 *         negative.

-	 */

-	public VersionImpl(int major, int minor, int micro) {

-		this(major, minor, micro, null);

-	}

-

-	/**

-	 * Creates a version identifier from the specifed components.

-	 * 

-	 * @param major Major component of the version identifier.

-	 * @param minor Minor component of the version identifier.

-	 * @param micro Micro component of the version identifier.

-	 * @param qualifier Qualifier component of the version identifier. If

-	 *        <code>null</code> is specified, then the qualifier will be set

-	 *        to the empty string.

-	 * @throws IllegalArgumentException If the numerical components are negative

-	 *         or the qualifier string is invalid.

-	 */

-	public VersionImpl(int major, int minor, int micro, String qualifier) {

-		super(major, minor, micro, qualifier);

-	}

-

-	// TODO Ugly!

-	public VersionImpl(String string) {

-		super(

-				string.indexOf("[") >= 0 || string.indexOf("(") >= 0 ? new VersionRange(

-						string).getMinimum().toString()

-						: string);

-		if ( string.indexOf("[") >= 0 || string.indexOf("(") >= 0 )

-			range = new VersionRange(string);

-	}

-

-	VersionRange getRange() {

-		return range;

-	}

-	/**

-	 * 	this	other		0		1		-1

-	 * 	

-	 * @param o

-	 * @return

-	 * @see org.osgi.framework.Version#compareTo(java.lang.Object)

-	 */

-	public int compareTo(Object o) {

-		if ( o instanceof VersionImpl ) {

-			VersionImpl	other = (VersionImpl) o;

-			int cs = 0;

-			if ( range != null )

-				cs++;

-			if ( other.range!=null)

-				cs+=2;

-			switch (cs ) {

-				case 0:	// V1 V2

-					return super.compareTo(other);

-					

-				case 1:	// R1 V2

-					return range.isIncluded(other) ? 0 : 1;

-					

-				case 2:	// V1 R2

-					return other.range.isIncluded(this) ? 0 : 1;

-	

-					// TODO experimental

-				case 3:	// R1 R2

-					return range.isIncluded(other.range.getMinimum()) && range.isIncluded(other.range.getMaximum()) ? 0 : 1;			

-			}

-			return -1;

-		} else {

-			return super.compareTo(o);

-		}

-	}

-

-	public boolean equals(Object other) {

-		return compareTo(other) == 0;

-	}

-}
\ No newline at end of file
diff --git a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java
index 820e5ce..920d67f 100644
--- a/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java
+++ b/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java
@@ -1,166 +1,119 @@
-/*******************************************************************************

- * Copyright (c) 2003, 2005 IBM Corporation and others.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * which accompanies this distribution, and is available at

- * http://www.eclipse.org/legal/epl-v10.html

+/*

+ * $Id: VersionRange.java 45 2007-10-01 12:56:02Z peter.kriens@aqute.biz $

  * 

- * Contributors:

- *     IBM Corporation - initial API and implementation

- *******************************************************************************/

+ * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved.

+ * 

+ * Licensed 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.osgi.impl.bundle.obr.resource;

 

-import org.osgi.framework.Version;

+import java.util.regex.*;

 

-/**

- * This class represents a version range.

- * @since 3.1

- */

-public class VersionRange {

-	private static final Version versionMax = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);

-	/**

-	 * An empty version

-	 */

-	public static final VersionRange emptyRange = new VersionRange(null);

+import org.osgi.framework.*;

 

-	private Version minVersion;

-	private boolean includeMin; 

-	private Version maxVersion;

-	private boolean includeMax;

+public class VersionRange implements Comparable {

+	Version high;

+	Version low;

+	char start = '[';

+	char end = ']';

 

-	/**

-	 * Constructs a VersionRange with the specified minVersion and maxVersion.

-	 * @param minVersion the minimum version of the range

-	 * @param maxVersion the maximum version of the range

-	 */

-	public VersionRange(Version minVersion, boolean includeMin, Version maxVersion, boolean includeMax) {

-		this.minVersion = minVersion;

-		this.includeMin = includeMin;

-		this.maxVersion = maxVersion;

-		this.includeMax = includeMax;

+	static String V = "[0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[a-zA-Z0-9_-]+)?)?)?";

+	static Pattern RANGE = Pattern.compile("(\\(|\\[)(" + V + "),(" + V

+			+ ")(\\)|\\])");

+

+	public VersionRange(String string) {

+		string = string.trim();

+		Matcher m = RANGE.matcher(string);

+		if (m.matches()) {

+			start = m.group(1).charAt(0);

+			low = new Version(m.group(2));

+			high = new Version(m.group(6));

+			end = m.group(10).charAt(0);

+			if (low.compareTo(high) >= 0)

+				throw new IllegalArgumentException(

+						"Low Range is higher than High Range: " + low + "-"

+								+ high);

+

+		} else

+			high = low = new Version(string);

 	}

 

-	/**

-	 * Constructs a VersionRange from the given versionRange String.

-	 * @param versionRange a version range String that specifies a range of

-	 * versions.

-	 */

-	public VersionRange(String versionRange) {

-		if (versionRange == null || versionRange.length() == 0) {

-			minVersion = Version.emptyVersion;

-			includeMin = true;

-			maxVersion = VersionRange.versionMax;

-			includeMax = true;

-			return;

-		}

-		versionRange = versionRange.trim();

-		if (versionRange.charAt(0) == '[' || versionRange.charAt(0) == '(') {

-			int comma = versionRange.indexOf(',');

-			if (comma < 0)

-				throw new IllegalArgumentException();

-			char last = versionRange.charAt(versionRange.length() - 1);

-			if (last != ']' && last != ')')

-				throw new IllegalArgumentException();

-

-			minVersion = Version.parseVersion(versionRange.substring(1, comma).trim());

-			includeMin = versionRange.charAt(0) == '[';

-			maxVersion = Version.parseVersion(versionRange.substring(comma + 1, versionRange.length() - 1).trim());

-			includeMax = last == ']';

-		} else {

-			minVersion = Version.parseVersion(versionRange.trim());

-			includeMin = true;

-			maxVersion = VersionRange.versionMax;

-			includeMax = true;

-		}

+	public boolean isRange() {

+		return high != low;

 	}

 

-	/**

-	 * Returns the minimum Version of this VersionRange

-	 * @return the minimum Version of this VersionRange

-	 */

-	public Version getMinimum() {

-		return minVersion;

+	public boolean includeLow() {

+		return start == '[';

 	}

 

-	/**

-	 * Indicates if the minimum version is included in the version range.

-	 * @return true if the minimum version is included in the version range;

-	 * otherwise false is returned

-	 */

-	public boolean getIncludeMinimum() {

-		return includeMin;

+	public boolean includeHigh() {

+		return end == ']';

 	}

 

-	/**

-	 * Returns the maximum Version of this VersionRange

-	 * @return the maximum Version of this VersionRange

-	 */

-	public Version getMaximum() {

-		return maxVersion;

+	public String toString() {

+		if (high == low)

+			return high.toString();

+

+		StringBuffer sb = new StringBuffer();

+		sb.append(start);

+		sb.append(low);

+		sb.append(',');

+		sb.append(high);

+		sb.append(end);

+		return sb.toString();

 	}

 

-	/**

-	 * Indicates if the maximum version is included in the version range.

-	 * @return true if the maximum version is included in the version range;

-	 * otherwise false is returned

-	 */

-	public boolean getIncludeMaximum() {

-		return includeMax;

-	}

-

-	/**

-	 * Returns whether the given version is included in this VersionRange.

-	 * This will depend on the minimum and maximum versions of this VersionRange

-	 * and the given version.

-	 * 

-	 * @param version a version to be tested for inclusion in this VersionRange. 

-	 * (may be <code>null</code>)

-	 * @return <code>true</code> if the version is include, 

-	 * <code>false</code> otherwise 

-	 */

-	public boolean isIncluded(Version version) {

-		Version minRequired = getMinimum();

-		if (minRequired == null)

-			return true;

-		if (version == null)

-			return false;

-		Version maxRequired = getMaximum() == null ? VersionRange.versionMax : getMaximum();

-		int minCheck = includeMin ? 0 : 1;

-		int maxCheck = includeMax ? 0 : -1;

-		return version.compareTo(minRequired) >= minCheck && version.compareTo(maxRequired) <= maxCheck;

-

-	}

-

-	public boolean equals(Object object) {

-		if (!(object instanceof VersionRange))

-			return false;

-		VersionRange vr = (VersionRange) object;

-		if (minVersion != null && vr.getMinimum() != null) {

-			if (minVersion.equals(vr.getMinimum()) && includeMin == vr.includeMin)

-				if (maxVersion != null && vr.getMaximum() != null) {

-					if (maxVersion.equals(vr.getMaximum()) && includeMax == vr.includeMax)

-						return true;

-				}

-				else

-					return maxVersion == vr.getMaximum();

-		}

-		else {

-			return minVersion == vr.getMinimum();

+	public boolean equals(Object other) {

+		if (other instanceof VersionRange) {

+			return compareTo(other)==0;

 		}

 		return false;

 	}

 

-	public String toString() {

-		if (minVersion == null)

-			return Version.emptyVersion.toString();

-		if (VersionRange.versionMax.equals(maxVersion))

-			return minVersion.toString();

-		StringBuffer result = new StringBuffer();

-		result.append(includeMin ? '[' : '(');

-		result.append(minVersion);

-		result.append(',');

-		result.append(maxVersion);

-		result.append(includeMax ? ']' : ')');

-		return result.toString();

+	public int hashCode() {

+		return low.hashCode() * high.hashCode();

 	}

-}

+

+	public int compareTo(Object other) {

+		VersionRange range = (VersionRange) other;

+		VersionRange a = this, b = range;

+		if (range.isRange()) {

+			a = range;

+			b = this;

+		} else {

+			if ( !isRange() )

+				return low.compareTo(range.high);

+		}

+		int l = a.low.compareTo(b.low);

+		boolean ll = false;

+		if (a.includeLow())

+			ll = l <= 0;

+		else

+			ll = l < 0;

+

+		if (!ll)

+			return -1;

+

+		int h = a.high.compareTo(b.high);

+		if (a.includeHigh())

+			ll = h >= 0;

+		else

+			ll = h > 0;

+

+		if (ll)

+			return 0;

+		else

+			return 1;

+	}

+}
\ No newline at end of file