diff --git a/core/src/main/java/org/verapdf/SemanticVersionNumber.java b/core/src/main/java/org/verapdf/version/SemanticVersionNumber.java
similarity index 96%
rename from core/src/main/java/org/verapdf/SemanticVersionNumber.java
rename to core/src/main/java/org/verapdf/version/SemanticVersionNumber.java
index 6f8c3e4d4..358bc1377 100644
--- a/core/src/main/java/org/verapdf/SemanticVersionNumber.java
+++ b/core/src/main/java/org/verapdf/version/SemanticVersionNumber.java
@@ -1,7 +1,7 @@
/**
*
*/
-package org.verapdf;
+package org.verapdf.version;
/**
* Simple interface for a semantic version
diff --git a/core/src/main/java/org/verapdf/VersionNumberImpl.java b/core/src/main/java/org/verapdf/version/VersionNumberImpl.java
similarity index 99%
rename from core/src/main/java/org/verapdf/VersionNumberImpl.java
rename to core/src/main/java/org/verapdf/version/VersionNumberImpl.java
index 2c95595bd..47f8f7f9a 100644
--- a/core/src/main/java/org/verapdf/VersionNumberImpl.java
+++ b/core/src/main/java/org/verapdf/version/VersionNumberImpl.java
@@ -1,7 +1,7 @@
/**
*
*/
-package org.verapdf;
+package org.verapdf.version;
/**
* @author Carl Wilson
diff --git a/core/src/main/java/org/verapdf/version/Versions.java b/core/src/main/java/org/verapdf/version/Versions.java
new file mode 100644
index 000000000..3605d6a87
--- /dev/null
+++ b/core/src/main/java/org/verapdf/version/Versions.java
@@ -0,0 +1,54 @@
+/**
+ *
+ */
+package org.verapdf.version;
+
+/**
+ * @author Carl Wilson
+ * carlwilson AT github
+ *
+ * @version 0.1
+ *
+ * Created 26 May 2017:01:48:14
+ */
+
+public final class Versions {
+ public static final String PDFBOX_BUILD_INFO = "PDFBOX"; //$NON-NLS-1$
+ private static final String pdfBoxBuildInfo = "-" + PDFBOX_BUILD_INFO; //$NON-NLS-1$
+ private static final String snapshotBuildInfo = "-SNAPSHOT"; //$NON-NLS-1$
+ private static final String versionPrefix = "v"; //$NON-NLS-1$
+
+ /**
+ *
+ */
+ private Versions() {
+ throw new AssertionError("Should never be here"); //$NON-NLS-1$
+ }
+
+ public static SemanticVersionNumber fromString(final String versionString) {
+ if (versionString == null)
+ throw new IllegalArgumentException("Argument versionString can not be null"); //$NON-NLS-1$
+ if (versionString.isEmpty())
+ throw new IllegalArgumentException("Argument versionString can not be empty"); //$NON-NLS-1$
+ String strippedVersion = (versionString.endsWith(pdfBoxBuildInfo)) ? versionString.replace(pdfBoxBuildInfo, "") //$NON-NLS-1$
+ : versionString;
+ strippedVersion = (strippedVersion.endsWith(snapshotBuildInfo)) ? strippedVersion.replace(snapshotBuildInfo, "") //$NON-NLS-1$
+ : strippedVersion;
+ strippedVersion = strippedVersion.startsWith(versionPrefix) ? strippedVersion.replaceFirst(versionPrefix, "") //$NON-NLS-1$
+ : strippedVersion;
+ return VersionNumberImpl.fromString(strippedVersion);
+ }
+
+ public static SemanticVersionNumber fromStrings(final String[] parts) {
+ return VersionNumberImpl.fromStrings(parts);
+ }
+
+ public static SemanticVersionNumber fromInts(final int[] parts) {
+ return VersionNumberImpl.fromInts(parts);
+ }
+
+ public static SemanticVersionNumber fromInts(final int major, final int minor, final int revision) {
+ return VersionNumberImpl.fromInts(major, minor, revision);
+ }
+
+}
diff --git a/core/src/test/java/org/verapdf/SemanticVersionTest.java b/core/src/test/java/org/verapdf/version/SemanticVersionTest.java
similarity index 78%
rename from core/src/test/java/org/verapdf/SemanticVersionTest.java
rename to core/src/test/java/org/verapdf/version/SemanticVersionTest.java
index 2170f7d5a..a4240d35e 100644
--- a/core/src/test/java/org/verapdf/SemanticVersionTest.java
+++ b/core/src/test/java/org/verapdf/version/SemanticVersionTest.java
@@ -1,7 +1,7 @@
/**
*
*/
-package org.verapdf;
+package org.verapdf.version;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -20,6 +20,7 @@
* Created 25 May 2017:22:31:17
*/
+//Move Versions to org.verapdf.version
@SuppressWarnings("static-method")
public class SemanticVersionTest {
private static final String v1_0_0 = "1.0.0"; //$NON-NLS-1$
@@ -30,7 +31,7 @@ public class SemanticVersionTest {
private static final String v1_0_0pdf = "1.0.0-PDFBOX"; //$NON-NLS-1$
private static final String v1_0_0snap = "1.0.0-SNAPSHOT"; //$NON-NLS-1$
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#hashCode()}.
+ * Test method for {@link VersionNumberImpl#hashCode()}.
*/
@Test
public final void testHashCodeAndEquals() {
@@ -38,7 +39,7 @@ public final void testHashCodeAndEquals() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromString(java.lang.String)}.
+ * Test method for {@link VersionNumberImpl#fromString(java.lang.String)}.
*/
@Test
public final void testVersionNumberFromString() {
@@ -48,7 +49,7 @@ public final void testVersionNumberFromString() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromString(java.lang.String)}.
+ * Test method for {@link VersionNumberImpl#fromString(java.lang.String)}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberFromNullString() {
@@ -57,7 +58,7 @@ public final void testVersionNumberFromNullString() {
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromString(java.lang.String)}.
+ * Test method for {@link VersionNumberImpl#fromString(java.lang.String)}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberFromEmptyString() {
@@ -65,7 +66,7 @@ public final void testVersionNumberFromEmptyString() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromStrings(java.lang.String[])}.
+ * Test method for {@link VersionNumberImpl#fromStrings(java.lang.String[])}.
*/
@Test
public final void testVersionNumberImplStringArray() {
@@ -75,7 +76,7 @@ public final void testVersionNumberImplStringArray() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromStrings(java.lang.String[])}.
+ * Test method for {@link VersionNumberImpl#fromStrings(java.lang.String[])}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplStringArrayNull() {
@@ -83,7 +84,7 @@ public final void testVersionNumberImplStringArrayNull() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromStrings(java.lang.String[])}.
+ * Test method for {@link VersionNumberImpl#fromStrings(java.lang.String[])}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplStringArrayBad() {
@@ -92,7 +93,7 @@ public final void testVersionNumberImplStringArrayBad() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromInts(int[])}.
+ * Test method for {@link VersionNumberImpl#fromInts(int[])}.
*/
@Test
public final void testVersionNumberImplIntArray() {
@@ -102,7 +103,7 @@ public final void testVersionNumberImplIntArray() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromInts(int[])}.
+ * Test method for {@link VersionNumberImpl#fromInts(int[])}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplIntArrayNull() {
@@ -110,7 +111,7 @@ public final void testVersionNumberImplIntArrayNull() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromInts(int[])}.
+ * Test method for {@link VersionNumberImpl#fromInts(int[])}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplIntArrayShort() {
@@ -118,7 +119,7 @@ public final void testVersionNumberImplIntArrayShort() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#fromInts(int[])}.
+ * Test method for {@link VersionNumberImpl#fromInts(int[])}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplIntArrayLong() {
@@ -126,7 +127,7 @@ public final void testVersionNumberImplIntArrayLong() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#VersionNumberImpl(int, int, int)}.
+ * Test method for {@link VersionNumberImpl#VersionNumberImpl(int, int, int)}.
*/
@Test
public final void testVersionNumberImplIntIntInt() {
@@ -136,7 +137,7 @@ public final void testVersionNumberImplIntIntInt() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#VersionNumberImpl(int, int, int)}.
+ * Test method for {@link VersionNumberImpl#VersionNumberImpl(int, int, int)}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplIntIntIntMinusMajor() {
@@ -144,7 +145,7 @@ public final void testVersionNumberImplIntIntIntMinusMajor() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#VersionNumberImpl(int, int, int)}.
+ * Test method for {@link VersionNumberImpl#VersionNumberImpl(int, int, int)}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplIntIntIntMinusMinor() {
@@ -152,7 +153,7 @@ public final void testVersionNumberImplIntIntIntMinusMinor() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#VersionNumberImpl(int, int, int)}.
+ * Test method for {@link VersionNumberImpl#VersionNumberImpl(int, int, int)}.
*/
@Test(expected=IllegalArgumentException.class)
public final void testVersionNumberImplIntIntIntMinusRev() {
@@ -160,7 +161,7 @@ public final void testVersionNumberImplIntIntIntMinusRev() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#getVersionString()}.
+ * Test method for {@link VersionNumberImpl#getVersionString()}.
*/
@Test
public final void testGetVersionString() {
@@ -173,7 +174,7 @@ public final void testGetVersionString() {
}
/**
- * Test method for {@link org.verapdf.VersionNumberImpl#compareTo(org.verapdf.VersionNumberImpl)}.
+ * Test method for {@link VersionNumberImpl#compareTo(VersionNumberImpl)}.
*/
@Test
public final void testCompareTo() {