incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 36366 - in incubator/depot/trunk/version/src: java/org/apache/depot/version/impl java/org/apache/depot/version/specification java/org/apache/depot/version/specification/experimental java/org/apache/depot/version/specification/formatting/format test/java/org/apache/depot/version/impl
Date Fri, 13 Aug 2004 19:47:22 GMT
Author: ajack
Date: Fri Aug 13 12:47:21 2004
New Revision: 36366

Removed:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/experimental/MavenVersionSpecification.java
Modified:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImplementationConstants.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImporter.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/VersionSpecificationFactory.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/ApacheVersionFormat.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java
   incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ApacheVersionSpecTest.java
   incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionImporterTests.java
Log:
Some importer fixes...

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImplementationConstants.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImplementationConstants.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImplementationConstants.java
Fri Aug 13 12:47:21 2004
@@ -47,7 +47,6 @@
     public static final String APACHE_VERSION_ID = VERSION_PACKAGE;
     public static final String DATETIMESTAMPED_VERSION_ID = "org.apache.datetimestamped";
     public static final String ECLIPSE_VERSION_ID = "org.eclipse";
-    public static final String MAVEN_VERSION_ID = "org.apache.maven";
     public static final String JAVASOFT_VERSION_ID = "java";
     public static final String JAKARTA_COMMONS_VERSION_ID =
         "org.apache.jakarta.commons";

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImporter.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImporter.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/VersionImporter.java
Fri Aug 13 12:47:21 2004
@@ -25,7 +25,6 @@
 import org.apache.depot.version.VersionException;
 import org.apache.depot.version.VersionMarker;
 import org.apache.depot.version.impl.data.VersionData;
-import org.apache.depot.version.specification.DatetimestampedVersionSpecification;
 import org.apache.depot.version.specification.VersionSpecification;
 import org.apache.depot.version.specification.VersionSpecificationFactory;
 import org.apache.depot.version.specification.formatting.VersionFormat;
@@ -140,7 +139,7 @@
 
 		VersionException lastVersionException = null;
 
-		Logger.getLogger().debug("Import ApacheVersion: [" + data + "]");
+		//Logger.getLogger().debug("Import ApacheVersion: [" + data + "]");
 
 		//
 		// Clean off trailing stuff...
@@ -151,32 +150,12 @@
 			cleanData = tokens.nextToken();
 
 		//
-		//  Favour our Datetimestamped specification
-		//
-		VersionSpecification datetimeSpecification =
-			new DatetimestampedVersionSpecification();
-
-		try {
-			VersionFormat format = datetimeSpecification.getVersionFormat();
-
-			Logger.getLogger().debug("Import DateTime? : [" + cleanData + "]");
-			
-			VersionData versionData = format.parseVersion(cleanData);
-
-			version = new ApacheVersion(datetimeSpecification, versionData);
-		}
-		catch (VersionFormatException vfe) {
-			Logger.getLogger().debug("Datetimestamped: ", vfe);
-			lastVersionException = vfe;
-		}
-
-		//
 		//  Try all other specifications...
 		//
 		if (null == version)
 			for (Iterator i =
 				VersionSpecificationFactory.getRegisteredSpecificationIds();
-				i.hasNext();
+				i.hasNext() && (null == version);
 				) {
 				String specId = (String) i.next();
 
@@ -197,7 +176,7 @@
 					version = new ApacheVersion(spec, versionData);
 				}
 				catch (VersionFormatException vfe) {
-					Logger.getLogger().debug("Spec: " + spec + " Format:" + format, vfe);
+					// Logger.getLogger().debug("Spec: " + spec + " Format:" + format, vfe);
 					lastVersionException = vfe;
 				}
 			}

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/VersionSpecificationFactory.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/VersionSpecificationFactory.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/VersionSpecificationFactory.java
Fri Aug 13 12:47:21 2004
@@ -25,7 +25,6 @@
 import org.apache.depot.version.VersionException;
 import org.apache.depot.version.impl.VersionImplementationConstants;
 import org.apache.depot.version.specification.experimental.JakartaCommonsVersionSpecification;
