You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/04/23 00:57:04 UTC

svn commit: r767705 [3/31] - in /maven/mercury/trunk/mercury-core: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/mercury/ src/main/java/org/apache/maven/merc...

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/QualityRange.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/QualityRange.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/QualityRange.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/QualityRange.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,108 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact;
+
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class QualityRange
+{
+    private static final Language LANG = new DefaultLanguage( QualityRange.class );
+    
+    public static final QualityRange SNAPSHOTS_ONLY =
+        new QualityRange( Quality.SNAPSHOT_QUALITY, true, Quality.SNAPSHOT_TS_QUALITY, true );
+
+    public static final QualityRange ALPHA_ONLY =
+        new QualityRange( Quality.SNAPSHOT_QUALITY, false, Quality.BETA_QUALITY, false );
+
+    public static final QualityRange BETA_ONLY =
+        new QualityRange( Quality.ALPHA_QUALITY, false, Quality.RELEASE_QUALITY, false );
+
+    public static final QualityRange RELEASES_ONLY =
+        new QualityRange( Quality.RELEASE_QUALITY, true, Quality.RELEASE_QUALITY, true );
+
+    public static final QualityRange ALL =
+        new QualityRange( Quality.SNAPSHOT_QUALITY, true, Quality.RELEASE_QUALITY, true );
+
+    protected Quality qualityFrom = Quality.SNAPSHOT_QUALITY;
+
+    protected boolean fromInclusive = true;
+
+    protected Quality qualityTo = Quality.RELEASE_QUALITY;
+
+    protected boolean toInclusive = true;
+
+    /**
+     * @param qualityFrom
+     * @param fromInclusive
+     * @param qualityTo
+     * @param toInclusive
+     */
+    public QualityRange( Quality qualityFrom, boolean fromInclusive, Quality qualityTo, boolean toInclusive )
+    {
+        this.qualityFrom = qualityFrom;
+        this.fromInclusive = fromInclusive;
+
+        this.qualityTo = qualityTo;
+        this.toInclusive = toInclusive;
+    }
+    
+    public static QualityRange create( boolean releases, boolean snapshots )
+    {
+        if( releases && snapshots )
+            return ALL;
+        else
+            if( releases )
+                return new QualityRange( Quality.ALPHA_QUALITY, true, Quality.RELEASE_QUALITY, true );
+            else
+                if( snapshots )
+                    return new QualityRange( Quality.SNAPSHOT_QUALITY, true, Quality.SNAPSHOT_TS_QUALITY, true );
+        
+        throw new IllegalArgumentException( LANG.getMessage( "quality.no.sn.no.rel" ) );
+    }
+
+    // ---------------------------------------------------------------------------
+    public boolean isAcceptedQuality( Quality quality )
+    {
+        // null quality means anything goes
+        if ( quality == null )
+        {
+            return true;
+        }
+
+        int from = quality.compareTo( qualityFrom );
+        if ( from == 0 )
+        {
+            return fromInclusive;
+        }
+
+        int to = quality.compareTo( qualityTo );
+        if ( to == 0 )
+        {
+            return toInclusive;
+        }
+
+        return from > 0 && to < 0;
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/QualityRange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/QualityRange.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessor.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessor.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessor.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessor.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,59 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.api;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+
+/**
+ * generic interface to be implemented by helper components
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public interface ArtifactListProcessor
+{
+    /** named functions - used to help processing in various parts of the system */
+    public static final String[] FUNCTIONS = new String[] { "tp" // transaction processing function, future use
+        };
+
+    public static final String FUNCTION_TP = FUNCTIONS[0];
+
+    /**
+     * initialize it if required
+     *
+     * @throws ArtifactListProcessorException
+     */
+    public void init( Map<String, String> env )
+        throws ArtifactListProcessorException;
+
+    /** configure it if required */
+    public void configure( Object config )
+        throws ArtifactListProcessorException;
+
+    /**
+     * actually do that
+     *
+     * @throws ArtifactListProcessorException
+     */
+    public List<ArtifactMetadata> process( List<ArtifactMetadata> artifacts )
+        throws ArtifactListProcessorException;
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessorException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessorException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessorException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessorException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,65 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.api;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class ArtifactListProcessorException
+    extends Exception
+{
+
+    /**
+   *
+   */
+    public ArtifactListProcessorException()
+    {
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     */
+    public ArtifactListProcessorException( String message )
+    {
+        super( message );
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param cause
+     */
+    public ArtifactListProcessorException( Throwable cause )
+    {
+        super( cause );
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public ArtifactListProcessorException( String message, Throwable cause )
+    {
+        super( message, cause );
+        // TODO Auto-generated constructor stub
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ArtifactListProcessorException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/Configurable.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/Configurable.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/Configurable.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/Configurable.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,38 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.api;
+
+/**
+ * provides a way to configure an object instance, if that object supports the idea
+ * 
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public interface Configurable
+{
+
+    /**
+     * configure this instance
+     * 
+     * @param name of the configurable property
+     * @param val configuration value
+     */
+    public void setOption( String name, Object val )
+        throws ConfigurationException;
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/Configurable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/Configurable.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,26 @@
+package org.apache.maven.mercury.artifact.api;
+
+public class ConfigurationException
+    extends Exception
+{
+
+    public ConfigurationException()
+    {
+    }
+
+    public ConfigurationException( String message )
+    {
+        super( message );
+    }
+
+    public ConfigurationException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public ConfigurationException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationUtil.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationUtil.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationUtil.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,42 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.maven.mercury.artifact.api;
+
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class ConfigurationUtil
+{
+    public static void configure( Configurable impl, Map<String,Object> config )
+    throws ConfigurationException
+    {
+        if( impl == null || config == null )
+            return;
+        
+        for( Map.Entry<String, Object> e : config.entrySet() )
+            impl.setOption( e.getKey(), e.getValue() );
+    }
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/api/ConfigurationUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ArtifactVersion.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ArtifactVersion.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ArtifactVersion.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ArtifactVersion.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,38 @@
+package org.apache.maven.mercury.artifact.version;
+
+import org.apache.maven.mercury.artifact.Quality;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+public interface ArtifactVersion
+    extends Comparable
+{
+    int getMajorVersion();
+
+    int getMinorVersion();
+
+    int getIncrementalVersion();
+
+    int getBuildNumber();
+
+    String getQualifier();
+    
+    Quality getQuality();
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ArtifactVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ArtifactVersion.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQuery.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQuery.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQuery.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQuery.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,58 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class AttributeQuery
+{
+    public static final char EXRP_START = '{';
+
+    public static final char EXRP_STOP = '}';
+
+    private String expr;
+
+    public AttributeQuery( String query )
+    {
+        if ( query == null || query.indexOf( EXRP_START ) == -1 )
+        {
+            return;
+        }
+        int from = query.indexOf( EXRP_START );
+        int to = query.indexOf( EXRP_STOP );
+    }
+
+    public static String stripExpression( String query )
+    {
+        if ( query == null || query.indexOf( EXRP_START ) == -1 )
+        {
+            return query;
+        }
+
+        int from = query.indexOf( EXRP_START );
+        if ( from == 0 )
+        {
+            return null;
+        }
+
+        return query.substring( 0, from );
+    }
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQuery.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQueryException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQueryException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQueryException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQueryException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,65 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class AttributeQueryException
+    extends Exception
+{
+
+    /**
+   *
+   */
+    public AttributeQueryException()
+    {
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     */
+    public AttributeQueryException( String message )
+    {
+        super( message );
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param cause
+     */
+    public AttributeQueryException( Throwable cause )
+    {
+        super( cause );
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public AttributeQueryException( String message, Throwable cause )
+    {
+        super( message, cause );
+        // TODO Auto-generated constructor stub
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQueryException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/AttributeQueryException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,445 @@
+package org.apache.maven.mercury.artifact.version;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you 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.
+ */
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.Stack;
+
+/*
+ * Generic implementation of version comparison.
+ *
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ * @author <a href="mailto:hboutemy@apache.org">Herve Boutemy</a>
+ * @version $Id$
+ */
+public class ComparableVersion
+    implements Comparable
+{
+    private String value;
+
+    private String canonical;
+
+    private ListItem items;
+
+    private interface Item
+    {
+        public static final int INTEGER_ITEM = 0;
+
+        public static final int STRING_ITEM = 1;
+
+        public static final int LIST_ITEM = 2;
+
+        public int compareTo( Item item );
+
+        public int getType();
+
+        public boolean isNull();
+    }
+
+    /**
+     * Represents a numeric item in the version item list.
+     */
+    private static class IntegerItem
+        implements Item
+    {
+    	private static final BigInteger BigInteger_ZERO = new BigInteger( "0" );
+
+        private final BigInteger value;
+
+        public static final IntegerItem ZERO = new IntegerItem();
+
+        private IntegerItem()
+        {
+        	this.value = BigInteger_ZERO;
+        }
+
+        public IntegerItem( String str )
+        {
+            this.value = new BigInteger( str );
+        }
+
+        public int getType()
+        {
+            return INTEGER_ITEM;
+        }
+
+        public boolean isNull()
+        {
+            return BigInteger_ZERO.equals( value );
+        }
+
+        public int compareTo( Item item )
+        {
+            if ( item == null )
+            {
+                return BigInteger_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
+            }
+
+            switch ( item.getType() )
+            {
+                case INTEGER_ITEM:
+                    return value.compareTo( ( (IntegerItem) item ).value );
+
+                case STRING_ITEM:
+                    return 1; // 1.1 > 1-sp
+
+                case LIST_ITEM:
+                    return 1; // 1.1 > 1-1
+
+                default:
+                    throw new RuntimeException( "invalid item: " + item.getClass() );
+            }
+        }
+
+        public String toString()
+        {
+            return value.toString();
+        }
+    }
+
+    /**
+     * Represents a string in the version item list, usually a qualifier.
+     */
+    private static class StringItem
+        implements Item
+    {
+        private final static String[] QUALIFIERS = { "snapshot", "alpha", "beta", "milestone", "rc", "", "sp" };
+
+        private final static List _QUALIFIERS = Arrays.asList( QUALIFIERS );
+
+        private final static Properties ALIASES = new Properties();
+        static
+        {
+            ALIASES.put( "ga", "" );
+            ALIASES.put( "final", "" );
+            ALIASES.put( "cr", "rc" );
+        }
+
+        /**
+         * A comparable for the empty-string qualifier. This one is used to determine if a given qualifier makes the
+         * version older than one without a qualifier, or more recent.
+         */
+        private static Comparable RELEASE_VERSION_INDEX = String.valueOf( _QUALIFIERS.indexOf( "" ) );
+
+        private String value;
+
+        public StringItem( String value, boolean followedByDigit )
+        {
+            if ( followedByDigit && value.length() == 1 )
+            {
+                // a1 = alpha-1, b1 = beta-1, m1 = milestone-1
+                switch ( value.charAt( 0 ) )
+                {
+                    case 'a':
+                        value = "alpha";
+                        break;
+                    case 'b':
+                        value = "beta";
+                        break;
+                    case 'm':
+                        value = "milestone";
+                        break;
+                }
+            }
+            this.value = ALIASES.getProperty( value, value );
+        }
+
+        public int getType()
+        {
+            return STRING_ITEM;
+        }
+
+        public boolean isNull()
+        {
+            return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 );
+        }
+
+        /**
+         * Returns a comparable for a qualifier.
+         *
+         * This method both takes into account the ordering of known qualifiers as well as lexical ordering for unknown
+         * qualifiers.
+         *
+         * just returning an Integer with the index here is faster, but requires a lot of if/then/else to check for -1
+         * or QUALIFIERS.size and then resort to lexical ordering. Most comparisons are decided by the first character,
+         * so this is still fast. If more characters are needed then it requires a lexical sort anyway.
+         *
+         * @param qualifier
+         * @return
+         */
+        public static Comparable comparableQualifier( String qualifier )
+        {
+            int i = _QUALIFIERS.indexOf( qualifier );
+
+            return i == -1 ? _QUALIFIERS.size() + "-" + qualifier : String.valueOf( i );
+        }
+
+        public int compareTo( Item item )
+        {
+            if ( item == null )
+            {
+                // 1-rc < 1, 1-ga > 1
+                return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX );
+            }
+            switch ( item.getType() )
+            {
+                case INTEGER_ITEM:
+                    return -1; // 1.any < 1.1 ?
+
+                case STRING_ITEM:
+                    return comparableQualifier( value ).compareTo( comparableQualifier( ( (StringItem) item ).value ) );
+
+                case LIST_ITEM:
+                    return -1; // 1.any < 1-1
+
+                default:
+                    throw new RuntimeException( "invalid item: " + item.getClass() );
+            }
+        }
+
+        public String toString()
+        {
+            return value;
+        }
+    }
+
+    /**
+     * Represents a version list item. This class is used both for the global item list and for sub-lists (which start
+     * with '-(number)' in the version specification).
+     */
+    private static class ListItem
+        extends ArrayList
+        implements Item
+    {
+        public int getType()
+        {
+            return LIST_ITEM;
+        }
+
+        public boolean isNull()
+        {
+            return ( size() == 0 );
+        }
+
+        void normalize()
+        {
+            for ( ListIterator iterator = listIterator( size() ); iterator.hasPrevious(); )
+            {
+                Item item = (Item) iterator.previous();
+                if ( item.isNull() )
+                {
+                    iterator.remove(); // remove null trailing items: 0, "", empty list
+                }
+                else
+                {
+                    break;
+                }
+            }
+        }
+
+        public int compareTo( Item item )
+        {
+            if ( item == null )
+            {
+                if ( size() == 0 )
+                {
+                    return 0; // 1-0 = 1- (normalize) = 1
+                }
+                Item first = (Item) get( 0 );
+                return first.compareTo( null );
+            }
+
+            switch ( item.getType() )
+            {
+                case INTEGER_ITEM:
+                    return -1; // 1-1 < 1.0.x
+
+                case STRING_ITEM:
+                    return 1; // 1-1 > 1-sp
+
+                case LIST_ITEM:
+                    Iterator left = iterator();
+                    Iterator right = ( (ListItem) item ).iterator();
+
+                    while ( left.hasNext() || right.hasNext() )
+                    {
+                        Item l = left.hasNext() ? (Item) left.next() : null;
+                        Item r = right.hasNext() ? (Item) right.next() : null;
+
+                        // if this is shorter, then invert the compare and mul with -1
+                        int result = l == null ? -1 * r.compareTo( l ) : l.compareTo( r );
+
+                        if ( result != 0 )
+                        {
+                            return result;
+                        }
+                    }
+
+                    return 0;
+
+                default:
+                    throw new RuntimeException( "invalid item: " + item.getClass() );
+            }
+        }
+
+        public String toString()
+        {
+            StringBuffer buffer = new StringBuffer( "(" );
+            for ( Iterator iter = iterator(); iter.hasNext(); )
+            {
+                buffer.append( iter.next() );
+                if ( iter.hasNext() )
+                {
+                    buffer.append( ',' );
+                }
+            }
+            buffer.append( ')' );
+            return buffer.toString();
+        }
+    }
+
+    public ComparableVersion( String version )
+    {
+        parseVersion( version );
+    }
+
+    public final void parseVersion( String version )
+    {
+        this.value = version;
+
+        items = new ListItem();
+
+        version = version.toLowerCase( Locale.ENGLISH );
+
+        ListItem list = items;
+
+        Stack stack = new Stack();
+        stack.push( list );
+
+        boolean isDigit = false;
+
+        int startIndex = 0;
+
+        for ( int i = 0; i < version.length(); i++ )
+        {
+            char c = version.charAt( i );
+
+            if ( c == '.' )
+            {
+                if ( i == startIndex )
+                {
+                    list.add( IntegerItem.ZERO );
+                }
+                else
+                {
+                    list.add( parseItem( isDigit, version.substring( startIndex, i ) ) );
+                }
+                startIndex = i + 1;
+            }
+            else if ( c == '-' )
+            {
+                if ( i == startIndex )
+                {
+                    list.add( IntegerItem.ZERO );
+                }
+                else
+                {
+                    list.add( parseItem( isDigit, version.substring( startIndex, i ) ) );
+                }
+                startIndex = i + 1;
+
+                if ( isDigit )
+                {
+                    list.normalize(); // 1.0-* = 1-*
+
+                    if ( ( i + 1 < version.length() ) && Character.isDigit( version.charAt( i + 1 ) ) )
+                    {
+                        // new ListItem only if previous were digits and new char is a digit,
+                        // ie need to differentiate only 1.1 from 1-1
+                        list.add( list = new ListItem() );
+
+                        stack.push( list );
+                    }
+                }
+            }
+            else if ( Character.isDigit( c ) )
+            {
+                if ( !isDigit && i > startIndex )
+                {
+                    list.add( new StringItem( version.substring( startIndex, i ), true ) );
+                    startIndex = i;
+                }
+
+                isDigit = true;
+            }
+            else
+            {
+                if ( isDigit && i > startIndex )
+                {
+                    list.add( parseItem( true, version.substring( startIndex, i ) ) );
+                    startIndex = i;
+                }
+
+                isDigit = false;
+            }
+        }
+
+        if ( version.length() > startIndex )
+        {
+            list.add( parseItem( isDigit, version.substring( startIndex ) ) );
+        }
+
+        while ( !stack.isEmpty() )
+        {
+            list = (ListItem) stack.pop();
+            list.normalize();
+        }
+
+        canonical = items.toString();
+    }
+
+    private static Item parseItem( boolean isDigit, String buf )
+    {
+        return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false );
+    }
+
+    public int compareTo( Object o )
+    {
+        return items.compareTo( ( (ComparableVersion) o ).items );
+    }
+
+    public String toString()
+    {
+        return value;
+    }
+
+    public boolean equals( Object o )
+    {
+        return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical );
+    }
+
+    public int hashCode()
+    {
+        return canonical.hashCode();
+    }
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,332 @@
+package org.apache.maven.mercury.artifact.version;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you 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.
+ */
+
+import java.util.StringTokenizer;
+
+import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.Quality;
+
+/*
+ * Default implementation of artifact versioning.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ * @version $Id$
+ */
+public class DefaultArtifactVersion
+    implements ArtifactVersion
+{
+    private String version;
+
+    private Integer majorVersion;
+
+    private Integer minorVersion;
+
+    private Integer incrementalVersion;
+
+    private Integer buildNumber;
+
+    private String base;
+
+    private String qualifier;
+
+    private ComparableVersion comparable;
+
+    private Quality quality = Quality.UNKNOWN_QUALITY;
+
+    public DefaultArtifactVersion( String version )
+    {
+        this.version = version;
+        parseVersion( version );
+        parseQuality( version );
+    }
+
+    public String getBase()
+    {
+        return base;
+    }
+
+    public boolean sameBase( DefaultArtifactVersion v )
+    {
+        return base.equals( v.base );
+    }
+
+    public boolean sameBase( String vs )
+    {
+        DefaultArtifactVersion v = new DefaultArtifactVersion( vs );
+        return base.equals( v.base );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return 11 + comparable.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object other )
+    {
+        return compareTo( other ) == 0;
+    }
+
+    public int compareTo( Object o )
+    {
+        DefaultArtifactVersion otherVersion = (DefaultArtifactVersion) o;
+        return this.comparable.compareTo( otherVersion.comparable );
+    }
+
+    public int getMajorVersion()
+    {
+        return majorVersion != null ? majorVersion : 0;
+    }
+
+    public int getMinorVersion()
+    {
+        return minorVersion != null ? minorVersion : 0;
+    }
+
+    public int getIncrementalVersion()
+    {
+        return incrementalVersion != null ? incrementalVersion : 0;
+    }
+
+    public int getBuildNumber()
+    {
+        return buildNumber != null ? buildNumber : 0;
+    }
+
+    public String getQualifier()
+    {
+        return qualifier;
+    }
+
+    public static boolean isVirtual( String version )
+    {
+        if ( version == null )
+            return false;
+
+        if ( version.endsWith( Artifact.SNAPSHOT_VERSION ) 
+            || version.endsWith( Artifact.LATEST_VERSION )
+            || version.endsWith( Artifact.RELEASE_VERSION )
+        )
+            return true;
+
+        return false;
+    }
+
+    public static boolean isVirtualRelease( String version )
+    {
+        if ( version == null )
+            return false;
+
+        if ( version.endsWith( Artifact.RELEASE_VERSION ) )
+            return true;
+
+        return false;
+    }
+
+    public static boolean isVirtualLatest( String version )
+    {
+        if ( version == null )
+            return false;
+
+        if ( version.endsWith( Artifact.LATEST_VERSION ) )
+            return true;
+
+        return false;
+    }
+
+    public static boolean isVirtualSnapshot( String version )
+    {
+        if ( version == null )
+            return false;
+
+        if ( version.endsWith( Artifact.SNAPSHOT_VERSION ) )
+            return true;
+
+        return false;
+    }
+
+    public final void parseVersion( String version )
+    {
+        comparable = new ComparableVersion( version );
+
+        int index = version.indexOf( "-" );
+
+        String part1;
+        String part2 = null;
+
+        if ( index < 0 )
+        {
+            part1 = version;
+        }
+        else
+        {
+            part1 = version.substring( 0, index );
+            part2 = version.substring( index + 1 );
+        }
+
+        if ( part2 != null )
+        {
+            try
+            {
+                if ( ( part2.length() == 1 ) || !part2.startsWith( "0" ) )
+                {
+                    buildNumber = Integer.valueOf( part2 );
+                }
+                else
+                {
+                    qualifier = part2;
+                }
+            }
+            catch ( NumberFormatException e )
+            {
+                qualifier = part2;
+            }
+        }
+
+        if ( ( part1.indexOf( "." ) < 0 ) && !part1.startsWith( "0" ) )
+        {
+            try
+            {
+                majorVersion = Integer.valueOf( part1 );
+            }
+            catch ( NumberFormatException e )
+            {
+                // qualifier is the whole version, including "-"
+                qualifier = version;
+                buildNumber = null;
+            }
+        }
+        else
+        {
+            boolean fallback = false;
+            StringTokenizer tok = new StringTokenizer( part1, "." );
+            try
+            {
+                majorVersion = getNextIntegerToken( tok );
+                if ( tok.hasMoreTokens() )
+                {
+                    minorVersion = getNextIntegerToken( tok );
+                }
+                if ( tok.hasMoreTokens() )
+                {
+                    incrementalVersion = getNextIntegerToken( tok );
+                }
+                if ( tok.hasMoreTokens() )
+                {
+                    fallback = true;
+                }
+
+                // string tokenzier won't detect these and ignores them
+                if ( part1.indexOf( ".." ) >= 0 || part1.startsWith( "." ) || part1.endsWith( "." ) )
+                {
+                    fallback = true;
+                }
+            }
+            catch ( NumberFormatException e )
+            {
+                fallback = true;
+            }
+
+            if ( fallback )
+            {
+                // qualifier is the whole version, including "-"
+                qualifier = version;
+                base = "";
+                majorVersion = null;
+                minorVersion = null;
+                incrementalVersion = null;
+                buildNumber = null;
+            }
+        }
+
+        if ( base == null )
+        {
+            if ( qualifier == null )
+            {
+                base = version;
+            }
+            else
+            {
+                int ind = version.indexOf( qualifier );
+                if ( ind == 0 )
+                {
+                    base = qualifier;
+                }
+                else
+                {
+                    base = version.substring( 0, version.indexOf( qualifier ) - 1 );
+                }
+            }
+        }
+    }
+
+    private static Integer getNextIntegerToken( StringTokenizer tok )
+    {
+        String s = tok.nextToken();
+        if ( ( s.length() > 1 ) && s.startsWith( "0" ) )
+        {
+            throw new NumberFormatException( "Number part has a leading 0: '" + s + "'" );
+        }
+        return Integer.valueOf( s );
+    }
+
+    private void parseQuality( String version )
+    {
+        quality = new Quality( version );
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        if ( majorVersion != null )
+        {
+            buf.append( majorVersion );
+        }
+        if ( minorVersion != null )
+        {
+            buf.append( "." );
+            buf.append( minorVersion );
+        }
+        if ( incrementalVersion != null )
+        {
+            buf.append( "." );
+            buf.append( incrementalVersion );
+        }
+        if ( buildNumber != null )
+        {
+            buf.append( "-" );
+            buf.append( buildNumber );
+        }
+        else if ( qualifier != null )
+        {
+            if ( buf.length() > 0 )
+            {
+                buf.append( "-" );
+            }
+            buf.append( qualifier );
+        }
+        return buf.toString();
+    }
+
+    public Quality getQuality()
+    {
+        return quality;
+    }
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MavenVersionRange.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MavenVersionRange.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MavenVersionRange.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MavenVersionRange.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,277 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+import org.apache.maven.mercury.artifact.Quality;
+import org.apache.maven.mercury.artifact.QualityEnum;
+import org.apache.maven.mercury.artifact.QualityRange;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * Single range implementation, similar to OSGi specification:
+ *
+ * [1.2.3, 4.5.6) 1.2.3 <= x < 4.5.6
+ * [1.2.3, 4.5.6] 1.2.3 <= x <= 4.5.6
+ * (1.2.3, 4.5.6) 1.2.3 < x < 4.5.6
+ * (1.2.3, 4.5.6] 1.2.3 < x <= 4.5.6
+ * 1.2.3 1.2.3 <= x - this one is configurable nowadays
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+class MavenVersionRange
+    implements VersionRange
+{
+    public static final String SYSTEM_PARAMETER_OSGI_VERSION = "maven.mercury.osgi.version";
+
+    public static final String SYSTEM_PARAMETER_OSGI_VERSION_DEFAULT = "false";
+
+    private boolean _osgiVersion =
+        Boolean.parseBoolean( System.getProperty( SYSTEM_PARAMETER_OSGI_VERSION, SYSTEM_PARAMETER_OSGI_VERSION_DEFAULT ) );
+
+    private static final DefaultArtifactVersion ZERO_VERSION = new DefaultArtifactVersion( "0.0.0" );
+
+    private static final Language _lang = new DefaultLanguage( MavenVersionRange.class );
+
+    QualityRange _toQualityRange = QualityRange.ALL;
+
+    DefaultArtifactVersion _fromVersion = ZERO_VERSION;
+
+    boolean _fromInclusive = true;
+
+    DefaultArtifactVersion _toVersion;
+
+    boolean _toInclusive = false;
+
+    boolean _singleton = false;
+
+    // --------------------------------------------------------------------------------------------
+    protected MavenVersionRange( final String range, final QualityRange qRange )
+        throws VersionException
+    {
+        this( range );
+        setToQualityRange( qRange );
+    }
+
+    // --------------------------------------------------------------------------------------------
+    protected MavenVersionRange( final String rangeIn )
+        throws VersionException
+    {
+        String range = AttributeQuery.stripExpression( rangeIn );
+
+        if ( range == null || range.length() < 1 )
+        {
+            return;
+        }
+
+        if ( range.indexOf( ',' ) > 0 )
+        {
+            if ( range.startsWith( "[" ) )
+            {
+                _fromInclusive = true;
+            }
+            else if ( range.startsWith( "(" ) )
+            {
+                _fromInclusive = false;
+            }
+            else
+            {
+                throw new VersionException( _lang.getMessage( "invalid.maven.version.range", range ) );
+            }
+
+            if ( range.endsWith( "]" ) )
+            {
+                _toInclusive = true;
+            }
+            else if ( range.endsWith( ")" ) )
+            {
+                _toInclusive = false;
+            }
+            else
+            {
+                throw new VersionException( _lang.getMessage( "invalid.maven.version.range", range ) );
+            }
+
+            int ind = range.indexOf( ',' );
+
+            String sFrom = range.substring( 1, ind );
+            if ( sFrom != null && sFrom.length() > 0 )
+            {
+                String sFromT = sFrom.trim();
+                if ( sFromT != null && sFromT.length() > 0 )
+                {
+                    checkForValidCharacters( sFromT );
+                    // TODO og: look for LATEST,RELEASE and SNAPSHOT
+                    Quality vq = new Quality( sFromT );
+                    if ( vq.getQuality().equals( QualityEnum.snapshot ) || vq.getQuality().equals( QualityEnum.unknown ) )
+                    {
+                        throw new VersionException( _lang.getMessage( "bad.version.sn", sFromT ) );
+                    }
+
+                    _fromVersion = new DefaultArtifactVersion( sFromT );
+                }
+            }
+
+            String sTo = range.substring( ind + 1, range.length() - 1 );
+            if ( sTo != null && sTo.length() > 0 )
+            {
+                String sToT = sTo.trim();
+                if ( sToT != null && sToT.length() > 0 )
+                {
+                    checkForValidCharacters( sToT );
+                    _toVersion = new DefaultArtifactVersion( sToT );
+                }
+            }
+
+            if ( _fromVersion == null && _fromInclusive )
+            {
+                throw new VersionException( _lang.getMessage( "invalid.maven.version.range.bad.from", range ) );
+            }
+
+            if ( _toVersion == null && _toInclusive )
+            {
+                throw new VersionException( _lang.getMessage( "invalid.maven.version.range.bad.to", range ) );
+            }
+
+        }
+        else
+        {
+
+            checkForValidCharacters( range );
+            _fromVersion = new DefaultArtifactVersion( range );
+
+            _singleton = true;
+
+            // good old maven version interpretation
+            if ( !_osgiVersion )
+            {
+                _toVersion = _fromVersion;
+                _fromInclusive = true;
+                _toInclusive = true;
+            }
+        }
+    }
+
+    // --------------------------------------------------------------------------------------------
+    protected void setToQualityRange( QualityRange qRange )
+    {
+        this._toQualityRange = qRange;
+    }
+
+    // --------------------------------------------------------------------------------------------
+    private void checkForValidCharacters( String v )
+        throws VersionException
+    {
+        if ( v == null || v.length() < 1 )
+        {
+            throw new VersionException( "empty version" );
+        }
+
+        int len = v.length();
+
+        for ( int i = 0; i < len; i++ )
+        {
+            char c = v.charAt( 0 );
+
+            if ( c >= '0' && c <= '9' )
+            {
+                continue;
+            }
+
+            if ( c >= 'A' && c <= 'Z' )
+            {
+                continue;
+            }
+
+            if ( c >= 'a' && c <= 'z' )
+            {
+                continue;
+            }
+
+            if ( c == '-' || c == '_' )
+            {
+                continue;
+            }
+
+            throw new VersionException( _lang.getMessage( "invalid.character", "" + c, v ) );
+        }
+    }
+
+    // --------------------------------------------------------------------------------------------
+    /*
+     * (non-Javadoc)
+     * @see org.apache.maven.mercury.artifact.version.VersionRange#includes(java.lang.String)
+     */
+    public boolean includes( String version )
+    {
+        DefaultArtifactVersion ver = new DefaultArtifactVersion( version );
+
+        int cmp1 = ver.compareTo( _fromVersion );
+
+        if ( cmp1 < 0 )
+        {
+            return false;
+        }
+
+        if ( cmp1 == 0 )
+        {
+            return _fromInclusive;
+        }
+
+        if ( _toVersion == null ) // eternity
+        {
+            return true;
+        }
+
+        int cmp2 = ver.compareTo( _toVersion );
+
+        if ( cmp2 < 0 )
+        {
+            if ( ver.sameBase( _toVersion ) )
+            {
+                return _toQualityRange.isAcceptedQuality( ver.getQuality() );
+            }
+            return true;
+        }
+
+        if ( cmp2 == 0 )
+        {
+            return _toInclusive;
+        }
+
+        return false;
+    }
+
+    public void setOption( String name, Object val )
+    {
+        if ( SYSTEM_PARAMETER_OSGI_VERSION.equals( name ) )
+        {
+            _osgiVersion = Boolean.parseBoolean( System.getProperty( (String)val, SYSTEM_PARAMETER_OSGI_VERSION_DEFAULT ) );
+        }
+    }
+    
+    public boolean isSingleton()
+    {
+        return _singleton;
+    }
+
+    // --------------------------------------------------------------------------------------------
+    // --------------------------------------------------------------------------------------------
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MavenVersionRange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MavenVersionRange.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/Messages.properties
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/Messages.properties?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/Messages.properties (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/Messages.properties Wed Apr 22 22:56:48 2009
@@ -0,0 +1,24 @@
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you 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.
+#
+bad.version.sn=version range cannot include SNAPSHOT, LATEST or RELEASE versions, found: {0}
+null.version.to.compare=one of the versions is null: {0} vs {1}, cannot compare
+invalid.maven.version.range=invalid range: {0}
+invalid.maven.version.range.bad.from=invalid range: {0} - from infinity cannot be inclusive
+invalid.maven.version.range.bad.to=invalid range: {0} - to infinity cannot be inclusive
+invalid.character=invalid character '{0}' in version {1}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MetadataVersionComparator.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MetadataVersionComparator.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MetadataVersionComparator.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MetadataVersionComparator.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,52 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+import java.util.Comparator;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * version comparator used elsewhere to keep version collections sorted
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class MetadataVersionComparator
+    implements Comparator<ArtifactMetadata>
+{
+    private static final Language _lang = new DefaultLanguage( MetadataVersionComparator.class );
+
+    public int compare( ArtifactMetadata v1, ArtifactMetadata v2 )
+    {
+        if ( v1 == null || v2 == null )
+        {
+            throw new IllegalArgumentException( _lang.getMessage( "null.version.to.compare", v1 == null ? "null"
+                            : v1.toString(), v2 == null ? "null" : v2.toString() ) );
+        }
+
+        DefaultArtifactVersion av1 = new DefaultArtifactVersion( v1.getVersion() );
+        DefaultArtifactVersion av2 = new DefaultArtifactVersion( v2.getVersion() );
+
+        return av1.compareTo( av2 );
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MetadataVersionComparator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/MetadataVersionComparator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionComparator.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionComparator.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionComparator.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionComparator.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,50 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+import java.util.Comparator;
+
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * version comparator used elsewhere to keep version collections sorted
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class VersionComparator
+    implements Comparator<String>
+{
+    private static final Language LANG = new DefaultLanguage( VersionComparator.class );
+
+    public int compare( String v1, String v2 )
+    {
+        if ( v1 == null || v2 == null )
+        {
+            throw new IllegalArgumentException( LANG.getMessage( "null.version.to.compare", v1, v2 ) );
+        }
+
+        DefaultArtifactVersion av1 = new DefaultArtifactVersion( v1 );
+        DefaultArtifactVersion av2 = new DefaultArtifactVersion( v2 );
+
+        return av1.compareTo( av2 );
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionComparator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionComparator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,48 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class VersionException
+    extends Exception
+{
+
+    public VersionException()
+    {
+    }
+
+    public VersionException( String message )
+    {
+        super( message );
+    }
+
+    public VersionException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public VersionException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionQuery.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionQuery.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionQuery.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionQuery.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,69 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+import java.util.StringTokenizer;
+
+/**
+ * multiple ranges. Not sure if we need need it - will delete later ..
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class VersionQuery
+{
+    String[] _ranges;
+
+    public VersionQuery( String query )
+    {
+
+    }
+
+    private void parseRange( String query )
+    {
+        if ( query == null || query.length() < 1 )
+        {
+            return;
+        }
+
+        StringTokenizer st = new StringTokenizer( query, "," );
+        int nRanges = st.countTokens();
+        if ( nRanges < 1 )
+        {
+            return;
+        }
+
+        _ranges = new String[nRanges];
+        int count = 0;
+
+        while ( st.hasMoreTokens() )
+        {
+            _ranges[count++] = st.nextToken();
+        }
+
+    }
+
+    /**
+   *
+   */
+    public boolean within( String version )
+    {
+        return false;
+    }
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionQuery.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRange.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRange.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRange.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRange.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,44 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+import org.apache.maven.mercury.artifact.api.Configurable;
+
+/**
+ * interface to the version range processor. To be implemented for various syntaxes/interpreters
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public interface VersionRange
+    extends Configurable
+{
+    /**
+     * returns true if the supplied version fits into the range
+     *
+     * @param version to test
+     * @return
+     */
+    public boolean includes( String version );
+
+    /**
+     * @return true if the range is good old single version, not a true range
+     */
+    public boolean isSingleton();
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRange.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRangeFactory.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRangeFactory.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRangeFactory.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRangeFactory.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,88 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.artifact.version;
+
+import java.util.Collection;
+
+import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.QualityRange;
+
+/**
+ * lack of IoC container makes me throw this class in.
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class VersionRangeFactory
+{
+
+    public static VersionRange create( final String version )
+        throws VersionException
+    {
+        return new MavenVersionRange( version );
+    }
+
+    public static VersionRange create( final String version, final QualityRange qRange )
+        throws VersionException
+    {
+        return new MavenVersionRange( version, qRange );
+    }
+
+    // --------------------------------------------------------------------------------------------
+    /**
+     * helpful latest version calculator
+     *
+     * @param versions
+     * @param noSnapshots
+     * @return
+     */
+    public static final String findLatest( final Collection<String> versions, final boolean noSnapshots )
+    {
+        DefaultArtifactVersion tempDav = null;
+        DefaultArtifactVersion tempDav2 = null;
+        String version = null;
+
+        // find latest
+        for ( String vn : versions )
+        {
+            // RELEASE?
+            if ( noSnapshots )
+            {
+                if( vn.endsWith( Artifact.SNAPSHOT_VERSION ) || vn.matches( Artifact.SNAPSHOT_TS_REGEX ) )
+                continue;
+            }
+
+            if ( version == null )
+            {
+                version = vn;
+                tempDav = new DefaultArtifactVersion( vn );
+                continue;
+            }
+
+            tempDav2 = new DefaultArtifactVersion( vn );
+            if ( tempDav2.compareTo( tempDav ) > 0 )
+            {
+                version = vn;
+                tempDav = tempDav2;
+            }
+        }
+        return version;
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRangeFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/artifact/version/VersionRangeFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessor.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessor.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessor.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessor.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,45 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.builder.api;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+
+public interface DependencyProcessor
+{
+    /** dummy processor to create M2 repositories when metadata processing is not required */
+    public static final DependencyProcessor NULL_PROCESSOR = new DependencyProcessor()
+    {
+        public List<ArtifactMetadata> getDependencies( ArtifactMetadata bmd, MetadataReader mdReader,
+                                                            Map<String, String> env, Map<?, ?> sysProps )
+            throws MetadataReaderException, DependencyProcessorException
+        {
+            return null;
+        }
+    };
+
+    // TODO: shouldn't sysProps be changed to Properties because of System.getProperties() API?
+    // Oleg: sysProp may help to experiment with Objects, different from Strings, so I'd 
+    //  stay with the Map until this is stable enough
+    public List<ArtifactMetadata> getDependencies( ArtifactMetadata bmd, MetadataReader mdReader,
+                                                        Map<String, String> env, Map<?, ?> sysProps )
+        throws MetadataReaderException, DependencyProcessorException;
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessorException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessorException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessorException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessorException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,65 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.builder.api;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class DependencyProcessorException
+    extends Exception
+{
+    private static final long serialVersionUID = -2956563106663149486L;
+
+    /**
+     *
+     */
+    public DependencyProcessorException()
+    {
+    }
+
+    /**
+     * @param message
+     */
+    public DependencyProcessorException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * @param cause
+     */
+    public DependencyProcessorException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public DependencyProcessorException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/DependencyProcessorException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/MetadataReader.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/MetadataReader.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/MetadataReader.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/MetadataReader.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,63 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.maven.mercury.builder.api;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+
+/**
+ * This interface implementation is supplied to MetadataProcessor to simplify it's access to remote repositories
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public interface MetadataReader
+{
+    /**
+     * read raw content pointed by bmd, possibly modified by classifier and type
+     *
+     * @param bmd coordinates
+     * @param classifier - replaces the getClassifier() from bmd if not null
+     * @param type - replaces the getType() from bmd if not null
+     * @param exempt - if this read should be exempt from stream verification, default - false
+     * @return
+     * @throws MetadataReaderException
+     * @throws RepositoryException
+     */
+    public byte[] readRawData( ArtifactMetadata bmd, String classifier, String type, boolean exempt )
+        throws MetadataReaderException;
+
+    public byte[] readRawData( ArtifactMetadata bmd, String classifier, String type )
+        throws MetadataReaderException;
+
+  /**
+     * read metadata for the artifact, pointed by bmd. It will return POM bytes regardless of actual bmd type
+     *
+     * @param bmd metadata to read
+     * @param exempt - if this read should be exempt from stream verification, default - false
+     * @return
+     * @throws MetadataReaderException
+     */
+    public byte[] readMetadata( ArtifactMetadata bmd, boolean exempt )
+        throws MetadataReaderException;
+
+    public byte[] readMetadata( ArtifactMetadata bmd )
+        throws MetadataReaderException;
+}

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/MetadataReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/builder/api/MetadataReader.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision