incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickcha...@apache.org
Subject svn commit: rev 31018 - in incubator/depot/trunk/version/src/java/org/apache/depot/version: . impl
Date Sat, 31 Jul 2004 07:34:56 GMT
Author: nickchalko
Date: Sat Jul 31 00:34:55 2004
New Revision: 31018

Modified:
   incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionMarker.java
   incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java
Log:
Added getVersionSpec and getDefaultVersion.

Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionMarker.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionMarker.java	(original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionMarker.java	Sat
Jul 31 00:34:55 2004
@@ -23,6 +23,7 @@
 import org.apache.depot.version.impl.ApacheVersion;
 import org.apache.depot.version.impl.ApacheVersionMarker;
 import org.apache.depot.version.impl.VersionIdentifier;
+import org.apache.depot.version.specification.VersionSpecification;
 
 // :TODO: Based upon thoughts from Anou..
 //
@@ -84,6 +85,13 @@
 	 */
 	String getLongVersion();  // TODO:  Rename as asLongFormat
 
+	
+	/**
+	 * Default Version 1.2.7 (fred) built June 7,1981
+	 * @return String
+	 */
+	String getDefaultVersion();  // TODO:  Rename as asLongFormat
+	
 	/**
 	 * Get any associated attributes, or null if none.
 	 */
@@ -93,4 +101,11 @@
 	 * Get any associated annotations, or null if none.
 	 */
 	List getAnnotations();
+	
+	
+	/**
+	 * The specifiaction used for this version.
+	 * @return VersionSpecification
+	 */
+	VersionSpecification getSpecification();
 }

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
Sat Jul 31 00:34:55 2004
@@ -36,6 +36,7 @@
 import org.apache.depot.version.VersionException;
 import org.apache.depot.version.VersionMarker;
 import org.apache.depot.version.impl.data.ReleaseLevel;
+import org.apache.depot.version.specification.ApacheVersionSpecification;
 import org.apache.depot.version.specification.VersionSpecification;
 import org.apache.depot.version.specification.formatting.VersionFormat;
 import org.apache.depot.version.specification.formatting.VersionFormatException;
@@ -47,536 +48,587 @@
 /**
  * @author arb_jack@users.apache.org
  */
