]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/BasicNameVersion.java
Help working
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / BasicNameVersion.java
index 9cefc940522b115ec849adff038d537ff4940ce9..73f12fc4a51b6e32fa2bdc3e430e522882158932 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ * Copyright (C) 2007-2012 Argeo GmbH
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.argeo.slc;
 
 import java.io.Serializable;
 
-
 public class BasicNameVersion implements NameVersion, Comparable<NameVersion>,
                Serializable {
        private static final long serialVersionUID = -5127304279136195127L;
@@ -28,6 +26,18 @@ public class BasicNameVersion implements NameVersion, Comparable<NameVersion>,
        public BasicNameVersion() {
        }
 
+       /** Interprets string in OSGi-like format my.module.name;version=0.0.0 */
+       public BasicNameVersion(String nameVersion) {
+               int index = nameVersion.indexOf(";version=");
+               if (index < 0) {
+                       name = nameVersion;
+                       version = null;
+               } else {
+                       name = nameVersion.substring(0, index);
+                       version = nameVersion.substring(index + ";version=".length());
+               }
+       }
+
        public BasicNameVersion(String name, String version) {
                this.name = name;
                this.version = version;
@@ -80,5 +90,4 @@ public class BasicNameVersion implements NameVersion, Comparable<NameVersion>,
                else
                        return name.compareTo(o.getName());
        }
-
 }