improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / BufferFactoryWrapper.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
12
13 import net.sourceforge.phpdt.core.IBuffer;
14 import net.sourceforge.phpdt.core.ICompilationUnit;
15 import net.sourceforge.phpdt.core.WorkingCopyOwner;
16
17 /**
18  * Wraps an IBufferFactory.
19  * TODO remove when removing IBufferFactory
20  * @deprecated
21  */
22 public class BufferFactoryWrapper extends WorkingCopyOwner {
23
24         public net.sourceforge.phpdt.core.IBufferFactory factory;
25                 
26         private BufferFactoryWrapper(net.sourceforge.phpdt.core.IBufferFactory factory) {
27                 this.factory = factory;
28         }
29         
30         public static WorkingCopyOwner create(net.sourceforge.phpdt.core.IBufferFactory factory) {
31                 return new BufferFactoryWrapper(factory);
32         }
33
34         /* (non-Javadoc)
35          * @see net.sourceforge.phpdt.core.WorkingCopyOwner#createBuffer(net.sourceforge.phpdt.core.ICompilationUnit)
36          */
37         public IBuffer createBuffer(ICompilationUnit workingCopy) {
38                 if (this.factory == null) return super.createBuffer(workingCopy);
39                 return this.factory.createBuffer(workingCopy);
40         }       
41         
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);
47         }
48         public int hashCode() {
49                 if (this.factory == null) return 0;
50                 return this.factory.hashCode();
51         }
52         public String toString() {
53                 return "FactoryWrapper for " + this.factory; //$NON-NLS-1$
54         }
55 }