I assumed that the incoming POM had been formatted with the eclipse format from the standard maven rules, so that I could run source/format safely. Apparently I made a bad assumption.
Shall I put it back? On Sun, Jun 12, 2011 at 4:08 PM, Stephen Connolly <[email protected]> wrote: > pom formatting got changed there > > On 12 June 2011 20:57, <[email protected]> wrote: >> Author: bimargulies >> Date: Sun Jun 12 19:57:40 2011 >> New Revision: 1134972 >> >> URL: http://svn.apache.org/viewvc?rev=1134972&view=rev >> Log: >> Take existing CollectionUtils as new implementation. >> >> Added: >> >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java >> (with props) >> Modified: >> >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/pom.xml >> >> Modified: >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml >> URL: >> http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml?rev=1134972&r1=1134971&r2=1134972&view=diff >> ============================================================================== >> --- >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml >> (original) >> +++ >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/pom.xml >> Sun Jun 12 19:57:40 2011 >> @@ -1,63 +1,68 @@ >> <?xml version="1.0" encoding="UTF-8"?> >> -<project xmlns="http://maven.apache.org/POM/4.0.0" >> - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >> http://maven.apache.org/xsd/maven-4.0.0.xsd"> >> - <modelVersion>4.0.0</modelVersion> >> - >> - <parent> >> - <artifactId>plexus-utils-commons-bridge-parent</artifactId> >> - <groupId>org.apache.maven.sandbox</groupId> >> - <version>0.1-SNAPSHOT</version> >> - </parent> >> - >> - <artifactId>plexus-utils-commons-bridge</artifactId> >> - >> - <name>Plexus Utils to Apache Commons bridge</name> >> - <description>A bridge/shim that implements Plexus Utils using Apache >> Commons</description> >> - >> - <dependencies> >> - <dependency> >> - <groupId>commons-io</groupId> >> - <artifactId>commons-io</artifactId> >> - </dependency> >> - <dependency> >> - <groupId>commons-codec</groupId> >> - <artifactId>commons-codec</artifactId> >> - </dependency> >> - <dependency> >> - <groupId>junit</groupId> >> - <artifactId>junit</artifactId> >> - <scope>test</scope> >> - </dependency> >> - <dependency> >> - <groupId>org.apache.maven.sandbox</groupId> >> - <artifactId>plexus-utils-tck</artifactId> >> - <version>${project.parent.version}</version> >> - <type>test-jar</type> >> - <scope>test</scope> >> - </dependency> >> - </dependencies> >> - >> - <build> >> - <plugins> >> - <plugin> >> - <artifactId>maven-dependency-plugin</artifactId> >> - <executions> >> - <execution> >> - <phase>generate-test-resources</phase> >> - <goals> >> - <goal>unpack-dependencies</goal> >> - </goals> >> - <configuration> >> - <includeTypes>test-jar</includeTypes> >> - <excludeTransitive>true</excludeTransitive> >> - >> <outputDirectory>${project.build.testOutputDirectory}</outputDirectory> >> - </configuration> >> - </execution> >> - </executions> >> - </plugin> >> - </plugins> >> - </build> >> +<project xmlns="http://maven.apache.org/POM/4.0.0" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >> http://maven.apache.org/xsd/maven-4.0.0.xsd"> >> + <modelVersion>4.0.0</modelVersion> >> + >> + <parent> >> + <artifactId>plexus-utils-commons-bridge-parent</artifactId> >> + <groupId>org.apache.maven.sandbox</groupId> >> + <version>0.1-SNAPSHOT</version> >> + </parent> >> + >> + <artifactId>plexus-utils-commons-bridge</artifactId> >> + >> + <name>Plexus Utils to Apache Commons bridge</name> >> + <description>A bridge/shim that implements Plexus Utils using Apache >> Commons</description> >> + >> + <dependencies> >> + <dependency> >> + <groupId>commons-io</groupId> >> + <artifactId>commons-io</artifactId> >> + </dependency> >> + <dependency> >> + <groupId>commons-codec</groupId> >> + <artifactId>commons-codec</artifactId> >> + </dependency> >> + <dependency> >> + <groupId>junit</groupId> >> + <artifactId>junit</artifactId> >> + <scope>test</scope> >> + </dependency> >> + <dependency> >> + <groupId>org.apache.maven.sandbox</groupId> >> + <artifactId>plexus-utils-tck</artifactId> >> + <version>${project.parent.version}</version> >> + <type>test-jar</type> >> + <scope>test</scope> >> + </dependency> >> + <dependency> >> + <groupId>com.google.guava</groupId> >> + <artifactId>guava</artifactId> >> + <version>r09</version> >> + <scope>test</scope> >> + </dependency> >> + </dependencies> >> + >> + <build> >> + <plugins> >> + <plugin> >> + >> <artifactId>maven-dependency-plugin</artifactId> >> + <executions> >> + <execution> >> + >> <phase>generate-test-resources</phase> >> + <goals> >> + >> <goal>unpack-dependencies</goal> >> + </goals> >> + <configuration> >> + >> <includeTypes>test-jar</includeTypes> >> + >> <excludeTransitive>true</excludeTransitive> >> + >> <outputDirectory>${project.build.testOutputDirectory}</outputDirectory> >> + </configuration> >> + </execution> >> + </executions> >> + </plugin> >> + </plugins> >> + </build> >> >> >> </project> >> >> Added: >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java >> URL: >> http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java?rev=1134972&view=auto >> ============================================================================== >> --- >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java >> (added) >> +++ >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java >> Sun Jun 12 19:57:40 2011 >> @@ -0,0 +1,253 @@ >> +package org.codehaus.plexus.util; >> + >> +/* >> + * Copyright The Codehaus Foundation. >> + * >> + * Licensed under the Apache License, Version 2.0 (the "License"); >> + * you may not use this file except in compliance with the License. >> + * You may obtain a copy of the License at >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> + >> +import java.util.ArrayList; >> +import java.util.Collection; >> +import java.util.HashMap; >> +import java.util.HashSet; >> +import java.util.Iterator; >> +import java.util.List; >> +import java.util.Map; >> +import java.util.NoSuchElementException; >> +import java.util.Set; >> + >> +/** >> + * @author <a href="mailto:[email protected]">olamy</a> >> + * @version $Id: CollectionUtils.java 8055 2009-01-16 12:45:08Z vsiveton $ >> + */ >> +@SuppressWarnings( { "rawtypes", "unchecked" } ) >> +public class CollectionUtils >> +{ >> + // >> ---------------------------------------------------------------------- >> + // Static methods that can probably be moved to a real util class. >> + // >> ---------------------------------------------------------------------- >> + >> + /** >> + * Take a dominant and recessive Map and merge the key:value >> + * pairs where the recessive Map may add key:value pairs to the dominant >> + * Map but may not override any existing key:value pairs. >> + * >> + * If we have two Maps, a dominant and recessive, and >> + * their respective keys are as follows: >> + * >> + * dominantMapKeys = { a, b, c, d, e, f } >> + * recessiveMapKeys = { a, b, c, x, y, z } >> + * >> + * Then the result should be the following: >> + * >> + * resultantKeys = { a, b, c, d, e, f, x, y, z } >> + * >> + * @param dominantMap Dominant Map. >> + * @param recessiveMap Recessive Map. >> + * @return The result map with combined dominant and recessive values. >> + */ >> + public static Map mergeMaps( Map dominantMap, Map recessiveMap ) >> + { >> + >> + if ( dominantMap == null && recessiveMap == null ) >> + { >> + return null; >> + } >> + >> + if ( dominantMap != null && recessiveMap == null ) >> + { >> + return dominantMap; >> + } >> + >> + if ( dominantMap == null && recessiveMap != null ) >> + { >> + return recessiveMap; >> + } >> + >> + Map result = new HashMap(); >> + >> + // Grab the keys from the dominant and recessive maps. >> + Set dominantMapKeys = dominantMap.keySet(); >> + Set recessiveMapKeys = recessiveMap.keySet(); >> + >> + // Create the set of keys that will be contributed by the >> + // recessive Map by subtracting the intersection of keys >> + // from the recessive Map's keys. >> + Collection contributingRecessiveKeys = >> + CollectionUtils.subtract( recessiveMapKeys, >> + CollectionUtils.intersection( >> dominantMapKeys, recessiveMapKeys ) ); >> + >> + result.putAll( dominantMap ); >> + >> + // Now take the keys we just found and extract the values from >> + // the recessiveMap and put the key:value pairs into the >> dominantMap. >> + for ( Iterator i = contributingRecessiveKeys.iterator(); >> i.hasNext(); ) >> + { >> + Object key = i.next(); >> + result.put( key, recessiveMap.get( key ) ); >> + } >> + >> + return result; >> + } >> + >> + /** >> + * Take a series of <code>Map</code>s and merge >> + * them where the ordering of the array from 0..n >> + * is the dominant order. >> + * >> + * @param maps An array of Maps to merge. >> + * @return Map The result Map produced after the merging process. >> + */ >> + public static Map mergeMaps( Map[] maps ) >> + { >> + Map result = null; >> + >> + if ( maps.length == 0 ) >> + { >> + result = null; >> + } >> + else if ( maps.length == 1 ) >> + { >> + result = maps[0]; >> + } >> + else >> + { >> + result = mergeMaps( maps[0], maps[1] ); >> + >> + for ( int i = 2; i < maps.length; i++ ) >> + { >> + result = mergeMaps( result, maps[i] ); >> + } >> + } >> + >> + return result; >> + } >> + >> + /** >> + * Returns a {@link Collection} containing the intersection >> + * of the given {@link Collection}s. >> + * <p> >> + * The cardinality of each element in the returned {@link Collection} >> + * will be equal to the minimum of the cardinality of that element >> + * in the two given {@link Collection}s. >> + * >> + * @see Collection#retainAll >> + */ >> + public static Collection intersection( final Collection a, final >> Collection b ) >> + { >> + ArrayList list = new ArrayList(); >> + Map mapa = getCardinalityMap( a ); >> + Map mapb = getCardinalityMap( b ); >> + Set elts = new HashSet( a ); >> + elts.addAll( b ); >> + Iterator it = elts.iterator(); >> + while ( it.hasNext() ) >> + { >> + Object obj = it.next(); >> + for ( int i = 0,m = Math.min( getFreq( obj, mapa ), getFreq( >> obj, mapb ) ); i < m; i++ ) >> + { >> + list.add( obj ); >> + } >> + } >> + return list; >> + } >> + >> + /** >> + * Returns a {@link Collection} containing <tt><i>a</i> - <i>b</i></tt>. >> + * The cardinality of each element <i>e</i> in the returned {@link >> Collection} >> + * will be the cardinality of <i>e</i> in <i>a</i> minus the cardinality >> + * of <i>e</i> in <i>b</i>, or zero, whichever is greater. >> + * >> + * @see Collection#removeAll >> + */ >> + public static Collection subtract( final Collection a, final Collection >> b ) >> + { >> + ArrayList list = new ArrayList( a ); >> + Iterator it = b.iterator(); >> + while ( it.hasNext() ) >> + { >> + list.remove( it.next() ); >> + } >> + return list; >> + } >> + >> + /** >> + * Returns a {@link Map} mapping each unique element in >> + * the given {@link Collection} to an {@link Integer} >> + * representing the number of occurances of that element >> + * in the {@link Collection}. >> + * An entry that maps to <tt>null</tt> indicates that the >> + * element does not appear in the given {@link Collection}. >> + */ >> + public static Map getCardinalityMap( final Collection col ) >> + { >> + HashMap count = new HashMap(); >> + Iterator it = col.iterator(); >> + while ( it.hasNext() ) >> + { >> + Object obj = it.next(); >> + Integer c = (Integer) ( count.get( obj ) ); >> + if ( null == c ) >> + { >> + count.put( obj, new Integer( 1 ) ); >> + } >> + else >> + { >> + count.put( obj, new Integer( c.intValue() + 1 ) ); >> + } >> + } >> + return count; >> + } >> + >> + public static List iteratorToList( Iterator it ) >> + { >> + if ( it == null ) >> + { >> + throw new NullPointerException( "it cannot be null." ); >> + } >> + >> + List list = new ArrayList(); >> + >> + while ( it.hasNext() ) >> + { >> + list.add( it.next() ); >> + } >> + >> + return list; >> + } >> + >> + // >> ---------------------------------------------------------------------- >> + // >> + // >> ---------------------------------------------------------------------- >> + >> + private static final int getFreq( final Object obj, final Map freqMap ) >> + { >> + try >> + { >> + Object o = freqMap.get( obj ); >> + if ( o != null ) // minimize NullPointerExceptions >> + { >> + return ( (Integer) o ).intValue(); >> + } >> + } >> + catch ( NullPointerException e ) >> + { >> + // ignored >> + } >> + catch ( NoSuchElementException e ) >> + { >> + // ignored >> + } >> + return 0; >> + } >> +} >> >> Propchange: >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> Propchange: >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/CollectionUtils.java >> ------------------------------------------------------------------------------ >> svn:mime-type = text/plain >> >> Modified: >> maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/pom.xml >> URL: >> http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/pom.xml?rev=1134972&r1=1134971&r2=1134972&view=diff >> ============================================================================== >> --- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/pom.xml >> (original) >> +++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/pom.xml >> Sun Jun 12 19:57:40 2011 >> @@ -1,56 +1,55 @@ >> <?xml version="1.0" encoding="UTF-8"?> >> -<project xmlns="http://maven.apache.org/POM/4.0.0" >> - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >> http://maven.apache.org/xsd/maven-4.0.0.xsd"> >> - <modelVersion>4.0.0</modelVersion> >> - >> - <parent> >> - <artifactId>plexus-utils-commons-bridge-parent</artifactId> >> - <groupId>org.apache.maven.sandbox</groupId> >> - <version>0.1-SNAPSHOT</version> >> - </parent> >> - >> - <artifactId>plexus-utils-tck</artifactId> >> - >> - <name>Plexus Utils Test Compatibility Kit</name> >> - <description>A set of test cases that verify compatibility with the >> Plexus Utils API</description> >> - >> - <dependencies> >> - <dependency> >> - <groupId>org.codehaus.plexus</groupId> >> - <artifactId>plexus-utils</artifactId> >> - <version>2.0.7</version> >> - <scope>provided</scope> >> - </dependency> >> - <dependency> >> - <groupId>junit</groupId> >> - <artifactId>junit</artifactId> >> - <version>4.8.2</version> >> - <scope>test</scope> >> - </dependency> >> - <dependency> >> - <groupId>com.google.guava</groupId> >> - <artifactId>guava</artifactId> >> - <version>r09</version> >> - <scope>test</scope> >> -</dependency> >> - >> - </dependencies> >> - >> - <build> >> - <plugins> >> - <plugin> >> - <artifactId>maven-jar-plugin</artifactId> >> - <executions> >> - <execution> >> - <goals> >> - <goal>test-jar</goal> >> - </goals> >> - </execution> >> - </executions> >> - </plugin> >> - </plugins> >> - </build> >> +<project xmlns="http://maven.apache.org/POM/4.0.0" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >> http://maven.apache.org/xsd/maven-4.0.0.xsd"> >> + <modelVersion>4.0.0</modelVersion> >> + >> + <parent> >> + <artifactId>plexus-utils-commons-bridge-parent</artifactId> >> + <groupId>org.apache.maven.sandbox</groupId> >> + <version>0.1-SNAPSHOT</version> >> + </parent> >> + >> + <artifactId>plexus-utils-tck</artifactId> >> + >> + <name>Plexus Utils Test Compatibility Kit</name> >> + <description>A set of test cases that verify compatibility with the >> Plexus Utils API</description> >> + >> + <dependencies> >> + <dependency> >> + <groupId>org.codehaus.plexus</groupId> >> + <artifactId>plexus-utils</artifactId> >> + <version>2.0.7</version> >> + <scope>provided</scope> >> + </dependency> >> + <dependency> >> + <groupId>junit</groupId> >> + <artifactId>junit</artifactId> >> + <version>4.8.2</version> >> + <scope>test</scope> >> + </dependency> >> + <dependency> >> + <groupId>com.google.guava</groupId> >> + <artifactId>guava</artifactId> >> + <version>r09</version> >> + <scope>test</scope> >> + </dependency> >> + >> + </dependencies> >> + >> + <build> >> + <plugins> >> + <plugin> >> + <artifactId>maven-jar-plugin</artifactId> >> + <executions> >> + <execution> >> + <goals> >> + <goal>test-jar</goal> >> + </goals> >> + </execution> >> + </executions> >> + </plugin> >> + </plugins> >> + </build> >> >> >> </project> >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
