Re: cvs commit: ant/src/main/org/apache/tools/ant/util CollectionUtils.java

2005-03-16 Thread Steve Loughran
Matt Benson wrote:
--- [EMAIL PROTECTED] wrote:
peterreilly2005/03/14 01:14:56
 Modified:src/main/org/apache/tools/ant/util
CollectionUtils.java
 Log:
 allow ant to compile with ant 1.5 again.

Oops!  :)  Thanks!

aah, it happens. my work project broke yesterday as someone added an int 
state variable with accessors on a class that extended Thread. But on 
java1.5,  there is an enum  State getState() in class thread. So no compile.

And the week before, I put Boolean.valueOf(): boolean into code and 
broken Java1.4 builds. The 1.5 transition  is   not  an easy one.

-S.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


cvs commit: ant/src/main/org/apache/tools/ant/util CollectionUtils.java

2005-03-14 Thread peterreilly
peterreilly2005/03/14 01:14:56

  Modified:src/main/org/apache/tools/ant/util CollectionUtils.java
  Log:
  allow ant to compile with ant 1.5 again.
  
  Revision  ChangesPath
  1.18  +4 -4  
ant/src/main/org/apache/tools/ant/util/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/util/CollectionUtils.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- CollectionUtils.java  10 Mar 2005 21:16:08 -  1.17
  +++ CollectionUtils.java  14 Mar 2005 09:14:56 -  1.18
  @@ -158,16 +158,16 @@
   
   /**
* Adapt the specified Enumeration to the Iterator interface.
  - * @param enum the Enumeration to adapt.
  + * @param e the Enumeration to adapt.
* @return an Iterator.
*/
  -public static Iterator asIterator(final Enumeration enum) {
  +public static Iterator asIterator(final Enumeration e) {
   return new Iterator() {
   public boolean hasNext() {
  -return enum.hasMoreElements();
  +return e.hasMoreElements();
   }
   public Object next() {
  -return enum.nextElement();
  +return e.nextElement();
   }
   public void remove() {
   throw new UnsupportedOperationException();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: ant/src/main/org/apache/tools/ant/util CollectionUtils.java

2005-03-10 Thread mbenson
mbenson 2005/03/10 13:16:08

  Modified:.WHATSNEW
   src/main/org/apache/tools/ant/taskdefs/optional
EchoProperties.java
   src/main/org/apache/tools/ant/util CollectionUtils.java
  Log:
  Sort echoproperties output in text mode as well as XML.
  PR: 18976
  
  Revision  ChangesPath
  1.770 +1 -1  ant/WHATSNEW
  
  Index: WHATSNEW
  ===
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.769
  retrieving revision 1.770
  diff -u -r1.769 -r1.770
  --- WHATSNEW  10 Mar 2005 16:13:54 -  1.769
  +++ WHATSNEW  10 Mar 2005 21:16:07 -  1.770
  @@ -67,7 +67,7 @@
   --
   
   * echoproperties now (alphanumerically) sorts the property list
  -  before echoing, when you request XML output (format=xml). 
  +  before echoing. Bugzilla report 18976.
   
   * A new base class DispatchTask has been added to facilitate elegant 
 creation of tasks with multiple actions.
  
  
  
  1.30  +11 -7 
ant/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
  
  Index: EchoProperties.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- EchoProperties.java   9 Mar 2005 23:38:22 -   1.29
  +++ EchoProperties.java   10 Mar 2005 21:16:08 -  1.30
  @@ -325,15 +325,19 @@
[EMAIL PROTECTED]  IOException  trouble
*/
   protected void saveProperties(Hashtable allProps, OutputStream os)
  - throws IOException, BuildException {
  -Properties props = new Properties();
  -Enumeration e = allProps.keys();
  -while (e.hasMoreElements()) {
  -String name = e.nextElement().toString();
  +throws IOException, BuildException {
  +final List keyList = new ArrayList(allProps.keySet());
  +Collections.sort(keyList);
  +Properties props = new Properties() {
  +public Enumeration keys() {
  +return CollectionUtils.asEnumeration(keyList.iterator());
  +}
  +};
  +for (int i = 0; i  keyList.size(); i++) {
  +String name = keyList.get(i).toString();
   String value = allProps.get(name).toString();
  -props.put(name, value);
  +props.setProperty(name, value);
   }
  -
   if (text.equals(format)) {
   jdkSaveProperties(props, os, Ant properties);
   } else if (xml.equals(format)) {
  
  
  
  1.17  +37 -1 
ant/src/main/org/apache/tools/ant/util/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/util/CollectionUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CollectionUtils.java  24 Jan 2005 18:13:20 -  1.16
  +++ CollectionUtils.java  10 Mar 2005 21:16:08 -  1.17
  @@ -16,10 +16,11 @@
*/
   package org.apache.tools.ant.util;
   
  +import java.util.Vector;
  +import java.util.Iterator;
   import java.util.Dictionary;
   import java.util.Enumeration;
   import java.util.NoSuchElementException;
  -import java.util.Vector;
   
   /**
* A set of helper methods related to collection manipulation.
  @@ -139,6 +140,41 @@
   return new CompoundEnumeration(e1, e2);
   }
   
  +/**
  + * Adapt the specified Iterator to the Enumeration interface.
  + * @param iter the Iterator to adapt.
  + * @return an Enumeration.
  + */
  +public static Enumeration asEnumeration(final Iterator iter) {
  +return new Enumeration() {
  +public boolean hasMoreElements() {
  +return iter.hasNext();
  +}
  +public Object nextElement() {
  +return iter.next();
  +}
  +};
  +}
  +
  +/**
  + * Adapt the specified Enumeration to the Iterator interface.
  + * @param enum the Enumeration to adapt.
  + * @return an Iterator.
  + */
  +public static Iterator asIterator(final Enumeration enum) {
  +return new Iterator() {
  +public boolean hasNext() {
  +return enum.hasMoreElements();
  +}
  +public Object next() {
  +return enum.nextElement();
  +}
  +public void remove() {
  +throw new UnsupportedOperationException();
  +}
  +};
  +}
  +
   private static final class CompoundEnumeration implements Enumeration {
   
   private final Enumeration e1, e2;
  
  
  


cvs commit: ant/src/main/org/apache/tools/ant/util CollectionUtils.java

2003-08-13 Thread peterreilly
peterreilly2003/08/13 07:22:29

  Modified:src/main/org/apache/tools/ant/types XMLCatalog.java
   src/main/org/apache/tools/ant/util CollectionUtils.java
  Log:
  some 1.1 isms
  PR: 22326
  Obtained from: Martijn Kruithof
  
  Revision  ChangesPath
  1.31  +1 -4  ant/src/main/org/apache/tools/ant/types/XMLCatalog.java
  
  Index: XMLCatalog.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- XMLCatalog.java   6 Aug 2003 14:35:03 -   1.30
  +++ XMLCatalog.java   13 Aug 2003 14:22:29 -  1.31
  @@ -58,7 +58,6 @@
   
   import java.io.File;
   import java.io.FileInputStream;
  -import java.io.FileNotFoundException;
   import java.io.IOException;
   import java.io.InputStream;
   import java.net.MalformedURLException;
  @@ -711,8 +710,6 @@
   source.setSystemId(sysid);
   log(catalog entry matched a readable file: '
   + sysid + ', Project.MSG_DEBUG);
  -} catch (FileNotFoundException ex) {
  -// ignore
   } catch (IOException ex) {
   // ignore
   }
  
  
  
  1.10  +9 -19 
ant/src/main/org/apache/tools/ant/util/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/util/CollectionUtils.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CollectionUtils.java  19 Jul 2003 08:11:08 -  1.9
  +++ CollectionUtils.java  13 Aug 2003 14:22:29 -  1.10
  @@ -63,15 +63,17 @@
*
* @author Stefan Bodewig
* @author a href=mailto:[EMAIL PROTECTED]Ingmar Stein/a
  + * @author  a href=mailto:[EMAIL PROTECTED]Martijn Kruithof/a
*
* @since Ant 1.5
*/
   public class CollectionUtils {
   
   /**
  - * Vector.equals() doesn't do any good in 1.1
  + * Please use Vector.equals() or List.equals() 
*
* @since Ant 1.5
  + * @deprecated
*/
   public static boolean equals(Vector v1, Vector v2) {
   if (v1 == v2) {
  @@ -82,30 +84,17 @@
   return false;
   }
   
  -if (v1.size() != v2.size()) {
  -return false;
  -}
  -
  -Enumeration e1 = v1.elements();
  -Enumeration e2 = v2.elements();
  -while (e1.hasMoreElements()) {
  -if (!e1.nextElement().equals(e2.nextElement())) {
  -return false;
  -}
  -}
  -
  -// don't need to check e2.hasMoreElements as the Vectors have
  -// same size.
  -
  -return true;
  +return v1.equals(v2);
   }
   
   /**
  - * Hashtable.equals() doesn't do any good in 1.1.
  + * Dictionary does not have an equals.
  + * Please use  Map.equals()
*
* pFollows the equals contract of Java 2's Map./p
*
* @since Ant 1.5
  + * @deprecated
*/
   public static boolean equals(Dictionary d1, Dictionary d2) {
   if (d1 == d2) {
  @@ -137,9 +126,10 @@
   }
   
   /**
  - * JDK 1.1 does not know the putAll method for hash tables.
  + * Dictionary does not know the putAll method. Please use Map.putAll().
*
* @since Ant 1.6
  + * @deprecated
*/
   public static void putAll(Dictionary m1, Dictionary m2) {
   for (Enumeration it = m2.keys(); it.hasMoreElements();) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: ant/src/main/org/apache/tools/ant/util CollectionUtils.java

2003-07-07 Thread bodewig
bodewig 2003/07/07 01:20:52

  Modified:src/main/org/apache/tools/ant RuntimeConfigurable.java
Target.java
   src/main/org/apache/tools/ant/util CollectionUtils.java
  Log:
  Move EmptyEnumeration to CollectionUtils
  
  Revision  ChangesPath
  1.39  +2 -12 
ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java
  
  Index: RuntimeConfigurable.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- RuntimeConfigurable.java  6 Jul 2003 09:57:34 -   1.38
  +++ RuntimeConfigurable.java  7 Jul 2003 08:20:52 -   1.39
  @@ -63,8 +63,8 @@
   import java.util.List;
   import java.util.Locale;
   import java.util.Map;
  -import java.util.NoSuchElementException;
   
  +import org.apache.tools.ant.util.CollectionUtils;
   import org.xml.sax.AttributeList;
   import org.xml.sax.helpers.AttributeListImpl;
   
  @@ -236,17 +236,7 @@
   if (children != null) {
   return Collections.enumeration(children);
   } else {
  -return new EmptyEnumeration();
  -}
  -}
  -
  -static final class EmptyEnumeration implements Enumeration {
  -public EmptyEnumeration() {}
  -public boolean hasMoreElements() {
  -return false;
  -}
  -public Object nextElement() throws NoSuchElementException {
  -throw new NoSuchElementException();
  +return new CollectionUtils.EmptyEnumeration();
   }
   }
   
  
  
  
  1.39  +3 -1  ant/src/main/org/apache/tools/ant/Target.java
  
  Index: Target.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Target.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Target.java   6 Jul 2003 09:57:34 -   1.38
  +++ Target.java   7 Jul 2003 08:20:52 -   1.39
  @@ -61,6 +61,8 @@
   import java.util.List;
   import java.util.StringTokenizer;
   
  +import org.apache.tools.ant.util.CollectionUtils;
  +
   /**
* Class to implement a target object with required parameters.
*
  @@ -222,7 +224,7 @@
   if (dependencies != null) {
   return Collections.enumeration(dependencies);
   } else {
  -return new RuntimeConfigurable.EmptyEnumeration();
  +return new CollectionUtils.EmptyEnumeration();
   }
   }
   
  
  
  
  1.7   +16 -1 
ant/src/main/org/apache/tools/ant/util/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/util/CollectionUtils.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CollectionUtils.java  7 Mar 2003 11:23:08 -   1.6
  +++ CollectionUtils.java  7 Jul 2003 08:20:52 -   1.7
  @@ -1,7 +1,7 @@
   /*
* The Apache Software License, Version 1.1
*
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
  @@ -55,6 +55,7 @@
   
   import java.util.Dictionary;
   import java.util.Enumeration;
  +import java.util.NoSuchElementException;
   import java.util.Vector;
   
   /**
  @@ -146,4 +147,18 @@
   m1.put(key, m2.get(key));
   }
   }
  +
  +/**
  + * @since Ant 1.6
  + */
  +public static final class EmptyEnumeration implements Enumeration {
  +public EmptyEnumeration() {}
  +public boolean hasMoreElements() {
  +return false;
  +}
  +public Object nextElement() throws NoSuchElementException {
  +throw new NoSuchElementException();
  +}
  +}
  +
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]