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.jdom.DOMBuilder;
14 import net.sourceforge.phpdt.internal.core.jdom.SimpleDOMBuilder;
17 * Standard implementation of <code>IDOMFactory</code>, and the only means of
18 * creating JDOMs and document fragments.
20 * This class may be instantiated; it is not intended to be subclassed.
23 public class DOMFactory implements IDOMFactory {
25 * Creates a new DOM factory.
31 * (non-Javadoc) Method declared on IDOMFactory.
33 public IDOMCompilationUnit createCompilationUnit() {
34 return (new DOMBuilder()).createCompilationUnit();
38 * (non-Javadoc) Method declared on IDOMFactory.
40 public IDOMCompilationUnit createCompilationUnit(char[] sourceCode,
42 if (sourceCode == null) {
45 return (new SimpleDOMBuilder()).createCompilationUnit(sourceCode, name
50 * (non-Javadoc) Method declared on IDOMFactory.
52 public IDOMCompilationUnit createCompilationUnit(String sourceCode,
54 if (sourceCode == null) {
57 return (new SimpleDOMBuilder()).createCompilationUnit(sourceCode
58 .toCharArray(), name.toCharArray());
62 * (non-Javadoc) Method declared on IDOMFactory.
64 // public IDOMField createField() {
65 // return createField("Object aField;"+ ProjectPrefUtil.LINE_SEPARATOR);
69 // * Method declared on IDOMFactory.
71 // public IDOMField createField(String sourceCode) {
72 // if(sourceCode == null) {
75 // return (new DOMBuilder()).createField(sourceCode.toCharArray());
78 * (non-Javadoc) Method declared on IDOMFactory.
80 // public IDOMImport createImport() {
81 // return (new DOMBuilder()).createImport();
84 // * Method declared on IDOMFactory.
86 // public IDOMImport createImport(String sourceCode) {
87 // if(sourceCode == null) {
90 // return (new DOMBuilder()).createImport(sourceCode.toCharArray());
93 * (non-Javadoc) Method declared on IDOMFactory.
95 // public IDOMInitializer createInitializer() {
96 // return createInitializer("static {}"+ ProjectPrefUtil.LINE_SEPARATOR);
100 // * Method declared on IDOMFactory.
102 // public IDOMInitializer createInitializer(String sourceCode) {
103 // if(sourceCode == null) {
106 // return (new DOMBuilder()).createInitializer(sourceCode.toCharArray());
109 * (non-Javadoc) Method declared on IDOMFactory.
111 // public IDOMMethod createMethod() {
112 // return createMethod("public void newMethod() {"+
113 // ProjectPrefUtil.LINE_SEPARATOR+"}"+ ProjectPrefUtil.LINE_SEPARATOR);
114 // //$NON-NLS-2$ //$NON-NLS-1$
117 // * Method declared on IDOMFactory.
119 // public IDOMMethod createMethod(String sourceCode) {
120 // if(sourceCode == null) {
123 // return (new DOMBuilder()).createMethod(sourceCode.toCharArray());
126 * (non-Javadoc) Method declared on IDOMFactory.
128 public IDOMPackage createPackage() {
129 return (new DOMBuilder()).createPackage();
132 * (non-Javadoc) Method declared on IDOMFactory.
134 // public IDOMPackage createPackage(String sourceCode) {
135 // if(sourceCode == null) {
138 // return (new DOMBuilder()).createPackage(sourceCode.toCharArray());
141 // * Method declared on IDOMFactory.
143 // public IDOMType createType() {
144 // return createType("public class AClass {"+ ProjectPrefUtil.LINE_SEPARATOR
145 // +"}"+ ProjectPrefUtil.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
148 * (non-Javadoc) Method declared on IDOMFactory.
150 // public IDOMType createClass() {
151 // return createType("public class AClass {"+ ProjectPrefUtil.LINE_SEPARATOR
152 // +"}"+ ProjectPrefUtil.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
155 // * Method declared on IDOMFactory.
157 // public IDOMType createInterface() {
158 // return createType("public interface AnInterface {"+
159 // ProjectPrefUtil.LINE_SEPARATOR +"}"+ ProjectPrefUtil.LINE_SEPARATOR);
160 // //$NON-NLS-2$ //$NON-NLS-1$
163 * (non-Javadoc) Method declared on IDOMFactory.
165 // public IDOMType createType(String sourceCode) {
166 // if(sourceCode == null) {
169 // return (new DOMBuilder()).createType(sourceCode.toCharArray());