krysalis-version/src/java/org/krysalis/version/impl VersionIdentifier.java,NONE,1.1 VersionIdentifierHelper.java,NONE,1.1 VersionImplementationConstants.java,NONE,1.1 VersionImporter.java,1.1,1.2 KrysalisVersion.java,1.29,1.30

[email protected] Sun, 23 Mar 2003 17:26:18 -0800
Newsgroups gmane.comp.krysalis.sandbox
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/impl
In directory sc8-pr-cvs1:/tmp/cvs-serv27679/src/java/org/krysalis/version/impl

Modified Files:
	VersionImporter.java KrysalisVersion.java 
Added Files:
	VersionIdentifier.java VersionIdentifierHelper.java 
	VersionImplementationConstants.java 
Log Message:
Cleaned up package naming

--- NEW FILE: VersionIdentifier.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
	  "This product includes software developed for project 
	   Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
	prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl;

import java.io.PrintWriter;

import org.krysalis.version.resolve.VersionMetadata;
import org.krysalis.version.util.debug.DebugUtils;
import org.krysalis.version.util.debug.Dumpable;

/**
 * @author ajack
 */
public class VersionIdentifier implements Comparable, Dumpable {
    /** Package Versions */
    public static final String PACKAGE_URI =
        "http://krysalis.org/version/package";
        
    /** Bogus Versions (for internal manipulations) */
        public static final String BOGUS_URI =
            "http://krysalis.org/version/bogus";
        
    
    public static final String JDK_URI = "http://krysalis.org/version/jdk";
    
    public static final VersionIdentifier BOGUS = new VersionIdentifier(BOGUS_URI,"bogus");
    
    private String m_key = null;
    private String m_typeURI = PACKAGE_URI;

    public VersionIdentifier(String key) {
        m_key = key;
        m_typeURI = PACKAGE_URI;
    }

    public VersionIdentifier(String typeURI, String key) {
        m_key = key;
        m_typeURI = typeURI;
    }

    /**
     * Returns the key.
     * @return String
     */
    public String getKey() {
        return m_key;
    }

    /**
     * Returns the typeURI.
     * @return String
     */
    public String getTypeURI() {
        return m_typeURI;
    }

    /**
     * Sets the key.
     * @param key The key to set
     */
    public void setKey(String key) {
        m_key = key;
    }

    /**
     * Sets the typeURI.
     * @param typeURI The typeURI to set
     */
    public void setTypeURI(String typeURI) {
        m_typeURI = typeURI;
    }

    public String toString() {
        // :TODO: Lazy, make more efficient...
        if (PACKAGE_URI.equals(m_typeURI))
            return m_key;

        return m_typeURI + ":" + m_key;
    }

    /**
     * @see Object#equals(Object)
     */
    public boolean equals(Object other) {
        boolean equal = false;

        if (other instanceof VersionIdentifier) {
            VersionIdentifier otherVersionId = (VersionIdentifier) other;

            equal = (otherVersionId.m_key.equals(m_key));

            equal &= otherVersionId.m_typeURI.equalsIgnoreCase(m_typeURI);
        }

        return equal;
    }

    /**
     * @see Object#hashCode()
     */
    public int hashCode() {
        return m_typeURI.hashCode() + m_key.hashCode();
    }

    /**
     * @see Object#equals(Object)
     */
    public int compareTo(Object other) {
        int comparison = -1;

        if (null == other) {
            comparison = -1;
        }
        else if (other instanceof VersionMetadata) {
            VersionMetadata otherVersionMetadata = (VersionMetadata) other;

            comparison = (otherVersionMetadata.getIdentifier().compareTo(this));
        }
        else if (other instanceof VersionIdentifier) {
            VersionIdentifier otherVersionId = (VersionIdentifier) other;

            comparison = (otherVersionId.m_typeURI.compareTo(m_typeURI));

            if (0 == comparison)
                comparison = (otherVersionId.m_key.compareTo(m_key));

        }
        else
            throw new IllegalArgumentException(
                "Not a VersionIdentifier: "
                    + other.getClass()
                    + " : "
                    + other.toString());

        return comparison;
    }

    public void dump(PrintWriter out, int depth) {
        final String indent = DebugUtils.getIndent(depth);

        if (null != m_typeURI) {
            out.print(indent);
            out.println("Type URI: " + m_typeURI);
        }
        
        if (null != m_key) {
            out.print(indent);
            out.println("Identifier Key: " + m_key);
        }

    }
}

--- NEW FILE: VersionIdentifierHelper.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2002-2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
      "This product includes software developed for project 
       Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
    prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl;

