1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 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.internal.core;
13 import net.sourceforge.phpdt.core.IBuffer;
14 import net.sourceforge.phpdt.core.ICompilationUnit;
15 import net.sourceforge.phpdt.core.WorkingCopyOwner;
18 * Wraps an IBufferFactory.
19 * TODO remove when removing IBufferFactory
22 public class BufferFactoryWrapper extends WorkingCopyOwner {
24 public net.sourceforge.phpdt.core.IBufferFactory factory;
26 private BufferFactoryWrapper(net.sourceforge.phpdt.core.IBufferFactory factory) {
27 this.factory = factory;
30 public static WorkingCopyOwner create(net.sourceforge.phpdt.core.IBufferFactory factory) {
31 return new BufferFactoryWrapper(factory);
35 * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit)
37 public IBuffer createBuffer(ICompilationUnit workingCopy) {
38 if (this.factory == null) return super.createBuffer(workingCopy);
39 return this.factory.createBuffer(workingCopy);
42 public boolean equals(Object obj) {
43 if (!(obj instanceof BufferFactoryWrapper)) return false;
44 BufferFactoryWrapper other = (BufferFactoryWrapper)obj;
45 if (this.factory == null) return other.factory == null;
46 return this.factory.equals(other.factory);
48 public int hashCode() {
49 if (this.factory == null) return 0;
50 return this.factory.hashCode();
52 public String toString() {
53 return "FactoryWrapper for " + this.factory; //$NON-NLS-1$