Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 29 30 package com.caucho.java.gen; 31 32 import com.caucho.java.JavaWriter; 33 import com.caucho.util.L10N; 34 35 import java.io.IOException ; 36 import java.util.ArrayList ; 37 38 41 public class GenClass extends BaseClass { 42 private static L10N L = new L10N(GenClass.class); 43 44 private String _packageName; 45 private String _fullClassName; 46 47 private ArrayList <String > _importList = new ArrayList <String >(); 48 49 52 public GenClass(String fullClassName) 53 { 54 _fullClassName = fullClassName; 55 56 int p = fullClassName.lastIndexOf('.'); 57 58 if (p > 0) { 59 _packageName = fullClassName.substring(0, p); 60 setClassName(fullClassName.substring(p + 1)); 61 } 62 else { 63 throw new IllegalArgumentException (L.l("Class '{0}' must belong to a package.", 64 fullClassName)); 65 } 66 } 67 68 71 public String getFullClassName() 72 { 73 return _fullClassName; 74 } 75 76 79 public String getPackageName() 80 { 81 return _packageName; 82 } 83 84 87 public void addImport(String importName) 88 { 89 if (! _importList.contains(importName)) 90 _importList.add(importName); 91 } 92 93 96 public void generate(JavaWriter out) 97 throws IOException  98 { 99 generateTopComment(out); 100 101 if (_packageName != null) { 102 out.println(); 103 out.println("package " + _packageName + ";"); 104 } 105 106 if (_importList.size() > 0) { 107 out.println(); 108 109 for (int i = 0; i < _importList.size(); i++) { 110 out.println("import " + _importList.get(i) + ";"); 111 } 112 } 113 114 out.println(); 115 116 super.generate(out); 117 } 118 119 122 protected void generateTopComment(JavaWriter out) 123 throws IOException  124 { 125 out.println("/*"); 126 out.println(" * Generated by " + com.caucho.Version.FULL_VERSION); 127 out.println(" */"); 128 } 129 } 130
| Popular Tags
|