You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by ni...@apache.org on 2004/08/17 06:05:27 UTC
svn commit: rev 36492 - in incubator/depot/trunk/version/src: java/org/apache/depot/version/impl test/java/org/apache/depot/version/impl
Author: nickchalko
Date: Mon Aug 16 23:05:22 2004
New Revision: 36492
Added:
incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/TestApacheVersion.java
incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/TestApacheVersionMarker.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/ApacheVersionMarker.java
Log:
One class per file.
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 Mon Aug 16 23:05:22 2004
@@ -46,23 +46,23 @@
/**
* @author arb_jack@users.apache.org
*/
-public class ApacheVersion
- implements Version, CompoundVersion, Dumpable, DOMProducer, DOMConsumer {
+public class ApacheVersion implements Version, CompoundVersion, Dumpable,
+ DOMProducer, DOMConsumer {
public final static String VERSION_TAG = "version";
-
- public final static ApacheVersion UNKNOWN =
- new ApacheVersion(new ApacheVersionSpecification(),
- VersionData.UNSET);
-
+
+ public final static ApacheVersion UNKNOWN = new ApacheVersion(
+ new ApacheVersionSpecification(), VersionData.UNSET);
+
/** The specification for this type of format */
private final VersionSpecification m_specification;
+
/** The data associated */
private VersionData m_data;
public static ApacheVersion fromVersion(Version version)
- throws VersionException {
-
+ throws VersionException {
+
// If a known type, just clone it
if (version instanceof ApacheVersion)
return (ApacheVersion) version;
@@ -81,8 +81,8 @@
public ApacheVersion() {
super();
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
m_data = new VersionData();
}
@@ -104,54 +104,35 @@
* @see CompoundVersion
*/
public ApacheVersion(CompoundVersion version) throws VersionException {
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
- m_data =
- new VersionData(
- VersionDataElementSet.DEFAULT,
- version.getMajor(),
- version.getMinor(),
- ReleaseLevel.getFromString(version.getReleaseLevel()),
- version.getReleaseQualifier(),
- version.getPoint(),
- version.getBuildNumber(),
- version.getBuildDate());
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
+ m_data = new VersionData(VersionDataElementSet.DEFAULT, version
+ .getMajor(), version.getMinor(), ReleaseLevel
+ .getFromString(version.getReleaseLevel()), version
+ .getReleaseQualifier(), version.getPoint(), version
+ .getBuildNumber(), version.getBuildDate());
}
/*
* Construct a standard version
*/
- public ApacheVersion(int major,int minor,ReleaseLevel releaseLevel, int releaseQualifier,
- int point, int buildNumber, Date buildDate) {
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
- m_data =
- new VersionData(
- VersionDataElementSet.DEFAULT,
- major,
- minor,
- releaseLevel,
- releaseQualifier,
- point,
- buildNumber,
- buildDate);
+ public ApacheVersion(int major, int minor, ReleaseLevel releaseLevel,
+ int releaseQualifier, int point, int buildNumber, Date buildDate) {
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
+ m_data = new VersionData(VersionDataElementSet.DEFAULT, major, minor,
+ releaseLevel, releaseQualifier, point, buildNumber, buildDate);
}
/*
* Construct a standard version
*/
- public ApacheVersion(int major,int minor,ReleaseLevel releaseLevel, int releaseQualifier,
- int point) {
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
- m_data =
- new VersionData(
- VersionDataElementSet.DEFAULT,
- major,
- minor,
- releaseLevel,
- releaseQualifier,
- point,
+ public ApacheVersion(int major, int minor, ReleaseLevel releaseLevel,
+ int releaseQualifier, int point) {
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
+ m_data = new VersionData(VersionDataElementSet.DEFAULT, major, minor,
+ releaseLevel, releaseQualifier, point,
VersionDataElement.DEFAULT_BUILD_NUMBER,
VersionDataElement.DEFAULT_BUILD_DATE);
}
@@ -159,47 +140,44 @@
/*
* Construct a standard version
*/
- public ApacheVersion(int major,int minor,ReleaseLevel releaseLevel,int buildNumber) {
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
- m_data =
- new VersionData(
- VersionDataElementSet.DEFAULT,
- major,
- minor,
- releaseLevel,
- VersionDataElement.DEFAULT_RELEASE_QUALIFIER,
- VersionDataElement.DEFAULT_POINT,
- buildNumber,
+ public ApacheVersion(int major, int minor, ReleaseLevel releaseLevel,
+ int buildNumber) {
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
+ m_data = new VersionData(VersionDataElementSet.DEFAULT, major, minor,
+ releaseLevel, VersionDataElement.DEFAULT_RELEASE_QUALIFIER,
+ VersionDataElement.DEFAULT_POINT, buildNumber,
VersionDataElement.DEFAULT_BUILD_DATE);
}
/**
* Constructor for Version.
+ *
* @param other
*/
public ApacheVersion(Date date) {
super();
- m_specification =
- new DatetimestampedVersionSpecification();
+ m_specification = new DatetimestampedVersionSpecification();
m_data = new VersionData(date);
}
/**
* Constructor for Version.
+ *
* @param other
*/
public ApacheVersion(VersionData data) {
super();
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
m_data = data;
}
/**
* Constructor for Version.
+ *
* @param other
*/
public ApacheVersion(String data) throws VersionException {
@@ -208,50 +186,49 @@
/**
* Constructor for Version.
+ *
* @param other
*/
public ApacheVersion(VersionSpecification specification, String data)
- throws VersionException {
+ throws VersionException {
this(VersionImporter.importApacheVersion(specification, data));
}
/**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersion(
- VersionSpecification specification,
- String data,
- Map properties)
- throws VersionFormatException, VersionException {
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersion(VersionSpecification specification, String data,
+ Map properties) throws VersionFormatException, VersionException {
this(VersionImporter.importApacheVersion(specification, data));
m_data.importProperties(properties);
}
/**
- * Constructor for Version.
- * @param other
- */
+ * Constructor for Version.
+ *
+ * @param other
+ */
public ApacheVersion(String data, Map properties)
- throws VersionFormatException, VersionException {
+ throws VersionFormatException, VersionException {
this(VersionImporter.importApacheVersion(data));
m_data.importProperties(properties);
}
-
/**
* Constructor for Version.
+ *
* @param specification
* @param data
*/
- public ApacheVersion(
- final VersionSpecification specification,
- final VersionData data) {
+ public ApacheVersion(final VersionSpecification specification,
+ final VersionData data) {
m_specification = specification;
m_data = data;
}
-
+
public String getVersion() {
return m_specification.getVersionFormat().toVersionString(m_data);
}
@@ -276,13 +253,9 @@
equal = otherVersion.m_data.equals(m_data);
// :TODO: Specification?
- }
- else
- throw new IllegalArgumentException(
- "Not a ApacheVersion: "
- + other.getClass()
- + " : "
- + other.toString());
+ } else
+ throw new IllegalArgumentException("Not a ApacheVersion: "
+ + other.getClass() + " : " + other.toString());
return equal;
}
@@ -293,13 +266,9 @@
ApacheVersion otherVersion = (ApacheVersion) other;
comparison = otherVersion.m_data.compareTo(m_data);
- }
- else
- throw new IllegalArgumentException(
- "Not a ApacheVersion: "
- + other.getClass()
- + " : "
- + other.toString());
+ } else
+ throw new IllegalArgumentException("Not a ApacheVersion: "
+ + other.getClass() + " : " + other.toString());
return comparison;
}
@@ -307,7 +276,7 @@
public Map importProperties(Map properties) throws VersionException {
return m_data.importProperties(properties);
}
-
+
public VersionData getVersionData() {
return m_data;
}
@@ -317,30 +286,26 @@
}
/**
- * Compute if this version is compatible with other.
- *
- * "Compatible" means (in effect) that other version is a
- * "good replacement" for the this one.
- *
- * The aspects of a version that are utilized are:
- *
- * - Major Version
- * - Minor Version
- * - Release Level
- *
- * The more specified in this version, the more are considered.
- *
- * Say (for example) one wanted something compatible with 1.0
- * then 1.0.1 is such, but 1.1 is not. As for "1" to get "1.*".
- *
- * Release level is somewhat different, especially when none
- * is set. No release level = RELEASE (by default) and as such
- * 1.0 means 1.0-release, so only 1.0.* of level "release" would
- * be compatible.
- *
- * Note: "Compatibility" is not transitive.
- *
- */
+ * Compute if this version is compatible with other.
+ *
+ * "Compatible" means (in effect) that other version is a "good replacement"
+ * for the this one.
+ *
+ * The aspects of a version that are utilized are:
+ * - Major Version - Minor Version - Release Level
+ *
+ * The more specified in this version, the more are considered.
+ *
+ * Say (for example) one wanted something compatible with 1.0 then 1.0.1 is
+ * such, but 1.1 is not. As for "1" to get "1.*".
+ *
+ * Release level is somewhat different, especially when none is set. No
+ * release level = RELEASE (by default) and as such 1.0 means 1.0-release,
+ * so only 1.0.* of level "release" would be compatible.
+ *
+ * Note: "Compatibility" is not transitive.
+ *
+ */
public boolean isCompatible(Version other) {
boolean compatible = false;
@@ -354,89 +319,66 @@
ApacheVersion otherApacheVersion = (ApacheVersion) other;
//
- // *This* is unset, or major's equal
+ // *This* is unset, or major's equal
//
if ((VersionDataElement.UNSET_MAJOR == getMajor())
- || otherApacheVersion.getMajor() == getMajor()) {
+ || otherApacheVersion.getMajor() == getMajor()) {
//
- // *This* is unset, or minor's equal
+ // *This* is unset, or minor's equal
//
if ((VersionDataElement.UNSET_MINOR == getMinor())
- || otherApacheVersion.getMinor() == getMinor()) {
+ || otherApacheVersion.getMinor() == getMinor()) {
//
// *Other* Release Level Higher
//
- if ((otherApacheVersion
- .getReleaseLevelObject()
- .compareTo(getReleaseLevelObject())
- >= 0)) {
+ if ((otherApacheVersion.getReleaseLevelObject().compareTo(
+ getReleaseLevelObject()) >= 0)) {
compatible = true;
}
else if (
- //
+ //
// If we aren't expecting a release, don't be fussy...
//
- !ReleaseLevel
- .RELEASE
- .equals(getReleaseLevelObject())) {
+ !ReleaseLevel.RELEASE.equals(getReleaseLevelObject())) {
compatible = true;
- }
- else {
+ } else {
Logger.getLogger().debug(
- "Release Levels ["
- + getReleaseLevelObject()
- + ","
- + otherApacheVersion.getReleaseLevelObject()
- + "]"
- + " for "
- + this
- + ","
- + otherApacheVersion
- + " are *NOT* Compatible");
+ "Release Levels ["
+ + getReleaseLevelObject()
+ + ","
+ + otherApacheVersion
+ .getReleaseLevelObject() + "]"
+ + " for " + this + ","
+ + otherApacheVersion
+ + " are *NOT* Compatible");
}
- }
- else
+ } else
Logger.getLogger().debug(
- "Minor Version Numbers ["
- + getMinor()
- + ","
- + otherApacheVersion.getMinor()
- + "]"
- + " for "
- + this
- + " and "
- + otherApacheVersion
- + " are *NOT* Compatible");
- }
- else
+ "Minor Version Numbers [" + getMinor() + ","
+ + otherApacheVersion.getMinor() + "]"
+ + " for " + this + " and "
+ + otherApacheVersion
+ + " are *NOT* Compatible");
+ } else
Logger.getLogger().debug(
- "Major Version Numbers ["
- + getMajor()
- + ","
- + otherApacheVersion.getMajor()
- + "]"
- + " for "
- + this
- + " and "
- + otherApacheVersion
- + " are *NOT* Compatible");
- }
- else
- throw new IllegalArgumentException(
- "Not a ApacheVersion: "
- + other.getClass()
- + " : "
- + other.toString());
+ "Major Version Numbers [" + getMajor() + ","
+ + otherApacheVersion.getMajor() + "]" + " for "
+ + this + " and " + otherApacheVersion
+ + " are *NOT* Compatible");
+ } else
+ throw new IllegalArgumentException("Not a ApacheVersion: "
+ + other.getClass() + " : " + other.toString());
return compatible;
}
/**
* Returns the data.
+ *
* @return VersionData
*/
public VersionData getData() {
@@ -445,7 +387,8 @@
/**
* Returns the format.
- * @return VersionSpecification
+ *
+ * @return VersionSpecification
*/
public VersionSpecification getSpecification() {
return m_specification;
@@ -453,37 +396,41 @@
/**
* Returns the major.
+ *
* @return int
- */
+ */
public int getMajor() {
return m_data.getMajor();
}
/**
* Returns the major.
+ *
* @return int
- */
+ */
public void setMajor(int major) {
m_data.setMajor(major);
}
/**
* Returns the minor.
+ *
* @return int
- */
+ */
public int getMinor() {
return m_data.getMinor();
}
/**
* Returns the minor.
+ *
* @return int
- */
+ */
public void setMinor(int minor) {
m_data.setMinor(minor);
}
- /*
+ /*
* @return Point
*/
public int getPoint() {
@@ -506,6 +453,7 @@
/**
* Set the Build Number
+ *
* @param buildNumber
*/
public void setBuildNumber(int buildNumber) {
@@ -514,6 +462,7 @@
/**
* Get the Build Date
+ *
* @return
*/
public Date getBuildDate() {
@@ -522,6 +471,7 @@
/**
* Set the Build Date
+ *
* @param date
*/
public void setBuildDate(Date date) {
@@ -529,41 +479,46 @@
}
/**
- * Returns the releaseLevel.
- * @return ReleaseLevel
- */
+ * Returns the releaseLevel.
+ *
+ * @return ReleaseLevel
+ */
public String getReleaseLevel() {
return m_data.getReleaseLevelAsString();
}
/**
* Returns the releaseLevel.
+ *
* @return ReleaseLevel
- */
+ */
public void setReleaseLevel(String releaseLevel) throws VersionException {
m_data.setReleaseLevel(ReleaseLevel.getFromString(releaseLevel));
}
/**
* Returns the releaseLevel.
+ *
* @return ReleaseLevel
- */
+ */
public void setReleaseLevel(ReleaseLevel releaseLevel) {
m_data.setReleaseLevel(releaseLevel);
}
/**
* Returns the releaseLevel.
+ *
* @return ReleaseLevel
- */
+ */
public ReleaseLevel getReleaseLevelObject() {
return m_data.getReleaseLevel();
}
/**
* Returns the releaseQualifier.
+ *
* @return ReleaseQualifier
- */
+ */
public int getReleaseQualifier() {
return m_data.getReleaseQualifier();
}
@@ -573,22 +528,22 @@
}
/**
- * Accepts (in string form) any of the elements of version data
- * e.g. major or minor or point or release level or build number
- * and returns an incremented version.
- *
- * @see VersionDataElement
- * @see org.apache.depot.version.Version#increment(String)
- */
+ * Accepts (in string form) any of the elements of version data e.g. major
+ * or minor or point or release level or build number and returns an
+ * incremented version.
+ *
+ * @see VersionDataElement
+ * @see org.apache.depot.version.Version#increment(String)
+ */
public Version increment(String element) throws VersionException {
// Extract which element of the version data, e.g. "major"
- VersionDataElement dataElement =
- VersionDataElement.getFromString(element);
+ VersionDataElement dataElement = VersionDataElement
+ .getFromString(element);
// Construct a suitable incrementor
- VersionDataIncrementor incrementor =
- new VersionDataIncrementor(dataElement);
+ VersionDataIncrementor incrementor = new VersionDataIncrementor(
+ dataElement);
// Increment the version data element, bumping the
- // higher elements
+ // higher elements
VersionData nextVersionData = incrementor.increment(m_data);
// Construct the new immutable version
return new ApacheVersion(m_specification, nextVersionData);
@@ -600,7 +555,8 @@
public String toString() {
// TODO handle this in a parent class.
- return m_specification.getVersionFormat().toVersionString(getVersionData());
+ return m_specification.getVersionFormat().toVersionString(
+ getVersionData());
}
public void dump(PrintWriter out, int depth, boolean verbose) {
@@ -624,9 +580,11 @@
void validate() {
if (null == m_specification)
- throw new IllegalArgumentException("Illegal (null) VersionSpecification on ApacheVersion.");
+ throw new IllegalArgumentException(
+ "Illegal (null) VersionSpecification on ApacheVersion.");
if (null == m_data)
- throw new IllegalArgumentException("Illegal (null) VersionData on ApacheVersion.");
+ throw new IllegalArgumentException(
+ "Illegal (null) VersionData on ApacheVersion.");
}
public void produceDOM(Document document, Element element) {
@@ -638,20 +596,21 @@
DOMUtils.produceDOM(document, element, m_data);
}
+
//
// XML handling
//
- public ApacheVersion(Element element) throws VersionException{
+ public ApacheVersion(Element element) throws VersionException {
// :TODO: Spec as attribute?
- m_specification =
- VersionSpecificationFactory.createDefaultVersionSpecification();
+ m_specification = VersionSpecificationFactory
+ .createDefaultVersionSpecification();
m_data = new VersionData(element);
}
-
+
public void consumeDOMElement(String tag, Element element) {
}
-
+
public void consumeDOMObject(String tag, Object object) {
}
@@ -660,35 +619,12 @@
}
public static ApacheVersion getTestVersion(int major, int minor) {
- return new TestApacheVersion(major,minor);
- }
-
- public static ApacheVersion getTestVersion(int major, int minor, ReleaseLevel level, int point) {
- return new TestApacheVersion(major,minor,level,point);
- }
-}
-
-//
-// Testing Instances
-//
-/**
- *
- * @deprecated
- */
-class TestApacheVersion extends ApacheVersion {
- TestApacheVersion() {
- super(VersionData.getTestVersionData());
+ return new TestApacheVersion(major, minor);
}
- TestApacheVersion(int major,int minor) {
- super(VersionData.getTestVersionData(major,minor));
- }
-
- TestApacheVersion(int major, int minor, ReleaseLevel level, int point) {
- super(VersionData.getTestVersionData(major,minor,level,point));
- }
-
- TestApacheVersion(String format) throws VersionException {
- super(VersionImporter.importApacheVersion(format));
+ public static ApacheVersion getTestVersion(int major, int minor,
+ ReleaseLevel level, int point) {
+ return new TestApacheVersion(major, minor, level, point);
}
}
+
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java Mon Aug 16 23:05:22 2004
@@ -611,24 +611,3 @@
}
}
-//
-// Testing Instances
-//
-
-class TestApacheVersionMarker extends ApacheVersionMarker {
- TestApacheVersionMarker(String identifier) {
- super(identifier, ApacheVersion.getTestVersion());
- }
-
- TestApacheVersionMarker(String identifier, int major, int minor) {
- super(identifier, ApacheVersion.getTestVersion(major, minor));
- }
-
- TestApacheVersionMarker(VersionIdentifier identifier) {
- super(identifier, ApacheVersion.getTestVersion());
- }
-
- TestApacheVersionMarker(VersionIdentifier identifier, int major, int minor) {
- super(identifier, ApacheVersion.getTestVersion(major, minor));
- }
-}
\ No newline at end of file
Added: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/TestApacheVersion.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/TestApacheVersion.java Mon Aug 16 23:05:22 2004
@@ -0,0 +1,39 @@
+/*
+ * 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.impl;
+
+import org.apache.depot.version.VersionException;
+import org.apache.depot.version.impl.data.ReleaseLevel;
+import org.apache.depot.version.impl.data.VersionData;
+
+ class TestApacheVersion extends ApacheVersion {
+ TestApacheVersion() {
+ super(VersionData.getTestVersionData());
+ }
+
+ TestApacheVersion(int major,int minor) {
+ super(VersionData.getTestVersionData(major,minor));
+ }
+
+ TestApacheVersion(int major, int minor, ReleaseLevel level, int point) {
+ super(VersionData.getTestVersionData(major,minor,level,point));
+ }
+
+ TestApacheVersion(String format) throws VersionException {
+ super(VersionImporter.importApacheVersion(format));
+ }
+}
Added: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/TestApacheVersionMarker.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/impl/TestApacheVersionMarker.java Mon Aug 16 23:05:22 2004
@@ -0,0 +1,35 @@
+/*
+ * 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.impl;
+
+
+class TestApacheVersionMarker extends ApacheVersionMarker {
+ TestApacheVersionMarker(String identifier) {
+ super(identifier, ApacheVersion.getTestVersion());
+ }
+
+ TestApacheVersionMarker(String identifier, int major, int minor) {
+ super(identifier, ApacheVersion.getTestVersion(major, minor));
+ }
+
+ TestApacheVersionMarker(VersionIdentifier identifier) {
+ super(identifier, ApacheVersion.getTestVersion());
+ }
+
+ TestApacheVersionMarker(VersionIdentifier identifier, int major, int minor) {
+ super(identifier, ApacheVersion.getTestVersion(major, minor));
+ }
+}
\ No newline at end of file