blob: dbe0b4eba0dc35581098586fc5aadc80dfde814f [file] [log] [blame]
nitindb0f7b262004-11-23 19:12:23 +00001/*******************************************************************************
amywu19526ad2007-04-10 17:03:52 +00002 * Copyright (c) 2004, 2005 IBM Corporation and others.
nitindb0f7b262004-11-23 19:12:23 +00003 * 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
amywu19526ad2007-04-10 17:03:52 +00007 *
nitindb0f7b262004-11-23 19:12:23 +00008 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.jst.jsp.core.internal.java;
12
13import org.eclipse.core.runtime.Platform;
david_williams4ad020f2005-04-18 08:00:30 +000014import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
15import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
16import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
17import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
18import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
nitindb0f7b262004-11-23 19:12:23 +000019
20/**
21 * Factory for JSPTranslationAdapters.
22 *
23 * @author pavery
24 *
25 */
26public class JSPTranslationAdapterFactory extends AbstractAdapterFactory {
27
28 private JSPTranslationAdapter fAdapter = null;
29
30 // for debugging
nitinda8d33f22007-04-16 23:03:50 +000031 static final boolean DEBUG = Boolean.valueOf(Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jsptranslation")).booleanValue(); //$NON-NLS-1$;
nitindb0f7b262004-11-23 19:12:23 +000032
33 public JSPTranslationAdapterFactory() {
david_williams6f9dcdd2005-10-09 05:14:55 +000034 super(IJSPTranslation.class, true);
nitindb0f7b262004-11-23 19:12:23 +000035 }
36
david_williams285ee2d2005-04-10 18:21:21 +000037 public INodeAdapterFactory copy() {
nitindb0f7b262004-11-23 19:12:23 +000038 return new JSPTranslationAdapterFactory();
39 }
40
41 protected INodeAdapter createAdapter(INodeNotifier target) {
david_williamsc39caaf2005-04-05 06:07:16 +000042 if (target instanceof IDOMNode && fAdapter == null) {
43 fAdapter = new JSPTranslationAdapter(((IDOMNode) target).getModel());
nitindb0f7b262004-11-23 19:12:23 +000044 if(DEBUG) {
david_williamse3f46612005-04-07 01:12:35 +000045 System.out.println("(+) JSPTranslationAdapterFactory [" + this + "] created adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$
nitindb0f7b262004-11-23 19:12:23 +000046 }
47 }
48 return fAdapter;
49 }
50
nitindb0f7b262004-11-23 19:12:23 +000051
nitindb0f7b262004-11-23 19:12:23 +000052 public void release() {
53 if (fAdapter != null) {
54 if(DEBUG) {
david_williamse3f46612005-04-07 01:12:35 +000055 System.out.println("(-) JSPTranslationAdapterFactory [" + this + "] releasing adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$
nitindb0f7b262004-11-23 19:12:23 +000056 }
57 fAdapter.release();
58 }
59 super.release();
60 }
amywu19526ad2007-04-10 17:03:52 +000061}