-import org.apache.depot.version.specification.experimental.MavenVersionSpecification;
 
 /**
  * @author ajack
@@ -57,9 +56,6 @@
 		registerVersionSpecification(
 				VersionImplementationConstants.JAKARTA_COMMONS_VERSION_ID,
 				JakartaCommonsVersionSpecification.class);
-		registerVersionSpecification(
-				VersionImplementationConstants.MAVEN_VERSION_ID,
-				MavenVersionSpecification.class);
 	}
 
 	/** Default */

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/ApacheVersionFormat.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/ApacheVersionFormat.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/ApacheVersionFormat.java
Fri Aug 13 12:47:21 2004
@@ -66,8 +66,8 @@
 		throws VersionFormatException {
 		int elementMask = 0;
 
-		//VersionLogger.g_log.debug(
-		//	"Parse Apache Version String: [" + versionString + "]");
+		Logger.getLogger().debug(
+			"Parse Apache Version String: [" + versionString + "]");
 
 		StringTokenizer tokens = new StringTokenizer(versionString, ". ");
 
@@ -105,16 +105,19 @@
 			// :TODO: Do we allow no minor? Throw Exception?
 		}
 
+		// Attach anything left after major/minor onto extra tokens
+		if (tokens.hasMoreTokens())
+			overflow = overflow + tokens.nextToken();
+
+		Logger.getLogger().debug(
+			"Major/Minor/Extra : [" + major + "/" + minor + "/" + overflow + "]");
+		
 		int point = VersionDataElement.DEFAULT_BUILD_NUMBER;
 		ReleaseLevel releaseLevel = ReleaseLevel.RELEASE;
 		int releaseQualifier = VersionDataElement.DEFAULT_RELEASE_QUALIFIER;
 		int buildNumber = VersionDataElement.DEFAULT_BUILD_NUMBER;
 		Date buildDate = null;