import java.util.Iterator;

import org.krysalis.version.pathutils.ClassFormatPartsList;

/**
 * @author ajack
 */
public class VersionIdentifierHelper {
    public static VersionIdentifier extractVersionIdentifier(String id) {
        return new VersionIdentifier(id);
    }

    public static VersionIdentifier extractVersionIdentifier(Object obj) {
        return extractVersionIdentifier(obj.getClass());
    }

//:TODO: Ensure we don't have KrysalisVersion by accident...
    public static VersionIdentifier extractVersionIdentifier(Class clazz) {
        String key = clazz.getName();

        for (Iterator i = ClassFormatPartsList.PARTS.iterator();
            i.hasNext();
            ) {
            String part = (String) i.next();

            int posn = key.lastIndexOf(part);

            if (posn == (key.length() - part.length()))
                key = key.substring(0, posn);
        }

        return new VersionIdentifier(key);
    }

}

--- NEW FILE: VersionImplementationConstants.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2002-2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
    "This product includes software developed for project 
	   Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
	prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl;

/**
 * @author ajack
 */
public class VersionImplementationConstants {

    public static final String VERSION_FORMAT_FIELD = "VERSION_FORMAT";
    public static final String VERSION_VERSION_FIELD = "VERSION_VERSION";
    public static final String VERSION_FIELD = "VERSION";

    //	The version of the Krysalis Version Format
    public static final String VERSION_FORMAT_VERSION = "1.0.0-alpha";

    public static final String VERSION_PACKAGE = "org.krysalis.version";

    //	The Krysalis Format
    public static final String KRYSALIS_VERSION_FORMAT = VERSION_PACKAGE;

    //	The Default Version Format
    public static final String VERSION_FORMAT = KRYSALIS_VERSION_FORMAT;

    // The location for finding Krysilis Version
    public static final String VERSION_URL =
        "http://metamorphosis.krysalis.org/cgi-bin/mmorphosiswiki.pl?Version";

    public static final String KRYSALIS_VERSION_ID = VERSION_PACKAGE;
    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";

}

Index: VersionImporter.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/impl/VersionImporter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** VersionImporter.java	10 Mar 2003 20:44:10 -0000	1.1
--- VersionImporter.java	24 Mar 2003 01:25:46 -0000	1.2
***************
*** 62,67 ****
  import org.krysalis.version.formatting.VersionFormat;
  import org.krysalis.version.formatting.exception.VersionFormatException;
! import org.krysalis.version.internal.VersionIdentifier;
! import org.krysalis.version.internal.data.VersionData;
  import org.krysalis.version.specification.VersionSpecification;
  import org.krysalis.version.specification.VersionSpecificationFactory;
--- 62,66 ----
  import org.krysalis.version.formatting.VersionFormat;
  import org.krysalis.version.formatting.exception.VersionFormatException;
! import org.krysalis.version.impl.data.VersionData;
  import org.krysalis.version.specification.VersionSpecification;
  import org.krysalis.version.specification.VersionSpecificationFactory;

Index: KrysalisVersion.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/impl/KrysalisVersion.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** KrysalisVersion.java	21 Mar 2003 22:04:07 -0000	1.29
--- KrysalisVersion.java	24 Mar 2003 01:25:46 -0000	1.30
***************
*** 63,73 ****
  import org.krysalis.version.exception.VersionException;
  import org.krysalis.version.formatting.exception.VersionFormatException;
! import org.krysalis.version.internal.VersionIdentifier;
! import org.krysalis.version.internal.VersionIdentifierHelper;
! import org.krysalis.version.internal.data.ReleaseLevel;
! import org.krysalis.version.internal.data.VersionData;
! import org.krysalis.version.internal.data.VersionDataElement;
! import org.krysalis.version.internal.data.VersionDataElementSet;
! import org.krysalis.version.internal.data.util.VersionDataIncrementor;
  import org.krysalis.version.specification.VersionSpecification;
  import org.krysalis.version.specification.VersionSpecificationFactory;
--- 63,71 ----
  import org.krysalis.version.exception.VersionException;
  import org.krysalis.version.formatting.exception.VersionFormatException;
! import org.krysalis.version.impl.data.ReleaseLevel;
! import org.krysalis.version.impl.data.VersionData;
! import org.krysalis.version.impl.data.VersionDataElement;
! import org.krysalis.version.impl.data.VersionDataElementSet;
! import org.krysalis.version.impl.data.util.VersionDataIncrementor;
  import org.krysalis.version.specification.VersionSpecification;
  import org.krysalis.version.specification.VersionSpecificationFactory;




-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en