Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 32906 invoked from network); 19 Jul 2008 21:29:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Jul 2008 21:29:33 -0000 Received: (qmail 12396 invoked by uid 500); 19 Jul 2008 21:29:32 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 12355 invoked by uid 500); 19 Jul 2008 21:29:32 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 12346 invoked by uid 99); 19 Jul 2008 21:29:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Jul 2008 14:29:32 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Jul 2008 21:28:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 602B023889F7; Sat, 19 Jul 2008 14:28:41 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r678220 - in /maven/sandbox/trunk/shared/maven-shared-model/src: main/java/org/apache/maven/shared/model/ main/java/org/apache/maven/shared/model/impl/ test/java/org/apache/maven/shared/model/impl/ Date: Sat, 19 Jul 2008 21:28:40 -0000 To: commits@maven.apache.org From: sisbell@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080719212841.602B023889F7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sisbell Date: Sat Jul 19 14:28:40 2008 New Revision: 678220 URL: http://svn.apache.org/viewvc?rev=678220&view=rev Log: Fairly complete javadocs. Removed unneeded sort method. Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DataSourceException.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DomainModel.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/InterpolatorProperty.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelContainer.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelDataSource.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java maven/sandbox/trunk/shared/maven-shared-model/src/test/java/org/apache/maven/shared/model/impl/DefaultModelDataSourceTest.java Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DataSourceException.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DataSourceException.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DataSourceException.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DataSourceException.java Sat Jul 19 14:28:40 2008 @@ -21,16 +21,27 @@ import java.io.IOException; +/** + * Exeception class whose instance is thrown if there is an illegal state within a data source. + */ public class DataSourceException extends IOException { static final long serialVersionUID = 8738495672439L; + /** + * Default constructor + */ public DataSourceException() { super(); } + /** + * Constructor + * + * @param message exception message + */ public DataSourceException( String message ) { super( message ); Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DomainModel.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DomainModel.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DomainModel.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/DomainModel.java Sat Jul 19 14:28:40 2008 @@ -27,7 +27,17 @@ public interface DomainModel { + /** + * Returns event history of joins and deletes used in constructing this domain model. + * + * @return event history of joins and deletes used in constructing this domain model + */ String getEventHistory(); + /** + * Sets event history of joins and deletes used in constructing this domain model + * + * @param history history of joins and deletes used in constructing this domain model + */ void setEventHistory( String history ); } Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/InterpolatorProperty.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/InterpolatorProperty.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/InterpolatorProperty.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/InterpolatorProperty.java Sat Jul 19 14:28:40 2008 @@ -19,13 +19,27 @@ * under the License. */ +/** + * Provides interpolator property information. + */ public final class InterpolatorProperty { - + /** + * The key (or name) of the property + */ private final String key; + /** + * The value of the property + */ private final String value; + /** + * Constructor + * + * @param key the key (or name) of the property. May not be null + * @param value the value of the property. May not be null. + */ public InterpolatorProperty( String key, String value ) { if ( key == null ) @@ -41,16 +55,32 @@ this.value = value; } + /** + * Returns key (or name) of property. + * + * @return key (or name) of property + */ public String getKey() { return key; } + /** + * Returns value of property. + * + * @return value of property + */ public String getValue() { return value; } + /** + * Returns true if key values match, otherwise returns false. + * + * @param o interpolator property to compare + * @return true if key values match, otherwise returns false + */ public boolean equals( Object o ) { if ( this == o ) @@ -72,6 +102,11 @@ return true; } + /** + * Returns hash code of interpolator property key. + * + * @return hash code of interpolator property key + */ public int hashCode() { return key.hashCode(); Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelContainer.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelContainer.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelContainer.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelContainer.java Sat Jul 19 14:28:40 2008 @@ -56,6 +56,4 @@ */ ModelContainer createNewInstance( List modelProperties ); - void sort( List modelProperties ); - } Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelDataSource.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelDataSource.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelDataSource.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelDataSource.java Sat Jul 19 14:28:40 2008 @@ -72,5 +72,10 @@ */ void init( List modelProperties, Collection modelContainerFactories ); + /** + * Return history of all joins and deletes + * + * @return history of all joins and deletes + */ String getEventHistory(); } Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java Sat Jul 19 14:28:40 2008 @@ -40,10 +40,22 @@ public final class ModelMarshaller { + /** + * Private Constructor + */ private ModelMarshaller() { } + /** + * Returns list of model properties transformed from the specified input stream. + * + * @param inputStream input stream containing the xml document. May not be null. + * @param baseUri the base uri of every model property. May not be null or empty. + * @param collections set of uris that are to be treated as a collection (multiple entries). May be null. + * @return list of model properties transformed from the specified input stream. + * @throws IOException if there was a problem doing the transform + */ public static List marshallXmlToModelProperties( InputStream inputStream, String baseUri, Set collections ) throws IOException @@ -53,7 +65,7 @@ throw new IllegalArgumentException( "inputStream: null" ); } - if ( baseUri == null ) + if ( baseUri == null || baseUri.trim().length() == 0 ) { throw new IllegalArgumentException( "baseUri: null" ); } @@ -184,6 +196,14 @@ } } + /** + * Returns XML string unmarshalled from the specified list of model properties + * + * @param modelProperties the model properties to unmarshal. May not be null or empty + * @param baseUri the base uri of every model property. May not be null or empty. + * @return XML string unmarshalled from the specified list of model properties + * @throws IOException if there was a problem with unmarshalling + */ public static String unmarshalModelPropertiesToXml( List modelProperties, String baseUri ) throws IOException { @@ -258,14 +278,29 @@ return sb.toString(); } + /** + * Returns list of tag names parsed from the specified uri. All #collection parts of the tag are removed from the + * tag names. + * + * @param basePosition the base position in the specified URI to start the parse + * @param uri the uri to parse for tag names + * @return list of tag names parsed from the specified uri + */ private static List getTagNamesFromUri( int basePosition, String uri ) { return Arrays.asList( uri.substring( basePosition ).replaceAll( "#collection", "" ).split( "/" ) ); } + /** + * Returns the XML formatted start tag for the specified value and the specified attribute. + * + * @param value the value to use for the start tag + * @param attribute the attribute to use in constructing of start tag + * @return the XML formatted start tag for the specified value and the specified attribute + */ private static String toStartTag( String value, ModelProperty attribute ) { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = new StringBuffer(); //TODO: Support more than one attribute sb.append( "\r\n<" ).append( value ); if ( attribute != null ) { @@ -277,6 +312,12 @@ return sb.toString(); } + /** + * Returns XML formatted end tag for the specified value. + * + * @param value the value to use for the end tag + * @return xml formatted end tag for the specified value + */ private static String toEndTag( String value ) { if ( value.trim().length() == 0 ) @@ -288,6 +329,9 @@ return sb.toString(); } + /** + * Class for storing information about URIs. + */ private static class Uri { Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java Sat Jul 19 14:28:40 2008 @@ -30,6 +30,9 @@ public final class ModelProperty { + /** + * A pattern used for finding pom, project and env properties + */ private static final Pattern EXPRESSION_PATTERN = Pattern.compile( "\\$\\{(pom\\.|project\\.|env\\.)?([^}]+)\\}" ); /** @@ -42,11 +45,20 @@ */ private final String value; + /** + * The count of '/' within this model property's uri, which is the depth of its XML nodes. + */ private final int depth; + /** + * Value of this model property after interpolation + */ private String resolvedValue; - private final List expressions; + /** + * List of unresolved expressions within this model property's value + */ + private final List unresolvedExpressions; /** * Constructor @@ -64,13 +76,13 @@ this.value = value; resolvedValue = value; - expressions = new ArrayList(); + unresolvedExpressions = new ArrayList(); if ( value != null ) { Matcher matcher = EXPRESSION_PATTERN.matcher( value ); while ( matcher.find() ) { - expressions.add( matcher.group( 0 ) ); + unresolvedExpressions.add( matcher.group( 0 ) ); } } depth = uri.split( "/" ).length; @@ -87,35 +99,61 @@ } /** - * Returns value for the key. Value may be null. + * Returns value for the URI key. Value may be null. * - * @return value for the key. Value may be null. + * @return value for the URI key. Value may be null */ public String getValue() { return value; } + /** + * Value of this model property after interpolation. + * + * @return value of this model property after interpolation + */ public String getResolvedValue() { return resolvedValue; } + /** + * Returns true if model property is completely interpolated, otherwise returns false. + * + * @return true if model property is completely interpolated, otherwise returns false + */ public boolean isResolved() { - return expressions.isEmpty(); + return unresolvedExpressions.isEmpty(); } + /** + * Returns copy of the uninterpolated model property + * + * @return copy of the uninterpolated model property + */ public ModelProperty createCopyOfOriginal() { return new ModelProperty( uri, value ); } + /** + * Returns the count of '/' within this model property's uri, which is the depth of its XML nodes. + * + * @return the count of '/' within this model property's uri, which is the depth of its XML nodes + */ public int getDepth() { return depth; } + /** + * Returns true if this model property is a direct parent of the specified model property, otherwise returns false. + * + * @param modelProperty the model property + * @return true if this model property is a direct parent of the specified model property, otherwise returns false + */ public boolean isParentOf( ModelProperty modelProperty ) { if ( Math.abs( depth - modelProperty.getDepth() ) > 1 ) @@ -128,13 +166,15 @@ } return ( modelProperty.getUri().startsWith( uri ) ); } - /* - public boolean isParentOf(ModelProperty modelProperty) { - return !(uri.equals(modelProperty.getUri()) || uri.startsWith(modelProperty.getUri())) - && (modelProperty.getUri().startsWith(uri)); - } - */ + /** + * Returns this model property as an interpolator property, allowing the interpolation of model elements within + * other model elements. + * + * @param baseUri the base uri of the model property + * @return this model property as an interpolator property, allowing the interpolation of model elements within + * other model elements + */ public InterpolatorProperty asInterpolatorProperty( String baseUri ) { if ( uri.contains( "#collection" ) || value == null ) @@ -145,6 +185,11 @@ return new InterpolatorProperty( key, value ); } + /** + * Resolves any unresolved model property expressions using the specified interpolator property + * + * @param property the interpolator property used to resolve + */ public void resolveWith( InterpolatorProperty property ) { if ( property == null ) @@ -155,16 +200,16 @@ { return; } - for ( String expression : expressions ) + for ( String expression : unresolvedExpressions ) { if ( property.getKey().equals( expression ) ) { resolvedValue = resolvedValue.replace( property.getKey(), property.getValue() ); - expressions.clear(); + unresolvedExpressions.clear(); Matcher matcher = EXPRESSION_PATTERN.matcher( resolvedValue ); while ( matcher.find() ) { - expressions.add( matcher.group( 0 ) ); + unresolvedExpressions.add( matcher.group( 0 ) ); } break; } Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java Sat Jul 19 14:28:40 2008 @@ -28,7 +28,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.logging.Logger; /** @@ -37,13 +36,17 @@ public final class ModelTransformerContext { + /** + * Factories to use for construction of model containers + */ private final Collection factories; + /** + * List of system and environmental properties to use during interpolation + */ private final static List systemInterpolatorProperties = new ArrayList(); - private static Logger logger = Logger.getAnonymousLogger(); - static { for ( Map.Entry e : System.getProperties().entrySet() ) @@ -166,16 +169,17 @@ } } + /* for ( InterpolatorProperty ip : properties ) { for ( ModelProperty mp : unresolvedProperties ) { - // mp.resolveWith(ip); - // System.out.println(mp); - // System.out.println("-------------------"); + mp.resolveWith(ip); + System.out.println(mp); + System.out.println("-------------------"); } } - + */ mps = sort( mps, baseUriForModel ); try @@ -196,11 +200,11 @@ * Transforms and interpolates specified hierarchical list of domain models (inheritence) to target domain model. * Uses standard environmental and system properties for intepolation. * - * @param domainModels - * @param fromModelTransformer - * @param toModelTransformer - * @return - * @throws IOException + * @param domainModels the domain model list to transform + * @param fromModelTransformer transformer that transforms from specified domain models to canonical data model + * @param toModelTransformer transformer that transforms from canonical data model to returned domain model + * @return processed domain model + * @throws IOException if there was a problem with the transform */ public DomainModel transform( List domainModels, ModelTransformer fromModelTransformer, ModelTransformer toModelTransformer ) @@ -217,7 +221,7 @@ * a #collection (http://apache.org/model/project/dependencyManagement/dependencies#collection/dependency) * * @param properties unsorted list of model properties. List may not be null. - * @param baseUri + * @param baseUri the base URI of every model property * @return sorted list of model properties */ protected List sort( List properties, String baseUri ) Modified: maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java Sat Jul 19 14:28:40 2008 @@ -33,7 +33,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.logging.Logger; /** * Default implementation of the ModelDataSource. @@ -42,16 +41,36 @@ implements ModelDataSource { + /** + * List of current model properties underlying the data source + */ private List modelProperties; + /** + * Copy of the model properties used during initialization of the data source + */ private List originalModelProperties; - private List deleteEvents; + /** + * History of joins and deletes + */ + private List dataEvents; + /** + * Map of model container factories used in creation of model containers + */ private Map modelContainerFactoryMap; - private static Logger logger = Logger.getAnonymousLogger(); + /** + * Default constructor + */ + public DefaultModelDataSource() + { + } + /** + * @see ModelDataSource#join(org.apache.maven.shared.model.ModelContainer, org.apache.maven.shared.model.ModelContainer) + */ public ModelContainer join( ModelContainer a, ModelContainer b ) throws DataSourceException { @@ -75,8 +94,8 @@ } } - List des = new ArrayList(); - for ( DeleteEvent de : deleteEvents ) + List des = new ArrayList(); + for ( DataEvent de : dataEvents ) { if ( aContainsAnyOfB( de.getRemovedModelProperties(), unknownProperties ) ) { @@ -119,12 +138,15 @@ deletedProperties.removeAll( joinedProperties ); if ( deletedProperties.size() > 0 ) { - deleteEvents.add( new DeleteEvent( a, b, deletedProperties, "join" ) ); + dataEvents.add( new DataEvent( a, b, deletedProperties, "join" ) ); } return a.createNewInstance( joinedProperties ); } + /** + * @see ModelDataSource#delete(org.apache.maven.shared.model.ModelContainer) + */ public void delete( ModelContainer modelContainer ) { if ( modelContainer == null ) @@ -136,14 +158,20 @@ throw new IllegalArgumentException( "modelContainer.properties: null" ); } modelProperties.removeAll( modelContainer.getProperties() ); - deleteEvents.add( new DeleteEvent( modelContainer, null, modelContainer.getProperties(), "delete" ) ); + dataEvents.add( new DataEvent( modelContainer, null, modelContainer.getProperties(), "delete" ) ); } + /** + * @see org.apache.maven.shared.model.ModelDataSource#getModelProperties() + */ public List getModelProperties() { return new ArrayList( modelProperties ); } + /** + * @see ModelDataSource#queryFor(String) + */ public List queryFor( String uri ) throws DataSourceException { @@ -239,6 +267,9 @@ return modelContainers; } + /** + * @see ModelDataSource#init(java.util.List, java.util.Collection) + */ public void init( List modelProperties, Collection modelContainerFactories ) { if ( modelProperties == null ) @@ -251,7 +282,7 @@ } this.modelProperties = new LinkedList( modelProperties ); this.modelContainerFactoryMap = new HashMap(); - this.deleteEvents = new ArrayList(); + this.dataEvents = new ArrayList(); this.originalModelProperties = new ArrayList( modelProperties ); for ( ModelContainerFactory factory : modelContainerFactories ) @@ -269,6 +300,9 @@ } } + /** + * @see org.apache.maven.shared.model.ModelDataSource#getEventHistory() + */ public String getEventHistory() { StringBuffer sb = new StringBuffer(); @@ -278,7 +312,7 @@ sb.append( mp ).append( "\r\n" ); } - for ( DeleteEvent de : deleteEvents ) + for ( DataEvent de : dataEvents ) { sb.append( de.toString() ); } @@ -291,48 +325,6 @@ return sb.toString(); } - private List findUnknownModelPropertiesFrom( List modelContainers ) - { - List unknownProperties = new ArrayList(); - for ( ModelContainer mc : modelContainers ) - { - if ( !modelProperties.containsAll( mc.getProperties() ) ) - { - for ( ModelProperty mp : mc.getProperties() ) - { - if ( !modelProperties.contains( mp ) ) - { - unknownProperties.add( mp ); - } - } - } - } - return unknownProperties; - } - - private static int findLastIndexOfParent( ModelProperty modelProperty, List modelProperties ) - { - for ( int i = modelProperties.size() - 1; i >= 0; i-- ) - { - if ( modelProperties.get( i ).getUri().equals( modelProperty.getUri() ) ) - { - for ( int j = i; j < modelProperties.size(); j++ ) - { - if ( !modelProperties.get( j ).getUri().startsWith( modelProperty.getUri() ) ) - { - return j - 1; - } - } - return modelProperties.size() - 1; - } - else if ( modelProperties.get( i ).isParentOf( modelProperty ) ) - { - return i; - } - } - return -1; - } - /** * Removes duplicate model properties from the containers and return list. * @@ -380,6 +372,72 @@ return processedProperties; } + /** + * Returns list of model properties (from the specified list of model containers) that are not contained in the data + * source + * + * @param modelContainers the model containers (containing model properties) to check for unknown model properties + * @return list of model properties (from the specified list of model containers) that are not contained in the data + * source + */ + private List findUnknownModelPropertiesFrom( List modelContainers ) + { + List unknownProperties = new ArrayList(); + for ( ModelContainer mc : modelContainers ) + { + if ( !modelProperties.containsAll( mc.getProperties() ) ) + { + for ( ModelProperty mp : mc.getProperties() ) + { + if ( !modelProperties.contains( mp ) ) + { + unknownProperties.add( mp ); + } + } + } + } + return unknownProperties; + } + + /** + * Returns the last position of the uri of the specified model property (ModelProperty.getUri) from within the specified + * list of model properties. + * + * @param modelProperty the model property + * @param modelProperties the list of model properties used in determining the returned index + * @return the last position of the uri of the specified model property (ModelProperty.getUri) from within the specified + * list of model properties. + */ + private static int findLastIndexOfParent( ModelProperty modelProperty, List modelProperties ) + { + for ( int i = modelProperties.size() - 1; i >= 0; i-- ) + { + if ( modelProperties.get( i ).getUri().equals( modelProperty.getUri() ) ) + { + for ( int j = i; j < modelProperties.size(); j++ ) + { + if ( !modelProperties.get( j ).getUri().startsWith( modelProperty.getUri() ) ) + { + return j - 1; + } + } + return modelProperties.size() - 1; + } + else if ( modelProperties.get( i ).isParentOf( modelProperty ) ) + { + return i; + } + } + return -1; + } + + /** + * Returns true if specified list 'a' contains one or more elements of specified list 'b', otherwise returns false. + * + * @param a list of model containers + * @param b list of model containers + * @return true if specified list 'a' contains one or more elements of specified list 'b', otherwise returns false. + */ private static boolean aContainsAnyOfB( List a, List b ) { for ( ModelProperty mp : b ) @@ -392,7 +450,10 @@ return false; } - private static class DeleteEvent + /** + * Join or delete event + */ + private static class DataEvent { private List removedModelProperties; @@ -403,8 +464,8 @@ private String methodName; - DeleteEvent( ModelContainer mcA, ModelContainer mcB, List removedModelProperties, - String methodName ) + DataEvent( ModelContainer mcA, ModelContainer mcB, List removedModelProperties, + String methodName ) { this.mcA = mcA; this.mcB = mcB; Modified: maven/sandbox/trunk/shared/maven-shared-model/src/test/java/org/apache/maven/shared/model/impl/DefaultModelDataSourceTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-model/src/test/java/org/apache/maven/shared/model/impl/DefaultModelDataSourceTest.java?rev=678220&r1=678219&r2=678220&view=diff ============================================================================== --- maven/sandbox/trunk/shared/maven-shared-model/src/test/java/org/apache/maven/shared/model/impl/DefaultModelDataSourceTest.java (original) +++ maven/sandbox/trunk/shared/maven-shared-model/src/test/java/org/apache/maven/shared/model/impl/DefaultModelDataSourceTest.java Sat Jul 19 14:28:40 2008 @@ -430,10 +430,6 @@ return new DummyModelContainer( modelProperties ); } - public void sort( List modelProperties ) - { - - } } } }