1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core.jdom;
13 import net.sourceforge.phpdt.internal.core.Util;
14 import net.sourceforge.phpdt.internal.core.jdom.DOMBuilder;
15 import net.sourceforge.phpdt.internal.core.jdom.SimpleDOMBuilder;
19 * Standard implementation of <code>IDOMFactory</code>, and the only means
20 * of creating JDOMs and document fragments.
22 * This class may be instantiated; it is not intended to be subclassed.
25 public class DOMFactory implements IDOMFactory {
27 * Creates a new DOM factory.
29 public DOMFactory() {}
31 * Method declared on IDOMFactory.
33 public IDOMCompilationUnit createCompilationUnit() {
34 return (new DOMBuilder()).createCompilationUnit();
37 * Method declared on IDOMFactory.
39 public IDOMCompilationUnit createCompilationUnit(char[] sourceCode, String name) {
40 if(sourceCode == null) {
43 return (new SimpleDOMBuilder()).createCompilationUnit(sourceCode, name.toCharArray());
46 * Method declared on IDOMFactory.
48 public IDOMCompilationUnit createCompilationUnit(String sourceCode, String name) {
49 if(sourceCode == null) {
52 return (new SimpleDOMBuilder()).createCompilationUnit(sourceCode.toCharArray(), name.toCharArray());
55 * Method declared on IDOMFactory.
57 //public IDOMField createField() {
58 // return createField("Object aField;"+ Util.LINE_SEPARATOR); //$NON-NLS-1$
61 // * Method declared on IDOMFactory.
63 //public IDOMField createField(String sourceCode) {
64 // if(sourceCode == null) {
67 // return (new DOMBuilder()).createField(sourceCode.toCharArray());
70 * Method declared on IDOMFactory.
72 //public IDOMImport createImport() {
73 // return (new DOMBuilder()).createImport();
76 // * Method declared on IDOMFactory.
78 //public IDOMImport createImport(String sourceCode) {
79 // if(sourceCode == null) {
82 // return (new DOMBuilder()).createImport(sourceCode.toCharArray());
85 * Method declared on IDOMFactory.
87 //public IDOMInitializer createInitializer() {
88 // return createInitializer("static {}"+ Util.LINE_SEPARATOR); //$NON-NLS-1$
91 // * Method declared on IDOMFactory.
93 //public IDOMInitializer createInitializer(String sourceCode) {
94 // if(sourceCode == null) {
97 // return (new DOMBuilder()).createInitializer(sourceCode.toCharArray());
100 * Method declared on IDOMFactory.
102 //public IDOMMethod createMethod() {
103 // return createMethod("public void newMethod() {"+ Util.LINE_SEPARATOR+"}"+ Util.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
106 // * Method declared on IDOMFactory.
108 //public IDOMMethod createMethod(String sourceCode) {
109 // if(sourceCode == null) {
112 // return (new DOMBuilder()).createMethod(sourceCode.toCharArray());
115 * Method declared on IDOMFactory.
117 public IDOMPackage createPackage() {
118 return (new DOMBuilder()).createPackage();
121 * Method declared on IDOMFactory.
123 //public IDOMPackage createPackage(String sourceCode) {
124 // if(sourceCode == null) {
127 // return (new DOMBuilder()).createPackage(sourceCode.toCharArray());
130 // * Method declared on IDOMFactory.
132 //public IDOMType createType() {
133 // return createType("public class AClass {"+ Util.LINE_SEPARATOR +"}"+ Util.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
136 * Method declared on IDOMFactory.
138 //public IDOMType createClass() {
139 // return createType("public class AClass {"+ Util.LINE_SEPARATOR +"}"+ Util.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
142 // * Method declared on IDOMFactory.
144 //public IDOMType createInterface() {
145 // return createType("public interface AnInterface {"+ Util.LINE_SEPARATOR +"}"+ Util.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
148 * Method declared on IDOMFactory.
150 //public IDOMType createType(String sourceCode) {
151 // if(sourceCode == null) {
154 // return (new DOMBuilder()).createType(sourceCode.toCharArray());