Skip to main content
summaryrefslogtreecommitdiffstats
blob: 53308f0ced7d5158e60ba034ac53516ba4e87ad8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Jens Lukowski/Innoopract - initial renaming/restructuring
 *     
 *******************************************************************************/
package org.eclipse.wst.sse.core.internal.provisional;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.sse.core.internal.encoding.EncodingRule;
import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;


/**
 * Responsible for creating a new Model from a resource, or as a new, empty
 * instance.
 * 
 */
public interface IModelLoader {
	/**
	 * This method should perform all the model initialization required before
	 * it contains content, namely, it should call newModel, the
	 * createNewStructuredDocument(), then setAdapterFactories. (this is
	 * tentative)
	 */
	IStructuredModel createModel();

	/**
	 * Method createModel. Creates a new model based on old one.
	 * 
	 * @param oldModel
	 * @return IStructuredModel
	 */
	IStructuredModel createModel(IStructuredModel oldModel);

	/**
	 * This method must return those factories which must be attached to the
	 * structuredModel before content is applied.
	 */
	List getAdapterFactories();

	void load(IFile file, IStructuredModel model) throws IOException, CoreException;

	void load(InputStream inputStream, IStructuredModel model, EncodingRule encodingRule) throws IOException;

	void load(String filename, InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws IOException;

	IModelLoader newInstance();

	/**
	 * This method should always return an new, empty Structured Model
	 * appropriate for itself.
	 */
	IStructuredModel newModel();

	IStructuredModel reinitialize(IStructuredModel model);

	/**
	 * This method should get a fresh copy of the data, and repopulate the
	 * models ... normally by a call to setText on the structuredDocument, for
	 * StructuredModels. This method is needed in some cases where clients are
	 * sharing a model and then changes canceled. Say for example, one editor
	 * and several "displays" are sharing a model, if the editor is closed
	 * without saving changes, then the displays still need a model, but they
	 * should revert to the original unsaved version.
	 */
	void reload(InputStream inputStream, IStructuredModel model);

	/**
	 * Create a Structured Model with the given StructuredDocument instance as
	 * its document (instead of a new document instance as well)
	 */
	IStructuredModel createModel(IStructuredDocument document, String baseLocation, IModelHandler handler);

}

Back to the top