File: PCMLTask.java

package info (click to toggle)
libjt400-java 9.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 35,452 kB
  • sloc: java: 383,267; xml: 4,278; makefile: 14
file content (81 lines) | stat: -rw-r--r-- 2,808 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
///////////////////////////////////////////////////////////////////////////////
//                                                                             
// JTOpen (IBM Toolbox for Java - OSS version)                              
//                                                                             
// Filename: PCMLTask.java
//                                                                             
// The source code contained herein is licensed under the IBM Public License   
// Version 1.0, which has been approved by the Open Source Initiative.         
// Copyright (C) 1997-2002 International Business Machines Corporation and     
// others. All rights reserved.                                                
//                                                                             
///////////////////////////////////////////////////////////////////////////////
import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;
import org.apache.tools.ant.types.*;
import java.io.*;

/**
 * ANT task used to generate serialized PCML files.
**/
public class PCMLTask extends MatchingTask
{
  static final String copyright = "Copyright (C) 1997-2002 International Business Machines Corporation and others.";

  private File srcDir_;
  private File destDir_;
  private Path classpath_;

  public void setClasspath(Path s)
  {
    classpath_ = s;
  }

  public void setSrcdir(File srcDir)
  {
    srcDir_ = srcDir;
  }

  public void setDestdir(File destDir)
  {
    destDir_ = destDir;
  }

  public void execute() throws BuildException
  {
    DirectoryScanner scanner = getDirectoryScanner(srcDir_);
    String[] f = scanner.getIncludedFiles();
    
    Java java = (Java)project.createTask("java");
    java.clearArgs();
    java.setClassname("com.ibm.as400.data.ProgramCallDocument");
    java.setClasspath(classpath_);
    java.setFork(true); // Otherwise JDK 1.4 throws NoClassDefFoundError on sun/reflect/SerializationConstructorAccessorImpl
    Commandline.Argument arg1 = java.createArg();
    arg1.setValue("-serialize");
    Commandline.Argument arg2 = java.createArg();
    for (int i=0; i<f.length; ++i)
    {
      File source = new File(srcDir_, f[i]);
      File dest = new File(destDir_, f[i]+".ser");
      if (!dest.exists() ||
          (dest.exists() && dest.lastModified() < source.lastModified()))
      {
        System.out.println("Processing "+f[i]);
      
        String name = f[i].replace('\\', '.').replace('/', '.');
        arg2.setValue(name);
        java.execute();

        Move move = (Move)project.createTask("move");
        String outname = new File(f[i]).getName()+".ser";
        File outfile = new File(outname);
        move.setFile(outfile);
        move.setTofile(dest);
        move.execute();
      }
    }
  }
}