| 1 package org.myoodb.tools.generator; 25 26 import java.util.*; 27 import java.io.File ; 28 29 import org.myoodb.core.*; 30 31 public class Main 32 { 33 public static void main(String [] args) throws Exception  34 { 35 if (args.length < 2) 36 { 37 throw new GeneratorException("invalid generator arguments { usage: main [--nobean] -s<sourcepath> [interface files]* }"); 38 } 39 40 int startIndex = 1; 42 boolean javaBean = true; 43 String sourcePath = null; 44 45 for (int i = 0; i < 2; i++) 46 { 47 int index = args[i].indexOf("-s"); 48 if ((index == 0) && (args[i].length() > 2)) 49 { 50 sourcePath = args[i].substring(index + 2, args[i].length()); 51 } 52 53 index = args[i].indexOf("-nobean"); 54 if (index == 0) 55 { 56 javaBean = false; 57 startIndex = 2; 58 } 59 } 60 61 if (sourcePath == null) 62 { 63 throw new GeneratorException("invalid generator arguments { usage: main [--nobean] -s<sourcepath> [interface files]* }"); 64 } 65 66 for (int i = startIndex; i < args.length; i++) 67 { 68 System.out.println(" Processing interface: " + args[i]); 69 70 HashMap methods = new HashMap(); 71 Helper.searchForMethods(sourcePath, args[i], methods); 72 73 ProxyGenerator proxyGen = new ProxyGenerator(); 77 proxyGen.beginClass(sourcePath, args[i]); 78 79 Iterator iter = methods.keySet().iterator(); 80 while (iter.hasNext()) 81 { 82 String methodName = (String ) iter.next(); 83 Integer accessLevel = (Integer ) methods.get(methodName); 84 if (accessLevel.intValue() == Lock.ACCESS_READ) 85 { 86 System.out.println(" - Method: (R) " + methodName); 87 proxyGen.makeMethod(methodName, Lock.ACCESS_READ); 88 } 89 else 90 { 91 System.out.println(" - Method: (W) " + methodName); 92 proxyGen.makeMethod(methodName, Lock.ACCESS_WRITE); 93 } 94 } 95 96 proxyGen.endClass(); 97 98 if (javaBean == true) 102 { 103 BeanGenerator beanGen = new BeanGenerator(); 104 beanGen.beginClass(sourcePath, args[i]); 105 106 iter = methods.keySet().iterator(); 107 while (iter.hasNext()) 108 { 109 String methodName = (String ) iter.next(); 110 Integer accessLevel = (Integer ) methods.get(methodName); 111 if (accessLevel.intValue() == Lock.ACCESS_READ) 112 { 113 System.out.println(" - Method: (R) " + methodName); 114 beanGen.makeMethod(methodName, Lock.ACCESS_READ); 115 } 116 else 117 { 118 System.out.println(" - Method: (W) " + methodName); 119 beanGen.makeMethod(methodName, Lock.ACCESS_WRITE); 120 } 121 } 122 123 beanGen.endClass(); 124 } 125 } 126 } 127 } 128 | Popular Tags |