KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > BufferFactoryWrapper


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import org.eclipse.jdt.core.IBuffer;
14 import org.eclipse.jdt.core.ICompilationUnit;
15 import org.eclipse.jdt.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 org.eclipse.jdt.core.IBufferFactory factory;
25         
26     private BufferFactoryWrapper(org.eclipse.jdt.core.IBufferFactory factory) {
27         this.factory = factory;
28     }
29     
30     public static WorkingCopyOwner create(org.eclipse.jdt.core.IBufferFactory factory) {
31         return new BufferFactoryWrapper(factory);
32     }
33
34     /* (non-Javadoc)
35      * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.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 JavaDoc 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 JavaDoc toString() {
53         return "FactoryWrapper for " + this.factory; //$NON-NLS-1$
54
}
55 }
56
Popular Tags