-
-		// Attach anything left after major/minor onto extra tokens
-		if (tokens.hasMoreTokens())
-			overflow = overflow + tokens.nextToken();
-
+		
 		if (overflow.length() > 0) {
 			StringTokenizer tokens2 = new StringTokenizer(overflow, "- ");
 
@@ -152,18 +155,16 @@
 			if ((remainder.length() == 0) && tokens2.hasMoreTokens())
 				remainder = tokens2.nextToken();
 
+			Logger.getLogger().debug(
+				"Point/Extra : [" + point  + "/" + remainder + "]");
+			
 			if (remainder.length() > 0)
 				try {
-
-					//
 					// Extract Release Level (perhaps with Qualifier)
-					//
 					int digitPosn = findNextNumeric(remainder);
 
 					if (-1 == digitPosn) {
-						//
 						// Release Level w/o a numeric qualifier
-						//
 						elementMask |= VersionDataElement.ELEMENT_RELEASE_LEVEL;
 
 						releaseLevel =
@@ -173,17 +174,13 @@
 						String possibleRL = remainder.substring(0, digitPosn);
 						String possibleRQ = remainder.substring(digitPosn);
 
-						//
 						// Release Level
-						//
 						elementMask |= VersionDataElement.ELEMENT_RELEASE_LEVEL;
 
 						releaseLevel =
 							parseReleaseLevel(versionString, possibleRL);
 
-						//
 						// Release Qualifier
-						//    
 						elementMask
 							|= VersionDataElement.ELEMENT_RELEASE_QUALIFIER;
 
@@ -194,16 +191,31 @@
 								possibleRQ);
 					}
 
-
-// :TODO: BUILD_DATE
+					Logger.getLogger().debug(
+						"RelaseLevel/Qualifier : [" + releaseLevel  + "/" + releaseQualifier + "]");				
 
 					if (tokens2.hasMoreTokens()) {
+						
+						String data = tokens2.nextToken();
+						
+						try
+						{
+							Date value = parseDate(data);
+							
+
+							elementMask |= VersionDataElement.ELEMENT_BUILD_DATE;
+							buildDate = value;
+						}
+						catch (Exception e)
+						{
+						
 						elementMask |= VersionDataElement.ELEMENT_BUILD_NUMBER;
 						buildNumber =
 							parseInt(
 								versionString,
 								VersionDataElement.BUILD_NUMBER,
 								tokens2.nextToken());
+						}
 					}
 				}
 				catch (VersionFormatException vfe) {

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java
Fri Aug 13 12:47:21 2004
@@ -51,30 +51,7 @@
 	public VersionData parseVersion(String versionString)
 			throws VersionFormatException {
 
-		Date value = null;
-
-		int len = versionString.length();
-
-		if ((len != VersionImplementationConstants.DATE_FORMAT_LEN)
-				&& (len != VersionImplementationConstants.DATETIME_FORMAT_LEN)
-				&& (len != VersionImplementationConstants.DATETIME_LONG_FORMAT_LEN))
-			throw new VersionFormatException(this, "Not a Datetime format ["
-					+ versionString + "] in [" + versionString + "] for ["
-					+ VersionDataElement.ELEMENT_BUILD_DATE + "]");
-
-		try {
-			if (len == VersionImplementationConstants.DATE_FORMAT_LEN)
-				value = VersionImplementationConstants.DATE_FORMAT.parse(versionString);
-			else if (len == VersionImplementationConstants.DATETIME_FORMAT_LEN)
-				value = VersionImplementationConstants.DATETIME_FORMAT.parse(versionString);
-			else if (len == VersionImplementationConstants.DATETIME_LONG_FORMAT_LEN)
-				value = VersionImplementationConstants.DATETIME_LONG_FORMAT.parse(versionString);
-
-		} catch (ParseException pe) {
-			throw new VersionFormatException(this, "Bad Datetime Value ["
-					+ versionString + "] in [" + versionString + "] for ["
-					+ VersionDataElement.ELEMENT_BUILD_DATE + "]", pe);
-		}
+		Date value = parseDate(versionString);
 
 		return new VersionData(value);
 	}

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java
(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java
Fri Aug 13 12:47:21 2004
@@ -17,10 +17,13 @@
 package org.apache.depot.version.specification.formatting.format;
 
 import java.io.PrintWriter;
+import java.text.ParseException;
+import java.util.Date;
 
 import org.apache.depot.common.util.SystemUtils;
 import org.apache.depot.common.util.debug.DebugUtils;
 import org.apache.depot.version.VersionException;
+import org.apache.depot.version.impl.VersionImplementationConstants;
 import org.apache.depot.version.impl.data.ReleaseLevel;
 import org.apache.depot.version.impl.data.VersionData;
 import org.apache.depot.version.impl.data.VersionDataElement;
@@ -43,70 +46,84 @@
 	}
 
 	public int parseInt(String input, VersionDataElement element, String data)
-		throws VersionFormatException {
-		int value = - 1;
+			throws VersionFormatException {
+		int value = -1;
 
 		try {
 			value = Integer.parseInt(data, 10);
-		}
-		catch (NumberFormatException nfe) {
-			throw new VersionFormatException(
-				this,
-				"Bad Version Value ["
-					+ data
-					+ "] in ["
-					+ input
-					+ "] for ["
-					+ element
-					+ "]",
-				nfe);
+		} catch (NumberFormatException nfe) {
+			throw new VersionFormatException(this, "Bad Version Value [" + data
+					+ "] in [" + input + "] for [" + element + "]", nfe);
 		}
 
 		return value;
 	}
 
 	public ReleaseLevel parseReleaseLevel(String input, String data)
-		throws VersionFormatException {
+			throws VersionFormatException {
 		ReleaseLevel releaseLevel = ReleaseLevel.UNSET;
 
 		try {
 
 			releaseLevel = ReleaseLevel.getFromString(data);
-		}
-		catch (VersionException ve) {
-			throw new VersionFormatException(
-				this,
-				"Bad Release Level Value ["
-					+ data
-					+ "] in ["
-					+ input
-					+ "] for ["
-					+ VersionDataElement.RELEASE_LEVEL
-					+ "]",
-				ve);
+		} catch (VersionException ve) {
+			throw new VersionFormatException(this, "Bad Release Level Value ["
+					+ data + "] in [" + input + "] for ["
+					+ VersionDataElement.RELEASE_LEVEL + "]", ve);
 		}
 
 		return releaseLevel;
 	}
-	
+
+	public Date parseDate(String data) throws VersionFormatException {
+		Date value = null;
+
+		int len = data.length();
+
+		if ((len != VersionImplementationConstants.DATE_FORMAT_LEN)
+				&& (len != VersionImplementationConstants.DATETIME_FORMAT_LEN)
+				&& (len != VersionImplementationConstants.DATETIME_LONG_FORMAT_LEN))
+			throw new VersionFormatException(this, "Not a Datetime format ["
+					+ data + "] in [" + data + "] for ["
+					+ VersionDataElement.ELEMENT_BUILD_DATE + "]");
+
+		try {
+			if (len == VersionImplementationConstants.DATE_FORMAT_LEN)
+				value = VersionImplementationConstants.DATE_FORMAT.parse(data);
+			else if (len == VersionImplementationConstants.DATETIME_FORMAT_LEN)
+				value = VersionImplementationConstants.DATETIME_FORMAT.parse(data);
+			else if (len == VersionImplementationConstants.DATETIME_LONG_FORMAT_LEN)
+				value = VersionImplementationConstants.DATETIME_LONG_FORMAT.parse(data);
+
+		} catch (ParseException pe) {
+			throw new VersionFormatException(this, "Bad Datetime Value ["
+					+ data + "] in [" + data + "] for ["
+					+ VersionDataElement.ELEMENT_BUILD_DATE + "]", pe);
+		}
+
+		return value;
+	}
+
 	/**
 	 * Finds the first digit character
+	 * 
 	 * @param data
 	 * @return The position of the digit, or -1
 	 */
 	public int findNextNumeric(String data) {
-		return findNextNumeric(data,0);
+		return findNextNumeric(data, 0);
 	}
 
 	/**
 	 * Finds the first digit character, after start
+	 * 
 	 * @param data
 	 * @return The position of the digit, or -1
 	 */
 	public int findNextNumeric(String data, int start) {
 		int digitPosn = -1;
 
-		for (int i = start;(i < data.length()) && (-1 == digitPosn); ++i) {
+		for (int i = start; (i < data.length()) && (-1 == digitPosn); ++i) {
 			char c = data.charAt(i);
 			if (Character.isDigit(c)) {
 				digitPosn = i;
@@ -114,10 +131,11 @@
 		}
 		return digitPosn;
 	}
-	
+
 	/**
-	 * Assumes that the start of data is a numeric, and finds first
-	 * non-numeric (e.g. a dash or a letter or something) after that.
+	 * Assumes that the start of data is a numeric, and finds first non-numeric
+	 * (e.g. a dash or a letter or something) after that.
+	 * 
 	 * @param data
 	 * @return The position of the non-numeric character, or -1
 	 */
@@ -126,14 +144,14 @@
 	}
 
 	/**
-	 * Assumes that @ start in data is a numeric, and finds first
-	 * non-numeric (e.g. a dash or a letter or something) after that.
+	 * Assumes that @ start in data is a numeric, and finds first non-numeric
+	 * (e.g. a dash or a letter or something) after that.
 	 * @param data
 	 * @return The position of the non-numeric character, or -1
 	 */
 	public int findEndOfNumericalArea(String data, int start) {
 		int nonNumericPos = -1;
-		for (int i = start;(i < data.length()) && (-1 == nonNumericPos); ++i) {
+		for (int i = start; (i < data.length()) && (-1 == nonNumericPos); ++i) {
 			char ch = data.charAt(i);
 
 			if (!Character.isDigit(ch))
@@ -162,12 +180,16 @@
 			//:TODO: More?
 		}
 	}
-	/* (non-Javadoc)
-	 * @see org.apache.version.specification.formatting.VersionFormat#format(org.apache.version.impl.data.VersionData,
java.lang.String)
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.version.specification.formatting.VersionFormat#format(org.apache.version.impl.data.VersionData,
+	 *      java.lang.String)
 	 */
 	public String format(VersionData data, String styleName) {
 
 		return toVersionString(data);
 	}
 
-}
+}
\ No newline at end of file

Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ApacheVersionSpecTest.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ApacheVersionSpecTest.java
(original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ApacheVersionSpecTest.java
Fri Aug 13 12:47:21 2004
@@ -16,7 +16,6 @@
 import org.apache.depot.version.specification.VersionSpecification;
 import org.apache.depot.version.specification.VersionSpecificationFactory;
 import org.apache.depot.version.specification.experimental.JakartaCommonsVersionSpecification;
-import org.apache.depot.version.specification.experimental.MavenVersionSpecification;
 
 /**
  * @author ajack
@@ -46,9 +45,6 @@
 		checkVersionSpecification(
 				VersionImplementationConstants.JAKARTA_COMMONS_VERSION_ID,
 				JakartaCommonsVersionSpecification.class);
-		checkVersionSpecification(
-				VersionImplementationConstants.MAVEN_VERSION_ID,
-				MavenVersionSpecification.class);
     }
     
     public void testSpecs2()  throws VersionException{

Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionImporterTests.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionImporterTests.java
(original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionImporterTests.java
Fri Aug 13 12:47:21 2004
@@ -18,6 +18,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.depot.common.log.Logger;
 import org.apache.depot.version.VersionException;
 import org.apache.depot.version.impl.data.ReleaseLevel;
 import org.apache.depot.version.specification.ApacheVersionSpecification;
@@ -29,6 +30,8 @@
 public class VersionImporterTests extends TestCase {
 	public VersionImporterTests(String arg0) {
 		super(arg0);
+		
+		Logger.testInit();
 	}
 
 	public static void main(String[] args) {

Mime
View raw message