1 11 package org.eclipse.jdt.core.jdom; 12 13 import org.eclipse.jdt.internal.core.jdom.*; 14 15 25 public class DOMFactory implements IDOMFactory { 26 String lineSeparator; 27 30 public DOMFactory() { 31 this.lineSeparator = org.eclipse.jdt.internal.core.util.Util.getLineSeparator(null, null); 33 } 34 37 public IDOMCompilationUnit createCompilationUnit() { 38 return (new DOMBuilder()).createCompilationUnit(); 39 } 40 43 public IDOMCompilationUnit createCompilationUnit(char[] sourceCode, String name) { 44 if(sourceCode == null) { 45 return null; 46 } 47 return (new SimpleDOMBuilder()).createCompilationUnit(sourceCode, name.toCharArray()); 48 } 49 52 public IDOMCompilationUnit createCompilationUnit(String sourceCode, String name) { 53 if(sourceCode == null) { 54 return null; 55 } 56 return (new SimpleDOMBuilder()).createCompilationUnit(sourceCode.toCharArray(), name.toCharArray()); 57 } 58 61 public IDOMField createField() { 62 return createField("Object aField;"+ this.lineSeparator); } 64 67 public IDOMField createField(String sourceCode) { 68 if(sourceCode == null) { 69 return null; 70 } 71 return (new DOMBuilder()).createField(sourceCode.toCharArray()); 72 } 73 76 public IDOMImport createImport() { 77 return (new DOMBuilder()).createImport(); 78 } 79 82 public IDOMImport createImport(String sourceCode) { 83 if(sourceCode == null) { 84 return null; 85 } 86 return (new DOMBuilder()).createImport(sourceCode.toCharArray()); 87 } 88 91 public IDOMInitializer createInitializer() { 92 return createInitializer("static {}"+ this.lineSeparator); } 94 97 public IDOMInitializer createInitializer(String sourceCode) { 98 if(sourceCode == null) { 99 return null; 100 } 101 return (new DOMBuilder()).createInitializer(sourceCode.toCharArray()); 102 } 103 106 public IDOMMethod createMethod() { 107 return createMethod("public void newMethod() {"+ this.lineSeparator+"}"+ this.lineSeparator); } 109 112 public IDOMMethod createMethod(String sourceCode) { 113 if(sourceCode == null) { 114 return null; 115 } 116 return (new DOMBuilder()).createMethod(sourceCode.toCharArray()); 117 } 118 121 public IDOMPackage createPackage() { 122 return (new DOMBuilder()).createPackage(); 123 } 124 127 public IDOMPackage createPackage(String sourceCode) { 128 if(sourceCode == null) { 129 return null; 130 } 131 return (new DOMBuilder()).createPackage(sourceCode.toCharArray()); 132 } 133 136 public IDOMType createType() { 137 return createType("public class AClass {"+ this.lineSeparator +"}"+ this.lineSeparator); } 139 142 public IDOMType createClass() { 143 return createType("public class AClass {"+ this.lineSeparator +"}"+ this.lineSeparator); } 145 148 public IDOMType createInterface() { 149 return createType("public interface AnInterface {"+ this.lineSeparator +"}"+ this.lineSeparator); } 151 154 public IDOMType createType(String sourceCode) { 155 if(sourceCode == null) { 156 return null; 157 } 158 return (new DOMBuilder()).createType(sourceCode.toCharArray()); 159 } 160 } 161 | Popular Tags |