1 import java.io.File;
2 import java.io.FileWriter;
3 import java.io.IOException;
4 import java.io.Writer;
5
6 import org.exolab.castor.mapping.MappingException;
7 import org.exolab.castor.tools.MappingTool;
8
9 import org.astrogrid.registry.beans.v10.cea.CeaApplicationType;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 /***
25 * Small utility to generate a mapping file for the generated classes.
26 * @author Paul Harrison (pah@jb.man.ac.uk) 15-Mar-2004
27 * @version $Name: $
28 * @since iteration5
29 */
30 public class GenerateMapping {
31
32 MappingTool maptool;
33 private File outfile;
34 /***
35 *
36 */
37 public GenerateMapping(String filename) throws MappingException {
38
39 outfile=new File(filename);
40 maptool = new MappingTool();
41 maptool.setForceIntrospection(false);
42
43 maptool.addClass(CeaApplicationType.class, false);
44
45
46 }
47 public void writeMap()
48 {
49 Writer w;
50 try {
51 w = new FileWriter(outfile);
52 maptool.write(w);
53 }
54 catch (IOException e) {
55 e.printStackTrace();
56 } catch (MappingException e) {
57 e.printStackTrace();
58 }
59
60
61 }
62
63 /***
64 * @param args The first argument is the name of the output file to be generated
65 */
66 public static void main(String[] args) {
67 try {
68 GenerateMapping mapper = new GenerateMapping(args[0]);
69 mapper.writeMap();
70 }
71 catch (MappingException e) {
72
73 e.printStackTrace();
74 }
75
76 }
77
78 }