krysalis-version/src/java/org/krysalis/version/impl/apache ApacheVersionMarker.java,1.1,1.2 ApacheVersionFormat.java,1.1,1.2 ApacheVersion.java,1.1,1.2 ApacheVersionSpecification.java,1.1,1.2
Nick Chalko <[email protected]> Tue, 09 Nov 2004 07:14:01 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-version/src/java/org/krysalis/version/impl/apache
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27011/src/java/org/krysalis/version/impl/apache
Modified Files:
ApacheVersionMarker.java ApacheVersionFormat.java
ApacheVersion.java ApacheVersionSpecification.java
Log Message:
Almost compiles!
Index: ApacheVersionMarker.java
===================================================================
RCS file: /cvsroot/krysalis/krysalis-version/src/java/org/krysalis/version/impl/apache/ApacheVersionMarker.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ApacheVersionMarker.java 9 Nov 2004 06:40:29 -0000 1.1
--- ApacheVersionMarker.java 9 Nov 2004 07:13:57 -0000 1.2
***************
*** 1,9 ****
package org.krysalis.version.impl.apache;
- import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
- import java.util.Iterator;
import java.util.List;
import java.util.Map;
--- 1,7 ----
***************
*** 15,20 ****
import org.krysalis.version.VersionIdentifier;
import org.krysalis.version.VersionSpecification;
- import org.w3c.dom.Attr;
- import org.w3c.dom.Document;
import org.w3c.dom.Element;
--- 13,16 ----
***************
*** 70,73 ****
--- 66,80 ----
}
+ /**
+ * @param id
+ * @param version
+ * @param properties
+ */
+ public ApacheVersionMarker(VersionIdentifier id, ApacheVersion version,
+ Map properties) {
+
+ // TODO Auto-generated constructor stub
+ }
+
public Map importProperties(Map properties) throws VersionException {
return m_version.importProperties(properties);
***************
*** 99,108 ****
// Please let me complete 'MASK' in format first
public String getLongVersion() {
! return FORMAT.format(m_version.getData(), VersionFormat.LONG);
}
// Please let me complete 'MASK' in format first
public String getShortVersion() {
! return FORMAT.format(m_version.getData(), VersionFormat.SHORT);
}
--- 106,115 ----
// Please let me complete 'MASK' in format first
public String getLongVersion() {
! return FORMAT.format(m_version, VersionFormat.LONG);
}
// Please let me complete 'MASK' in format first
public String getShortVersion() {
! return FORMAT.format(m_version, VersionFormat.SHORT);
}
***************
*** 156,210 ****
public String toString() {
! String v = FORMAT.toVersionString(m_version.getData());
return m_identifier + " version " + v;
}
- public void dump(PrintWriter out, int depth, boolean verbose) {
- final String indent = " ";
-
- if (verbose) {
-
- if (null != m_identifier)
- m_identifier.dump(out, depth + 1, verbose);
-
- if (null != m_version)
- m_version.dump(out, depth + 1, verbose);
-
- if (null != m_annotations) {
- for (Iterator ai = m_annotations.iterator(); ai.hasNext();) {
- Object note = ai.next();
- out.println(" - " + note.toString());
- }
- }
-
- if (null != m_attributes) {
- for (Iterator ai = m_attributes.keySet().iterator(); ai
- .hasNext();) {
- Object key = ai.next();
- Object value = m_attributes.get(key);
-
- out.println(" - " + key + " -> [" + value.toString() + "]");
- }
- }
- } else {
- out.print(indent);
- out.print(m_identifier.toString());
- out.print(" : ");
- out.println(m_version.toString());
-
- if (null != m_attributes) {
- out.print(indent);
- out.print("Attributes :");
- out.println(m_attributes);
- }
-
- if (null != m_annotations) {
- out.print(indent);
- out.print("Annotations :");
- out.println(m_annotations);
- }
- }
- }
-
/**
* Returns the attributes.
--- 163,170 ----
public String toString() {
! String v = FORMAT.format(m_version, VersionFormat.DEFUALT);
return m_identifier + " version " + v;
}
/**
* Returns the attributes.
***************
*** 289,294 ****
}
-
-
/**
* The Date this version was Built.
--- 249,252 ----
***************
*** 300,305 ****
}
-
-
public void consumeDOMElement(String tag, Element element) {
}
--- 258,261 ----
***************
*** 310,314 ****
}
!
! }
--- 266,288 ----
}
! /*
! * (non-Javadoc)
! *
! * @see org.krysalis.version.VersionMarker#getDefaultVersion()
! */
! public String getDefaultVersion() {
! // TODO Auto-generated method stub
! return null;
! }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.krysalis.version.VersionMarker#getSpecification()
+ */
+ public VersionSpecification getSpecification() {
+
+ return new ApacheVersionSpecification();
+ }
+
+ }
Index: ApacheVersionFormat.java
===================================================================
RCS file: /cvsroot/krysalis/krysalis-version/src/java/org/krysalis/version/impl/apache/ApacheVersionFormat.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ApacheVersionFormat.java 9 Nov 2004 06:40:29 -0000 1.1
--- ApacheVersionFormat.java 9 Nov 2004 07:13:58 -0000 1.2
***************
*** 17,32 ****
package org.krysalis.version.impl.apache;
import java.util.Date;
import java.util.StringTokenizer;
- import org.apache.depot.common.log.Logger;
- import org.apache.depot.version.Version;
- import org.apache.depot.version.impl.ApacheVersion;
- 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;
import org.apache.depot.version.impl.data.VersionDataElementSet;
! import org.apache.depot.version.specification.formatting.VersionFormat;
! import org.apache.depot.version.specification.formatting.VersionFormatException;
import org.krysalis.version.impl.VersionFormatImpl;
--- 17,35 ----
package org.krysalis.version.impl.apache;
import java.util.Date;
+ import java.util.Map;
import java.util.StringTokenizer;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
import org.apache.depot.version.impl.data.ReleaseLevel;
import org.apache.depot.version.impl.data.VersionData;
import org.apache.depot.version.impl.data.VersionDataElement;
import org.apache.depot.version.impl.data.VersionDataElementSet;
! import org.krysalis.version.Version;
! import org.krysalis.version.VersionException;
! import org.krysalis.version.VersionFormat;
! import org.krysalis.version.VersionFormatException;
! import org.krysalis.version.VersionIdentifier;
! import org.krysalis.version.VersionMarker;
import org.krysalis.version.impl.VersionFormatImpl;
***************
*** 35,38 ****
--- 38,42 ----
*/
public class ApacheVersionFormat extends VersionFormatImpl {
+ private final static Logger LOG = Logger.global;
//:TODO: Make it sensetive to elements...
private VersionDataElementSet m_elements = null;
***************
*** 69,73 ****
int elementMask = 0;
! Logger.getLogger().debug(
"Parse Apache Version String: [" + versionString + "]");
--- 73,77 ----
int elementMask = 0;
! LOG.log(Level.FINE,
"Parse Apache Version String: [" + versionString + "]");
***************
*** 108,112 ****
overflow = overflow + tokens.nextToken();
! Logger.getLogger().debug(
"Major/Minor/Extra : [" + major + "/" + minor + "/" + overflow
+ "]");
--- 112,116 ----
overflow = overflow + tokens.nextToken();
! LOG.log(Level.FINE,
"Major/Minor/Extra : [" + major + "/" + minor + "/" + overflow
+ "]");
***************
*** 151,155 ****
remainder = tokens2.nextToken();
! Logger.getLogger().debug(
"Point/Extra : [" + point + "/" + remainder + "]");
--- 155,159 ----
remainder = tokens2.nextToken();
! LOG.log(Level.FINE,
"Point/Extra : [" + point + "/" + remainder + "]");
***************
*** 183,187 ****
}
! Logger.getLogger().debug(
"RelaseLevel/Qualifier : [" + releaseLevel + "/"
+ releaseQualifier + "]");
--- 187,191 ----
}
! LOG.log(Level.FINE,
"RelaseLevel/Qualifier : [" + releaseLevel + "/"
+ releaseQualifier + "]");
***************
*** 205,209 ****
}
} catch (VersionFormatException vfe) {
! Logger.getLogger().debug("Previous", vfe);
elementMask |= VersionDataElement.ELEMENT_BUILD_NUMBER;
buildNumber = parseInt(versionString,
--- 209,213 ----
}
} catch (VersionFormatException vfe) {
! LOG.log(Level.FINE,"Previous", vfe);
elementMask |= VersionDataElement.ELEMENT_BUILD_NUMBER;
buildNumber = parseInt(versionString,
***************
*** 313,319 ****
* @see org.apache.depot.version.specification.formatting.VersionFormat#parseVersion(java.lang.String)
*/
! public Version parseVersion(String version) throws VersionFormatException {
! return new ApacheVersion(parseVersionData(version));
}
}
\ No newline at end of file
--- 317,344 ----
* @see org.apache.depot.version.specification.formatting.VersionFormat#parseVersion(java.lang.String)
*/
! public ApacheVersion parseVersion(String version) throws VersionFormatException {
! try {
! ApacheVersionFormat avf=new ApacheVersionFormat();
! return new ApacheVersion(avf.parseVersionData(version));
! } catch (VersionException e) {
! throw new VersionFormatException(ApacheVersion.APACHE_VERSION_SPEC.getVersionFormat(),e);
! }
! }
!
! /* (non-Javadoc)
! * @see org.krysalis.version.VersionFormat#createVersionMarker(org.krysalis.version.VersionIdentifier, org.krysalis.version.Version, java.util.Map)
! */
! public VersionMarker createVersionMarker(VersionIdentifier id, Version version, Map properties) {
! // TODO Auto-generated method stub
! return null;
! }
!
! /* (non-Javadoc)
! * @see org.krysalis.version.VersionFormat#format(org.krysalis.version.Version, java.lang.String)
! */
! public String format(Version m_version, String format) {
! // TODO Auto-generated method stub
! return null;
}
}
\ No newline at end of file
Index: ApacheVersion.java
===================================================================
RCS file: /cvsroot/krysalis/krysalis-version/src/java/org/krysalis/version/impl/apache/ApacheVersion.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ApacheVersion.java 9 Nov 2004 06:40:29 -0000 1.1
--- ApacheVersion.java 9 Nov 2004 07:13:58 -0000 1.2
***************
*** 17,21 ****
package org.krysalis.version.impl.apache;
- import java.io.PrintWriter;
import java.util.Comparator;
import java.util.Date;
--- 17,20 ----
***************
*** 26,38 ****
import org.apache.depot.version.impl.data.VersionData;
import org.apache.depot.version.impl.data.VersionDataElement;
! import org.apache.depot.version.impl.data.VersionDataElementSet;
import org.krysalis.version.Version;
import org.krysalis.version.VersionException;
! import org.krysalis.version.VersionFormatException;
import org.krysalis.version.VersionSpecification;
! import org.krysalis.version.VersionSpecificationFactory;
! import org.krysalis.version.util.DebugUtils;
! import org.w3c.dom.Document;
! import org.w3c.dom.Element;
/**
--- 25,34 ----
import org.apache.depot.version.impl.data.VersionData;
import org.apache.depot.version.impl.data.VersionDataElement;
! import org.apache.depot.version.impl.data.VersionDataIncrementor;
import org.krysalis.version.Version;
import org.krysalis.version.VersionException;
! import org.krysalis.version.VersionFormat;
import org.krysalis.version.VersionSpecification;
! import org.krysalis.version.impl.CompoundVersion;
/**
***************
*** 43,47 ****
* @author [email protected]
*/
! public class ApacheVersion implements Version, CompoundVersion{
public final static String VERSION_TAG = "version";
--- 39,44 ----
* @author [email protected]
*/
! public class ApacheVersion implements Version, CompoundVersion {
! private final static Logger LOG = Logger.global;
public final static String VERSION_TAG = "version";
***************
*** 51,55 ****
/** The specification for this type of format */
! private final VersionSpecification m_specification;
/** The data associated */
--- 48,54 ----
/** The specification for this type of format */
! public final static ApacheVersionSpecification APACHE_VERSION_SPEC = new ApacheVersionSpecification();
!
! public final static ApacheVersionFormat APACHE_VERSION_FORMAT = new ApacheVersionFormat();
/** The data associated */
***************
*** 60,70 ****
// If a known type, just clone it
! if (version instanceof ApacheVersion)
return (ApacheVersion) version;
! else if (version instanceof CompoundVersion) {
! return new ApacheVersion((CompoundVersion) version);
}
! throw new IllegalArgumentException("Don't know how to handle "+version.getClass());
}
--- 59,69 ----
// If a known type, just clone it
! if (version instanceof ApacheVersion) {
return (ApacheVersion) version;
!
}
! throw new IllegalArgumentException("Don't know how to handle "
! + version.getClass());
}
***************
*** 76,81 ****
super();
- m_specification = VersionSpecificationFactory
- .createDefaultVersionSpecification();
m_data = new VersionData();
}
--- 75,78 ----
***************
*** 88,173 ****
public ApacheVersion(ApacheVersion other) {
super();
-
- m_specification = other.m_specification;
m_data = new VersionData(other.m_data);
}
- /*
- * Construct from a CompoundVersion
- *
- * @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());
- }
-
- /*
- * 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);
- }
-
- /*
- * 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,
- VersionDataElement.DEFAULT_BUILD_NUMBER,
- VersionDataElement.DEFAULT_BUILD_DATE);
- }
-
- /*
- * 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,
- VersionDataElement.DEFAULT_BUILD_DATE);
- }
-
- /**
- * Constructor for Version.
- *
- * @param other
- */
- public ApacheVersion(Date date) {
- super();
-
- m_specification = new DatetimestampedVersionSpecification();
- m_data = new VersionData(date);
- }
-
- /**
- * Constructor for Version.
- *
- * @param other
- */
- public ApacheVersion(VersionData data) {
- super();
-
- m_specification = VersionSpecificationFactory
- .createDefaultVersionSpecification();
- m_data = data;
- }
-
/**
* Constructor for Version.
--- 85,91 ----
***************
*** 176,229 ****
*/
public ApacheVersion(String data) throws VersionException {
! this(VersionImporter.importApacheVersion(data));
! }
!
! /**
! * Constructor for Version.
! *
! * @param other
! */
! public ApacheVersion(VersionSpecification specification, String data)
! throws VersionException {
! this(VersionImporter.importApacheVersion(specification, data));
}
/**
! * 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
! */
! public ApacheVersion(String data, Map properties)
! 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) {
! m_specification = specification;
! m_data = data;
}
public String getVersion() {
! return m_specification.getVersionFormat().toVersionString(m_data);
}
--- 94,121 ----
*/
public ApacheVersion(String data) throws VersionException {
! this(APACHE_VERSION_FORMAT.parseVersion(data));
}
/**
! * @param m_specification2
! * @param nextVersionData
*/
! public ApacheVersion(VersionSpecification m_specification2,
! VersionData nextVersionData) {
! // TODO Auto-generated constructor stub
}
/**
* @param data
*/
! public ApacheVersion(VersionData data) {
!
! // TODO Auto-generated constructor stub
}
public String getVersion() {
! return APACHE_VERSION_SPEC.getVersionFormat().format(this,
! VersionFormat.DEFUALT);
}
***************
*** 231,236 ****
int hashCode = 0;
! if (null != m_specification)
! hashCode += m_specification.hashCode();
if (null != m_data)
hashCode = m_data.hashCode();
--- 123,128 ----
int hashCode = 0;
! if (null != APACHE_VERSION_SPEC)
! hashCode += APACHE_VERSION_SPEC.hashCode();
if (null != m_data)
hashCode = m_data.hashCode();
***************
*** 341,367 ****
} else {
! Logger.getLogger().debug(
! "Release Levels ["
! + getReleaseLevelObject()
! + ","
! + otherApacheVersion
! .getReleaseLevelObject() + "]"
! + " for " + this + ","
! + otherApacheVersion
! + " are *NOT* Compatible");
}
} else
! Logger.getLogger().debug(
! "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: "
--- 233,252 ----
} else {
! LOG.fine("Release Levels [" + getReleaseLevelObject()
! + ","
! + otherApacheVersion.getReleaseLevelObject()
! + "]" + " for " + this + ","
! + otherApacheVersion + " are *NOT* Compatible");
}
} else
! LOG.fine("Minor Version Numbers [" + getMinor() + ","
! + otherApacheVersion.getMinor() + "]" + " for "
! + this + " and " + otherApacheVersion
! + " are *NOT* Compatible");
} else
! LOG.fine("Major Version Numbers [" + getMajor() + ","
! + otherApacheVersion.getMajor() + "]" + " for " + this
! + " and " + otherApacheVersion
! + " are *NOT* Compatible");
} else
throw new IllegalArgumentException("Not a ApacheVersion: "
***************
*** 386,390 ****
*/
public VersionSpecification getSpecification() {
! return m_specification;
}
--- 271,275 ----
*/
public VersionSpecification getSpecification() {
! return APACHE_VERSION_SPEC;
}
***************
*** 541,545 ****
VersionData nextVersionData = incrementor.increment(m_data);
// Construct the new immutable version
! return new ApacheVersion(m_specification, nextVersionData);
}
--- 426,430 ----
VersionData nextVersionData = incrementor.increment(m_data);
// Construct the new immutable version
! return new ApacheVersion(APACHE_VERSION_SPEC, nextVersionData);
}
***************
*** 550,578 ****
public String toString() {
// TODO handle this in a parent class.
! return m_specification.getVersionFormat().toVersionString(
! getVersionData());
! }
!
! public void dump(PrintWriter out, int depth, boolean verbose) {
! final String indent = DebugUtils.getIndent(depth);
!
! if ((null != m_specification) && verbose) {
! out.print(indent);
! out.println("Specification:");
! m_specification.dump(out, depth + 1, verbose);
! }
!
! if (null != m_data) {
! if (verbose) {
! out.print(indent);
! out.println("Data:");
! }
!
! m_data.dump(out, (verbose ? depth + 1 : depth), verbose);
! }
}
void validate() {
! if (null == m_specification)
throw new IllegalArgumentException(
"Illegal (null) VersionSpecification on ApacheVersion.");
--- 435,443 ----
public String toString() {
// TODO handle this in a parent class.
! return APACHE_VERSION_FORMAT.format(this, VersionFormat.DEFUALT);
}
void validate() {
! if (null == APACHE_VERSION_SPEC)
throw new IllegalArgumentException(
"Illegal (null) VersionSpecification on ApacheVersion.");
***************
*** 581,611 ****
"Illegal (null) VersionData on ApacheVersion.");
}
-
- public void produceDOM(Document document, Element element) {
-
- //
- // Import XML as 'smart'
- //
- //Element v = DOMUtils.insertElement(document, element, VERSION_TAG);
-
- DOMUtils.produceDOM(document, element, m_data);
- }
-
- //
- // XML handling
- //
-
- public ApacheVersion(Element element) throws VersionException {
- // :TODO: Spec as attribute?
- m_specification = VersionSpecificationFactory
- .createDefaultVersionSpecification();
- m_data = new VersionData(element);
- }
-
- public void consumeDOMElement(String tag, Element element) {
- }
-
- public void consumeDOMObject(String tag, Object object) {
- }
}
-
--- 446,448 ----
Index: ApacheVersionSpecification.java
===================================================================
RCS file: /cvsroot/krysalis/krysalis-version/src/java/org/krysalis/version/impl/apache/ApacheVersionSpecification.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ApacheVersionSpecification.java 9 Nov 2004 06:40:29 -0000 1.1
--- ApacheVersionSpecification.java 9 Nov 2004 07:13:58 -0000 1.2
***************
*** 19,22 ****
--- 19,23 ----
+ import org.apache.depot.version.impl.data.VersionDataElementSet;
import org.krysalis.version.impl.VersionSpecificationImpl;
***************
*** 29,32 ****
--- 30,35 ----
public class ApacheVersionSpecification extends VersionSpecificationImpl {
+ public static final ApacheVersionFormat APACHE_VERSION_FORMAT = new ApacheVersionFormat();
+
/**
* @see org.apache.depot.version.specification.VersionSpecification#getId()
***************
*** 66,70 ****
String versionString, Map properties) throws org.krysalis.version.VersionException {
! return new ApacheVersionMarker(id.getKey(), versionString,properties);
}
--- 69,73 ----
String versionString, Map properties) throws org.krysalis.version.VersionException {
! return new ApacheVersionMarker(id, new ApacheVersion(versionString),properties);
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click