ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model ModelElementUtil.java
Date Tue, 04 Jun 2002 12:36:44 GMT
adammurdoch    2002/06/04 05:36:44

  Modified:    container/src/java/org/apache/myrmidon/interfaces/model
                        ModelElementUtil.java
  Log:
  Added another copyModel() method.
  
  Revision  Changes    Path
  1.3       +17 -10    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/ModelElementUtil.java
  
  Index: ModelElementUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/ModelElementUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModelElementUtil.java	2 Jun 2002 04:59:40 -0000	1.2
  +++ ModelElementUtil.java	4 Jun 2002 12:36:44 -0000	1.3
  @@ -19,7 +19,7 @@
    * Utility methods for dealing with {@link org.apache.myrmidon.api.metadata.ModelElement}
objects.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/06/02 04:59:40 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/04 12:36:44 $
    */
   public class ModelElementUtil
   {
  @@ -62,25 +62,32 @@
        */
       public static ModelElement copyModel( final ModelElement model )
       {
  -        final ModelElement newElement =
  +        final ModelElement newModel =
               new ModelElement( model.getName(), model.getLocation() );
  +        copyModel( model, newModel );
  +        return newModel;
  +    }
   
  -        final String[] attributes = model.getAttributeNames();
  +    /**
  +     * Makes a shallow copy of a model.
  +     */
  +    public static void copyModel( final ModelElement srcModel,
  +                                  final ModelElement destModel )
  +    {
  +        final String[] attributes = srcModel.getAttributeNames();
           for( int i = 0; i < attributes.length; i++ )
           {
               final String name = attributes[ i ];
  -            final String value = model.getAttribute( name );
  -            newElement.setAttribute( name, value );
  +            final String value = srcModel.getAttribute( name );
  +            destModel.setAttribute( name, value );
           }
   
  -        final ModelElement[] children = model.getChildren();
  +        final ModelElement[] children = srcModel.getChildren();
           for( int i = 0; i < children.length; i++ )
           {
  -            newElement.addChild( children[ i ] );
  +            destModel.addChild( children[ i ] );
           }
   
  -        newElement.setContent( model.getContent() );
  -
  -        return newElement;
  +        destModel.setContent( srcModel.getContent() );
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message