You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/07/28 23:47:10 UTC
svn commit: rev 30885 - in incubator/depot/trunk/version/src: java/org/apache/depot/version/impl java/org/apache/depot/version/impl/data java/org/apache/depot/version/impl/util java/org/apache/depot/version/specification java/org/apache/depot/version/specification/formatting/format java/org/apache/depot/version/tool test/java/org/apache/depot/version/impl
Author: ajack
Date: Wed Jul 28 16:47:09 2004
New Revision: 30885
Added:
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/DatetimestampedVersionSpecification.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java
Removed:
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/DatestampedVersionSpecification.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatestampedVersionFormat.java
Modified:
incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java
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/impl/data/VersionData.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/VersionSpecificationFactory.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java
incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ImporterTests.java
incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/VersionImporterTests.java
Log:
Worked on datetime (not just date)
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java Wed Jul 28 16:47:09 2004
@@ -180,7 +180,7 @@
super();
m_specification =
- VersionSpecificationFactory.createDatestampedVersionSpecification();
+ VersionSpecificationFactory.createDatetimestampedVersionSpecification();
m_data = new VersionData(date);
}
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 Wed Jul 28 16:47:09 2004
@@ -45,15 +45,24 @@
"http://www.apache.org/version/";
public static final String APACHE_VERSION_ID = VERSION_PACKAGE;
- public static final String DATESTAMPED_VERSION_ID = "org.apache.datestamped";
+ 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";
-
-
- public final static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
+ public final static String DATE_FORMAT_STRING = "yyyyMMdd";
+ public final static String DATETIME_FORMAT_STRING = "yyyyMMddhhmm";
+ public final static String DATETIME_LONG_FORMAT_STRING = "yyyyMMddhhmmss";
+ public final static int DATE_FORMAT_LEN = DATE_FORMAT_STRING.length();
+ public final static int DATETIME_FORMAT_LEN = DATETIME_FORMAT_STRING.length();
+ public final static int DATETIME_LONG_FORMAT_LEN = DATETIME_LONG_FORMAT_STRING.length();
+
+ public final static DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_FORMAT_STRING);
+ public final static DateFormat DATETIME_FORMAT = new SimpleDateFormat(DATETIME_FORMAT_STRING);
+ public final static DateFormat DATETIME_LONG_FORMAT = new SimpleDateFormat(DATETIME_LONG_FORMAT_STRING);
+
+ public final static DateFormat DEFAULT_DATETIME_FORMAT = new SimpleDateFormat();
}
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 Wed Jul 28 16:47:09 2004
@@ -139,7 +139,7 @@
VersionException lastVersionException = null;
- Logger.getLogger().debug("Import: [" + data + "]");
+ Logger.getLogger().debug("Import ApacheVersion: [" + data + "]");
//
// Clean off trailing stuff...
@@ -150,45 +150,25 @@
cleanData = tokens.nextToken();
//
- // Favour our Datestamped specification
+ // Favour our Datetimestamped specification
//
- VersionSpecification datedSpecification =
- VersionSpecificationFactory.createDatestampedVersionSpecification();
+ VersionSpecification datetimeSpecification =
+ VersionSpecificationFactory.createDatetimestampedVersionSpecification();
try {
- VersionFormat format = datedSpecification.getVersionFormat();
+ VersionFormat format = datetimeSpecification.getVersionFormat();
+ Logger.getLogger().debug("Import DateTime? : [" + cleanData + "]");
+
VersionData versionData = format.parseVersion(cleanData);
- version = new ApacheVersion(datedSpecification, versionData);
+ version = new ApacheVersion(datetimeSpecification, versionData);
}
catch (VersionFormatException vfe) {
- Logger.getLogger().debug("Datestamped: ", vfe);
+ Logger.getLogger().debug("Datetimestamped: ", vfe);
lastVersionException = vfe;
}
- if (null == version) {
-
- //
- // Favour our specification
- //
- VersionSpecification apacheSpecification =
- VersionSpecificationFactory
- .createApacheVersionSpecification();
-
- try {
- VersionFormat format = apacheSpecification.getVersionFormat();
-
- VersionData versionData = format.parseVersion(cleanData);
-
- version =
- new ApacheVersion(apacheSpecification, versionData);
- }
- catch (VersionFormatException vfe) {
- Logger.getLogger().debug("Default: ", vfe);
- lastVersionException = vfe;
- }
- }
//
// Try all other specifications...
//
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java Wed Jul 28 16:47:09 2004
@@ -739,7 +739,7 @@
if (null != m_buildDate) {
out.print(indent);
- out.println("BuildDate:" + getBuildDateString());
+ out.println("BuildDate:" + getBuildDate());
}
}
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/util/DiffTool.java Wed Jul 28 16:47:09 2004
@@ -26,7 +26,7 @@
import org.apache.depot.version.specification.VersionSpecification;
/**
- * @author arb_jack@users.sourceforge.net
+ * @author ajack@apache.org
*/
public class DiffTool {
Added: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/DatetimestampedVersionSpecification.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/DatetimestampedVersionSpecification.java Wed Jul 28 16:47:09 2004
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.apache.depot.version.specification;
+
+import org.apache.depot.version.impl.VersionImplementationConstants;
+import org.apache.depot.version.impl.data.VersionDataElement;
+import org.apache.depot.version.specification.formatting.VersionFormat;
+import org.apache.depot.version.specification.formatting.format.DatetimestampedVersionFormat;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.2 $
+ *
+ */
+public class DatetimestampedVersionSpecification extends VersionSpecificationImpl {
+
+ /**
+ * @see org.apache.depot.version.specification.VersionSpecification#getId()
+ */
+ public String getId() {
+ return VersionImplementationConstants.VERSION_PACKAGE+".datetimestamped";
+ }
+
+ /**
+ * @see org.apache.depot.version.specification.VersionSpecification#getDescription()
+ */
+ public String getDescription() {
+ return "Datetimestamped Version Default Specification";
+ }
+
+ /**
+ * @see org.apache.depot.version.specification.VersionSpecification#getElementMask()
+ */
+ public int getElementMask() {
+ return VersionDataElement.ELEMENT_BUILD_DATE;
+ }
+
+ /**
+ * @see org.apache.depot.version.specification.VersionSpecification#getVersionFormat()
+ */
+ public VersionFormat getVersionFormat() {
+ return new DatetimestampedVersionFormat();
+ }
+}
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 Wed Jul 28 16:47:09 2004
@@ -36,8 +36,8 @@
l_registry = new HashMap();
registerVersionSpecification(
- VersionImplementationConstants.DATESTAMPED_VERSION_ID,
- DatestampedVersionSpecification.class);
+ VersionImplementationConstants.DATETIMESTAMPED_VERSION_ID,
+ DatetimestampedVersionSpecification.class);
registerVersionSpecification(
VersionImplementationConstants.APACHE_VERSION_ID,
ApacheVersionSpecification.class);
@@ -72,8 +72,8 @@
return new ApacheVersionSpecification();
}
- public static VersionSpecification createDatestampedVersionSpecification() {
- return new DatestampedVersionSpecification();
+ public static VersionSpecification createDatetimestampedVersionSpecification() {
+ return new DatetimestampedVersionSpecification();
}
public static VersionSpecification createJakartaCommonsVersionSpecification() {
Added: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/DatetimestampedVersionFormat.java Wed Jul 28 16:47:09 2004
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.apache.depot.version.specification.formatting.format;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import org.apache.depot.version.impl.VersionImplementationConstants;
+import org.apache.depot.version.impl.data.VersionData;
+import org.apache.depot.version.impl.data.VersionDataElement;
+import org.apache.depot.version.specification.formatting.VersionFormatException;
+
+/**
+ * @author ajack
+ */
+public class DatetimestampedVersionFormat extends VersionFormatImpl {
+
+ public DatetimestampedVersionFormat() {
+ }
+
+ public String getFormatId() {
+ return "org.apache.datetimestamped";
+ }
+
+ public String getVersionFormatVersion() {
+ return "1.1.1";
+ }
+
+ //public String getVersionFormatMask() {
+ // return "{BUILD_NUMBER}";
+ //}
+
+ public String getVersionFormatDescription() {
+ return "{DATETIMESTAMP} = YYYYMMDD[HHMM[SS]]";
+ }
+
+ 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);
+ }
+
+ return new VersionData(value);
+ }
+
+ public String toVersionString(VersionData data) {
+ StringBuffer output = new StringBuffer();
+
+ output.append(VersionImplementationConstants.DATETIME_FORMAT.format(data.getBuildDate()));
+
+ return output.toString();
+ }
+}
\ No newline at end of file
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java Wed Jul 28 16:47:09 2004
@@ -117,5 +117,4 @@
public void setOut(PrintWriter writer) {
m_out = writer;
}
-
}
Modified: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ImporterTests.java
==============================================================================
--- incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ImporterTests.java (original)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/ImporterTests.java Wed Jul 28 16:47:09 2004
@@ -48,7 +48,7 @@
dated,
new ApacheVersion(
VersionSpecificationFactory
- .createDatestampedVersionSpecification(),
+ .createDatetimestampedVersionSpecification(),
new VersionData(date)));
}
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 Wed Jul 28 16:47:09 2004
@@ -51,24 +51,26 @@
public void testTypical() throws VersionException {
ApacheVersion version = importVersion("1.2.3-alpha-20030302");
- assertTrue(
+ assertEquals(
"Release Qualifier Correct",
- ReleaseLevel.ALPHA.equals(version.getReleaseLevelObject()));
+ ReleaseLevel.ALPHA,
+ version.getReleaseLevelObject());
VersionSpecification spec = version.getSpecification();
assertEquals(
"Apache Specification Used",
- spec,VersionSpecificationFactory
+ spec,
+ VersionSpecificationFactory
.createApacheVersionSpecification());
}
public void testReleaseQualifier() throws VersionException {
ApacheVersion version = importVersion("1.2.3-alpha1-20030302");
- assertTrue(
+ assertEquals(
"Release Qualifier Correct",
- 1 == version.getReleaseQualifier());
+ 1,version.getReleaseQualifier());
VersionSpecification spec = version.getSpecification();