david_williams | cfdb2cd | 2004-11-11 08:37:49 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2001, 2004 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 | * Jens Lukowski/Innoopract - initial renaming/restructuring |
| 11 | * |
| 12 | *******************************************************************************/ |
david_williams | 2e7166e | 2005-04-13 05:28:38 +0000 | [diff] [blame] | 13 | package org.eclipse.wst.sse.core.internal.ltk.modelhandler; |
david_williams | cfdb2cd | 2004-11-11 08:37:49 +0000 | [diff] [blame] | 14 | |
| 15 | import java.util.ArrayList; |
| 16 | import java.util.Collection; |
| 17 | import java.util.List; |
| 18 | |
david_williams | 7a65dc2 | 2005-04-09 02:19:50 +0000 | [diff] [blame] | 19 | import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector; |
david_williams | cfdb2cd | 2004-11-11 08:37:49 +0000 | [diff] [blame] | 20 | import org.eclipse.wst.sse.core.internal.modelhandler.PluginContributedFactoryReader; |
| 21 | |
david_williams | 1b04516 | 2005-03-17 22:25:26 +0000 | [diff] [blame] | 22 | /** |
| 23 | * ISSUE: need to provide this functionality in improved API. |
| 24 | */ |
david_williams | cfdb2cd | 2004-11-11 08:37:49 +0000 | [diff] [blame] | 25 | |
| 26 | public abstract class AbstractModelHandler implements IModelHandler { |
| 27 | private String associatedContentTypeId; |
| 28 | private boolean defaultSetting; |
| 29 | private String modelHandlerID; |
| 30 | |
david_williams | cfdb2cd | 2004-11-11 08:37:49 +0000 | [diff] [blame] | 31 | public AbstractModelHandler() { |
| 32 | super(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * These factories are added automatically by model manager |
| 37 | */ |
| 38 | public List getAdapterFactories() { |
| 39 | List result = new ArrayList(); |
| 40 | Collection holdFactories = PluginContributedFactoryReader.getInstance().getFactories(this); |
| 41 | if (holdFactories != null) { |
| 42 | result.addAll(holdFactories); |
| 43 | } |
| 44 | return result; |
| 45 | } |
| 46 | |
| 47 | public String getAssociatedContentTypeId() { |
| 48 | return associatedContentTypeId; |
| 49 | } |
| 50 | |
| 51 | public abstract IDocumentCharsetDetector getEncodingDetector(); |
| 52 | |
| 53 | public String getId() { |
| 54 | return modelHandlerID; |
| 55 | } |
| 56 | |
| 57 | public boolean isDefault() { |
| 58 | return defaultSetting; |
| 59 | } |
| 60 | |
| 61 | protected void setAssociatedContentTypeId(String contentTypeId) { |
| 62 | associatedContentTypeId = contentTypeId; |
| 63 | } |
| 64 | |
| 65 | public void setDefault(boolean defaultParam) { |
| 66 | defaultSetting = defaultParam; |
| 67 | } |
| 68 | |
| 69 | protected void setId(String id) { |
| 70 | modelHandlerID = id; |
| 71 | } |
| 72 | } |