Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Problem with the defined collection.

Problem with the defined collection.

2005-05-19       - By Siwiec, Tomasz

Dear All,
I have a problem with my own collection of objects that I pass to my
task.
I have a AntFileInfoSet collection that store AntFileInfo objects (both
of them inherits from ProjectComponent).
The AntFileInfoSet looks like that:

public class AntFileInfoSet extends ProjectComponent {
   private String refid = null;
   private List antFileInfos = new ArrayList();

   public void setRefid(String refid) {... }

   public void addFile(AntFileInfo afi) {
       this.antFileInfos.add(afi);
   }
   public List getAntFileInfos() {
       if (refid != null) {
           return ((AntFileInfoSet)
getProject().getReference(refid)).getAntFileInfos(); (HERE I KEEP
GETTING ClassCastException)
       } else {
           return antFileInfos;
       }
   }
}

The type & task definitions looks like that:
   <taskdef name="myTask" classname="com...MyTask"
classpathref="std.classpath"/>
   <typedef name="download_files" classname="com.....AntFileInfoSet"
classpathref="std.classpath"/>
   <typedef name="file" classname="com.....AntFileInfo"
classpathref="std.classpath"/>
   ...
   <myTask .......>        
<download_files id="flashline.flieInfos">
              <file name="xxx" .../>
              <file name="xxx" .../>
           </download_files>
   </myTask>
   ...

The way I use it in my task is:
public class MyTask extends Task {
   ....
   private AntFileInfoSet antFileInfoSet = null;
   .....
   public void addDownload_files(AntFileInfoSet afis) {
       antFileInfoSet = afis;
   }

  public void execute() {
  ...
  List antFileInfoList = antFileInfoSet.getAntFileInfos();  (HERE
I KEEP GETTING above Exception)
...  
  }

The main problem is I can't debug this problem as it works ok under
InteliJ (there is no ClasscastException) but it doesn't outside. I use
Ant 1.6.2.
Do you have any idea?
Regards,
Tomasz

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.