01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.text;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.pde.internal.core.text.plugin.DocumentGenericNode;
14:
15: /**
16: * DocumentNodeFactory
17: *
18: */
19: public abstract class DocumentNodeFactory implements
20: IDocumentNodeFactory {
21:
22: /**
23: *
24: */
25: public DocumentNodeFactory() {
26: // NO-OP
27: }
28:
29: /* (non-Javadoc)
30: * @see org.eclipse.pde.internal.core.text.IDocumentNodeFactory#createAttribute(java.lang.String, java.lang.String, org.eclipse.pde.internal.core.text.IDocumentElementNode)
31: */
32: public IDocumentAttributeNode createAttribute(String name,
33: String value, IDocumentElementNode enclosingElement) {
34:
35: IDocumentAttributeNode attribute = new DocumentAttributeNode();
36: try {
37: attribute.setAttributeName(name);
38: attribute.setAttributeValue(value);
39: } catch (CoreException e) {
40: // Ignore
41: }
42: attribute.setEnclosingElement(enclosingElement);
43: return attribute;
44: }
45:
46: /* (non-Javadoc)
47: * @see org.eclipse.pde.internal.core.text.IDocumentNodeFactory#createDocumentTextNode(java.lang.String, org.eclipse.pde.internal.core.text.IDocumentElementNode)
48: */
49: public IDocumentTextNode createDocumentTextNode(String content,
50: IDocumentElementNode parent) {
51: IDocumentTextNode textNode = new DocumentTextNode();
52: textNode.setEnclosingElement(parent);
53: parent.addTextNode(textNode);
54: textNode.setText(content);
55: return textNode;
56: }
57:
58: /* (non-Javadoc)
59: * @see org.eclipse.pde.internal.core.text.IDocumentNodeFactory#createDocumentNode(java.lang.String, org.eclipse.pde.internal.core.text.IDocumentElementNode)
60: */
61: public IDocumentElementNode createDocumentNode(String name,
62: IDocumentElementNode parent) {
63: // Cannot return null
64: return createGeneric(name);
65: }
66:
67: /**
68: * @param name
69: * @return
70: */
71: protected IDocumentElementNode createGeneric(String name) {
72: return new DocumentGenericNode(name);
73: }
74:
75: }
|