nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
amywu | 19526ad | 2007-04-10 17:03:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2004, 2005 IBM Corporation and others. |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 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 |
amywu | 19526ad | 2007-04-10 17:03:52 +0000 | [diff] [blame] | 7 | * |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.jst.jsp.core.internal.java; |
| 12 | |
| 13 | import org.eclipse.core.runtime.Platform; |
david_williams | 4ad020f | 2005-04-18 08:00:30 +0000 | [diff] [blame] | 14 | import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory; |
| 15 | import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; |
| 16 | import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory; |
| 17 | import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; |
| 18 | import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * Factory for JSPTranslationAdapters. |
| 22 | * |
| 23 | * @author pavery |
| 24 | * |
| 25 | */ |
| 26 | public class JSPTranslationAdapterFactory extends AbstractAdapterFactory { |
| 27 | |
| 28 | private JSPTranslationAdapter fAdapter = null; |
| 29 | |
| 30 | // for debugging |
nitind | a8d33f2 | 2007-04-16 23:03:50 +0000 | [diff] [blame] | 31 | static final boolean DEBUG = Boolean.valueOf(Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jsptranslation")).booleanValue(); //$NON-NLS-1$; |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 32 | |
| 33 | public JSPTranslationAdapterFactory() { |
david_williams | 6f9dcdd | 2005-10-09 05:14:55 +0000 | [diff] [blame] | 34 | super(IJSPTranslation.class, true); |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 35 | } |
| 36 | |
david_williams | 285ee2d | 2005-04-10 18:21:21 +0000 | [diff] [blame] | 37 | public INodeAdapterFactory copy() { |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 38 | return new JSPTranslationAdapterFactory(); |
| 39 | } |
| 40 | |
| 41 | protected INodeAdapter createAdapter(INodeNotifier target) { |
david_williams | c39caaf | 2005-04-05 06:07:16 +0000 | [diff] [blame] | 42 | if (target instanceof IDOMNode && fAdapter == null) { |
| 43 | fAdapter = new JSPTranslationAdapter(((IDOMNode) target).getModel()); |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 44 | if(DEBUG) { |
david_williams | e3f4661 | 2005-04-07 01:12:35 +0000 | [diff] [blame] | 45 | System.out.println("(+) JSPTranslationAdapterFactory [" + this + "] created adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$ |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | return fAdapter; |
| 49 | } |
| 50 | |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 51 | |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 52 | public void release() { |
| 53 | if (fAdapter != null) { |
| 54 | if(DEBUG) { |
david_williams | e3f4661 | 2005-04-07 01:12:35 +0000 | [diff] [blame] | 55 | System.out.println("(-) JSPTranslationAdapterFactory [" + this + "] releasing adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$ |
nitind | b0f7b26 | 2004-11-23 19:12:23 +0000 | [diff] [blame] | 56 | } |
| 57 | fAdapter.release(); |
| 58 | } |
| 59 | super.release(); |
| 60 | } |
amywu | 19526ad | 2007-04-10 17:03:52 +0000 | [diff] [blame] | 61 | } |