-public class ApacheVersionMarker implements VersionMarker, Dumpable, DOMProducer, DOMConsumer
{
+public class ApacheVersionMarker implements VersionMarker, Dumpable,
+		DOMProducer, DOMConsumer {
 
-    public final static String VERSION_MARKER_TAG = "versionMarker";
-    public final static String VERSION_ID_ATTRIBUTE = "versionId";
+	public final static String VERSION_MARKER_TAG = "versionMarker";
 
-    private static final Map l_parts = new HashMap();
-    static {
-        l_parts.put(ApacheVersion.VERSION_TAG, ApacheVersion.class);
-    }
-
-    private VersionIdentifier m_identifier;
-    private ApacheVersion m_version;
-    public final static VersionFormat FORMAT = new ApacheVersionFormat();
-
-    /** Extended Optional Settings... */
-    //:TODO: final on these two?
-    private Map m_attributes = null;
-    private List m_annotations = null;
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(ApacheVersionMarker other) {
-        super();
-
-        m_identifier = other.m_identifier;
-        m_version = other.m_version;
-
-        validate();
-    }
-
-    public ApacheVersionMarker(String identifier, ApacheVersion version) {
-        m_identifier = new VersionIdentifier(identifier);
-        m_version = version;
-        validate();
-    }
-
-    public ApacheVersionMarker(String identifier, CompoundVersion version) throws VersionException
{
-        m_identifier = new VersionIdentifier(identifier);
-        m_version = new ApacheVersion(version);
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String identifier) {
-        super();
-
-        m_identifier = new VersionIdentifier(identifier);
-        m_version = new ApacheVersion();
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(VersionIdentifier identifier, Date date) {
-        super();
-
-        m_identifier = identifier;
-        m_version = new ApacheVersion(date);
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String identifier, Date date) {
-        this(new VersionIdentifier(identifier), date);
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, String data) throws VersionException {
-        this(VersionImporter.importApacheVersionMarker(VersionIdentifier.importVersionIdentifier(id),
data));
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(VersionIdentifier id, String data) throws VersionException
{
-        this(VersionImporter.importApacheVersionMarker(id, data));
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(VersionIdentifier id, Version version) throws VersionException
{
-        m_identifier = id;
-        m_version = ApacheVersion.fromVersion(version);
-        validate();
-    }
-
-    /**
-     * Constructor for ApacheVersion.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(VersionIdentifier id, ApacheVersion version) {
-        m_identifier = id;
-        m_version = version;
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, VersionSpecification specification, String data)
throws VersionException {
-        this(VersionImporter.importApacheVersionMarker(
-                VersionIdentifier.importVersionIdentifier(id),
-                    specification,
-                    data));
-    }
-
-    public ApacheVersionMarker(String id, int major, int minor, ReleaseLevel releaseLevel,
int buildNumber) {
-        this(VersionIdentifier.importVersionIdentifier(id), new ApacheVersion(major, minor,
releaseLevel, buildNumber));
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, VersionSpecification specification, String data,
Map properties)
-            throws VersionFormatException, VersionException {
-        this(VersionImporter.importApacheVersionMarker(id, specification, data));
-        importProperties(properties);
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, Map properties) throws VersionFormatException,
VersionException {
-        this(id);
-        importProperties(properties);
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, VersionSpecification specification, String data,
Map attributes,
-            List annotations) throws VersionFormatException, VersionException {
-        this(new VersionIdentifier(id), specification, data, attributes, annotations);
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(VersionIdentifier id, VersionSpecification specification,
String data, Map attributes,
-            List annotations) throws VersionFormatException, VersionException {
-        this(VersionImporter.importApacheVersionMarker(id, specification, data));
-
-        importProperties(attributes);
-
-        m_attributes = attributes;
-        m_annotations = annotations;
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(VersionIdentifier id, Version version, Map attributes, List
annotations)
-            throws VersionFormatException, VersionException {
-        this(id, version);
-
-        // :TODO: Ensure importProperties does return the
-        // ununsed ones
-        m_attributes = importProperties(attributes);
-        m_annotations = annotations;
-        validate();
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, Version version, Map attributes, List annotations)
-            throws VersionFormatException, VersionException {
-        this(new VersionIdentifier(id), version);
-
-        importProperties(attributes);
-
-        m_attributes = attributes;
-        m_annotations = annotations;
-        validate();
-    }
-
-    /**
-     * @param string
-     * @param version
-     * @param attributes
-     * @param m_annotationList
-     * @param date
-     */
-    public ApacheVersionMarker(String id, Version version, HashMap attributes, List annotationList,
Date date)
-            throws VersionFormatException, VersionException {
-        this(id, version, attributes, annotationList);
-        m_version.setBuildDate(date);
-    }
-
-    /**
-     * Constructor for Version.
-     * 
-     * @param other
-     */
-    public ApacheVersionMarker(String id, String data, Map properties) throws VersionFormatException,
VersionException {
-        this(VersionImporter.importApacheVersionMarker(id, data));
-        importProperties(properties);
-        validate();
-    }
-
-    public Map importProperties(Map properties) throws VersionException {
-        return m_version.importProperties(properties);
-    }
-
-    public String getId() {
-        return m_identifier.toString();
-    }
-
-    /**
-     * Returns the identifier.
-     * 
-     * @return VersionIdentifier
-     */
-    public VersionIdentifier getIdentifier() {
-        return m_identifier;
-    }
-
-    public Version getVersion() {
-        return m_version;
-    }
-
-    public ApacheVersion getApacheVersion() {
-        return m_version;
-    }
-
-    // :TODO: Nick, let me complete 'MASK' in format first
-    // :TODO: Nick, this really a description?
-    // Please let me complete 'MASK' in format first
-    public String getLongVersion() {
-        return FORMAT.toVersionString(this.m_version.getData());
-    }
-
-    //  Please let me complete 'MASK' in format first
-    public String getShortVersion() {
-        return getVersion().toString();
-    }
-
-    public int hashCode() {
-        int hashCode = 0;
-
-        if (null != m_identifier) hashCode = m_identifier.hashCode();
-
-        if (null != m_version) hashCode += m_version.hashCode();
-
-        return hashCode;
-    }
-
-    public boolean equals(Object other) {
-        boolean equal = false;
-
-        if (other instanceof ApacheVersionMarker) {
-            ApacheVersionMarker otherVersionMarker = (ApacheVersionMarker) other;
-
-            equal = otherVersionMarker.m_identifier.equals(m_identifier);
-
-            if (equal) equal = otherVersionMarker.m_version.equals(m_version);
-        } else
-            throw new IllegalArgumentException("Not a ApacheVersionMarker: "
-                    + other.getClass()
-                    + " : "
-                    + other.toString());
-
-        return equal;
-    }
-
-    public int compareTo(Object other) {
-        int comparison = -1;
-
-        if (other instanceof ApacheVersionMarker) {
-            ApacheVersionMarker otherVersionMarker = (ApacheVersionMarker) other;
-
-            comparison = otherVersionMarker.m_identifier.compareTo(m_identifier);
-
-            if (0 == comparison) comparison = otherVersionMarker.m_version.compareTo(m_version);
-        } else
-            throw new IllegalArgumentException("Not a ApacheVersionMarker: "
-                    + other.getClass()
-                    + " : "
-                    + other.toString());
-
-        return comparison;
-    }
-
-    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 = DebugUtils.getIndent(depth);
-
-        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.
-     * 
-     * @return Map
-     */
-    public Map getAttributes() {
-        return m_attributes;
-    }
-
-    /**
-     * Sets the attributes.
-     * 
-     * @param attributes
-     *            The attributes to set
-     */
-    public void setAttributes(Map attributes) {
-        m_attributes = attributes;
-    }
-
-    public void setAttribute(String key, Object value) {
-        if (null == m_attributes) m_attributes = new HashMap();
-
-        m_attributes.put(key, value);
-    }
-
-    public Object getAttribute(String key) {
-        Object value = null;
-
-        if (null != m_attributes) value = m_attributes.get(key);
-
-        return value;
-    }
-
-    public String getAttributeAsString(String key) {
-        Object value = null;
-
-        if (null != m_attributes) value = m_attributes.get(key);
-
-        return ((null != value) ? value.toString() : null);
-    }
-
-    public void addAnnotation(Object note) {
-        if (null == m_annotations) m_annotations = new ArrayList();
-
-        m_annotations.add(note);
-    }
-
-    /**
-     * Returns the annotations.
-     * 
-     * @return List
-     */
-    public List getAnnotations() {
-        return m_annotations;
-    }
-
-    /**
-     * Sets the annotations.
-     * 
-     * @param annotations
-     *            The annotations to set
-     */
-    public void setAnnotations(List annotations) {
-        m_annotations = annotations;
-    }
-
-    private void validate() {
-        if (null == m_identifier){
-            throw new IllegalArgumentException("Invalid (null) identifier");
-        }
-        m_identifier.validate();
-
-        if (null == m_version) {
-            throw new IllegalArgumentException("Invalid (null) version");
-        }
-        m_version.validate();
-    }
-
-    public void produceDOM(Document document, Element element) {
-
-        // 
-        //  Import XML as 'smart'
-        //
-        Element v = document.createElement(VERSION_MARKER_TAG);
-        DOMUtils.appendChild(document, element, v);
-
-        Attr a = document.createAttribute(VERSION_ID_ATTRIBUTE);
-        a.setNodeValue(getId());
-        v.setAttributeNode(a);
-        DOMUtils.produceDOM(document, v, m_version);
-    }
-
-    /**
-     * The Date this version was Built.
-     * 
-     * @return the Date the version was Built
-     */
-    public Date getBuildDate() {
-        return (Date) m_attributes.get(VersionConstants.BUILD_DATETIME);
-    }
-
-    //
-    //	XML handling
-    //
-
-    public ApacheVersionMarker(Element element) throws DepotException {
-        //
-        // Any attributes we need?
-        //
-        if (element.getNodeName().equals(VERSION_MARKER_TAG)) {
-            DOMUtils.consumeDOMSubElements(this, l_parts, element);
-        }
-        // Identifier...
-        m_identifier = new VersionIdentifier(element.getAttribute(VERSION_ID_ATTRIBUTE));
-    }
-
-    public void consumeDOMElement(String tag, Element element) {
-    }
-    public void consumeDOMObject(String tag, Object object) {
-        if (object instanceof ApacheVersion) m_version = (ApacheVersion) object;
-    }
-
-    public static ApacheVersionMarker getTestVersionMarker(String identifier) {
-        return new TestApacheVersionMarker(identifier);
-    }
-
-    public static ApacheVersionMarker getTestVersionMarker(VersionIdentifier identifier)
{
-        return new TestApacheVersionMarker(identifier);
-    }
-
-    public static ApacheVersionMarker getTestVersionMarker(String identifier, int major,
int minor) {
-        return new TestApacheVersionMarker(identifier, major, minor);
-    }
-
-    public static ApacheVersionMarker getTestVersionMarker(VersionIdentifier identifier,
int major, int minor) {
-        return new TestApacheVersionMarker(identifier, major, minor);
-    }
+	public final static String VERSION_ID_ATTRIBUTE = "versionId";
+
+	private static final Map l_parts = new HashMap();
+	static {
+		l_parts.put(ApacheVersion.VERSION_TAG, ApacheVersion.class);
+	}
+
+	private VersionIdentifier m_identifier;
+
+	private ApacheVersion m_version;
+
+	public final static VersionFormat FORMAT = new ApacheVersionFormat();
+
+	/** Extended Optional Settings... */
+	//:TODO: final on these two?
+	private Map m_attributes = null;
+
+	private List m_annotations = null;
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(ApacheVersionMarker other) {
+		super();
+
+		m_identifier = other.m_identifier;
+		m_version = other.m_version;
+
+		validate();
+	}
+
+	public ApacheVersionMarker(String identifier, ApacheVersion version) {
+		m_identifier = new VersionIdentifier(identifier);
+		m_version = version;
+		validate();
+	}
+
+	public ApacheVersionMarker(String identifier, CompoundVersion version)
+			throws VersionException {
+		m_identifier = new VersionIdentifier(identifier);
+		m_version = new ApacheVersion(version);
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String identifier) {
+		super();
+
+		m_identifier = new VersionIdentifier(identifier);
+		m_version = new ApacheVersion();
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(VersionIdentifier identifier, Date date) {
+		super();
+
+		m_identifier = identifier;
+		m_version = new ApacheVersion(date);
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String identifier, Date date) {
+		this(new VersionIdentifier(identifier), date);
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, String data) throws VersionException {
+		this(VersionImporter.importApacheVersionMarker(VersionIdentifier
+				.importVersionIdentifier(id), data));
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(VersionIdentifier id, String data)
+			throws VersionException {
+		this(VersionImporter.importApacheVersionMarker(id, data));
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(VersionIdentifier id, Version version)
+			throws VersionException {
+		m_identifier = id;
+		m_version = ApacheVersion.fromVersion(version);
+		validate();
+	}
+
+	/**
+	 * Constructor for ApacheVersion.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(VersionIdentifier id, ApacheVersion version) {
+		m_identifier = id;
+		m_version = version;
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, VersionSpecification specification,
+			String data) throws VersionException {
+		this(VersionImporter.importApacheVersionMarker(VersionIdentifier
+				.importVersionIdentifier(id), specification, data));
+	}
+
+	public ApacheVersionMarker(String id, int major, int minor,
+			ReleaseLevel releaseLevel, int buildNumber) {
+		this(VersionIdentifier.importVersionIdentifier(id), new ApacheVersion(
+				major, minor, releaseLevel, buildNumber));
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, VersionSpecification specification,
+			String data, Map properties) throws VersionFormatException,
+			VersionException {
+		this(VersionImporter.importApacheVersionMarker(id, specification, data));
+		importProperties(properties);
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, Map properties)
+			throws VersionFormatException, VersionException {
+		this(id);
+		importProperties(properties);
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, VersionSpecification specification,
+			String data, Map attributes, List annotations)
+			throws VersionFormatException, VersionException {
+		this(new VersionIdentifier(id), specification, data, attributes,
+				annotations);
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(VersionIdentifier id,
+			VersionSpecification specification, String data, Map attributes,
+			List annotations) throws VersionFormatException, VersionException {
+		this(VersionImporter.importApacheVersionMarker(id, specification, data));
+
+		importProperties(attributes);
+
+		m_attributes = attributes;
+		m_annotations = annotations;
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(VersionIdentifier id, Version version,
+			Map attributes, List annotations) throws VersionFormatException,
+			VersionException {
+		this(id, version);
+
+		// :TODO: Ensure importProperties does return the
+		// ununsed ones
+		m_attributes = importProperties(attributes);
+		m_annotations = annotations;
+		validate();
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, Version version, Map attributes,
+			List annotations) throws VersionFormatException, VersionException {
+		this(new VersionIdentifier(id), version);
+
+		importProperties(attributes);
+
+		m_attributes = attributes;
+		m_annotations = annotations;
+		validate();
+	}
+
+	/**
+	 * @param string
+	 * @param version
+	 * @param attributes
+	 * @param m_annotationList
+	 * @param date
+	 */
+	public ApacheVersionMarker(String id, Version version, HashMap attributes,
+			List annotationList, Date date) throws VersionFormatException,
+			VersionException {
+		this(id, version, attributes, annotationList);
+		m_version.setBuildDate(date);
+	}
+
+	/**
+	 * Constructor for Version.
+	 * 
+	 * @param other
+	 */
+	public ApacheVersionMarker(String id, String data, Map properties)
+			throws VersionFormatException, VersionException {
+		this(VersionImporter.importApacheVersionMarker(id, data));
+		importProperties(properties);
+		validate();
+	}
+
+	public Map importProperties(Map properties) throws VersionException {
+		return m_version.importProperties(properties);
+	}
+
+	public String getId() {
+		return m_identifier.toString();
+	}
+
+	/**
+	 * Returns the identifier.
+	 * 
+	 * @return VersionIdentifier
+	 */
+	public VersionIdentifier getIdentifier() {
+		return m_identifier;
+	}
+
+	public Version getVersion() {
+		return m_version;
+	}
+
+	public ApacheVersion getApacheVersion() {
+		return m_version;
+	}
+
+	// :TODO: Nick, let me complete 'MASK' in format first
+	// :TODO: Nick, this really a description?
+	// 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);
+	}
+
+	public int hashCode() {
+		int hashCode = 0;
+
+		if (null != m_identifier)
+			hashCode = m_identifier.hashCode();
+
+		if (null != m_version)
+			hashCode += m_version.hashCode();
+
+		return hashCode;
+	}
+
+	public boolean equals(Object other) {
+		boolean equal = false;
+
+		if (other instanceof ApacheVersionMarker) {
+			ApacheVersionMarker otherVersionMarker = (ApacheVersionMarker) other;
+
+			equal = otherVersionMarker.m_identifier.equals(m_identifier);
+
+			if (equal)
+				equal = otherVersionMarker.m_version.equals(m_version);
+		} else
+			throw new IllegalArgumentException("Not a ApacheVersionMarker: "
+					+ other.getClass() + " : " + other.toString());
+
+		return equal;
+	}
+
+	public int compareTo(Object other) {
+		int comparison = -1;
+
+		if (other instanceof ApacheVersionMarker) {
+			ApacheVersionMarker otherVersionMarker = (ApacheVersionMarker) other;
+
+			comparison = otherVersionMarker.m_identifier
+					.compareTo(m_identifier);
+
+			if (0 == comparison)
+				comparison = otherVersionMarker.m_version.compareTo(m_version);
+		} else
+			throw new IllegalArgumentException("Not a ApacheVersionMarker: "
+					+ other.getClass() + " : " + other.toString());
+
+		return comparison;
+	}
+
+	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 = DebugUtils.getIndent(depth);
+
+		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.
+	 * 
+	 * @return Map
+	 */
+	public Map getAttributes() {
+		return m_attributes;
+	}
+
+	/**
+	 * Sets the attributes.
+	 * 
+	 * @param attributes
+	 *            The attributes to set
+	 */
+	public void setAttributes(Map attributes) {
+		m_attributes = attributes;
+	}
+
+	public void setAttribute(String key, Object value) {
+		if (null == m_attributes)
+			m_attributes = new HashMap();
+
+		m_attributes.put(key, value);
+	}
+
+	public Object getAttribute(String key) {
+		Object value = null;
+
+		if (null != m_attributes)
+			value = m_attributes.get(key);
+
+		return value;
+	}
+
+	public String getAttributeAsString(String key) {
+		Object value = null;
+
+		if (null != m_attributes)
+			value = m_attributes.get(key);
+
+		return ((null != value) ? value.toString() : null);
+	}
+
+	public void addAnnotation(Object note) {
+		if (null == m_annotations)
+			m_annotations = new ArrayList();
+
+		m_annotations.add(note);
+	}
+
+	/**
+	 * Returns the annotations.
+	 * 
+	 * @return List
+	 */
+	public List getAnnotations() {
+		return m_annotations;
+	}
+
+	/**
+	 * Sets the annotations.
+	 * 
+	 * @param annotations
+	 *            The annotations to set
+	 */
+	public void setAnnotations(List annotations) {
+		m_annotations = annotations;
+	}
+
+	private void validate() {
+		if (null == m_identifier) {
+			throw new IllegalArgumentException("Invalid (null) identifier");
+		}
+		m_identifier.validate();
+
+		if (null == m_version) {
+			throw new IllegalArgumentException("Invalid (null) version");
+		}
+		m_version.validate();
+	}
+
+	public void produceDOM(Document document, Element element) {
+
+		// 
+		//  Import XML as 'smart'
+		//
+		Element v = document.createElement(VERSION_MARKER_TAG);
+		DOMUtils.appendChild(document, element, v);
+
+		Attr a = document.createAttribute(VERSION_ID_ATTRIBUTE);
+		a.setNodeValue(getId());
+		v.setAttributeNode(a);
+		DOMUtils.produceDOM(document, v, m_version);
+	}
+
+	/**
+	 * The Date this version was Built.
+	 * 
+	 * @return the Date the version was Built
+	 */
+	public Date getBuildDate() {
+		return (Date) m_attributes.get(VersionConstants.BUILD_DATETIME);
+	}
+
+	//
+	//	XML handling
+	//
+
+	public ApacheVersionMarker(Element element) throws DepotException {
+		//
+		// Any attributes we need?
+		//
+		if (element.getNodeName().equals(VERSION_MARKER_TAG)) {
+			DOMUtils.consumeDOMSubElements(this, l_parts, element);
+		}
+		// Identifier...
+		m_identifier = new VersionIdentifier(element
+				.getAttribute(VERSION_ID_ATTRIBUTE));
+	}
+
+	public void consumeDOMElement(String tag, Element element) {
+	}
+
+	public void consumeDOMObject(String tag, Object object) {
+		if (object instanceof ApacheVersion)
+			m_version = (ApacheVersion) object;
+	}
+
+	public static ApacheVersionMarker getTestVersionMarker(String identifier) {
+		return new TestApacheVersionMarker(identifier);
+	}
+
+	public static ApacheVersionMarker getTestVersionMarker(
+			VersionIdentifier identifier) {
+		return new TestApacheVersionMarker(identifier);
+	}
+
+	public static ApacheVersionMarker getTestVersionMarker(String identifier,
+			int major, int minor) {
+		return new TestApacheVersionMarker(identifier, major, minor);
+	}
+
+	public static ApacheVersionMarker getTestVersionMarker(
+			VersionIdentifier identifier, int major, int minor) {
+		return new TestApacheVersionMarker(identifier, major, minor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.depot.version.VersionMarker#getDefaultVersion()
+	 */
+	public String getDefaultVersion() {
+		return FORMAT.format(m_version.getData(), VersionFormat.DEFUALT);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.depot.version.VersionMarker#getSpecification()
+	 */
+	public VersionSpecification getSpecification() {
+		return new ApacheVersionSpecification();
+	}
 }
 
 //
 // 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));
-    }
+	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));
+	}
 }

Mime
View raw message