Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1aa5880f58be7d0ee31ce785ee5f136ad4971a0b (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*****************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *****************************************************************************/

package org.eclipse.jface.text.formatter;

import java.util.Map;

import org.eclipse.jface.preference.IPreferenceStore;

/**
 * Formatting context used in formatting strategies implementing interface
 * <code>IFormattingStrategyExtension</code>.
 * 
 * @see IFormattingStrategyExtension
 * @since 3.0
 */
public interface IFormattingContext {

	/**
	 * Dispose of the formatting context.
	 * <p>
	 * Must be called after the formatting context has been used in a
	 * formatting process.
	 */
	void dispose();

	/**
	 * Returns the preference keys used for the retrieval of formatting
	 * preferences.
	 * 
	 * @return The preference keys for formatting
	 */
	String[] getPreferenceKeys();

	/**
	 * Retrieves the property <code>key</code> from the formatting context
	 * 
	 * @param key
	 *                  Key of the property to store in the context
	 * @return The property <code>key</code> if available, <code>null</code>
	 *               otherwise
	 */
	Object getProperty(Object key);

	/**
	 * Is this preference key for a boolean preference?
	 * 
	 * @param key
	 *                  The preference key to query its type
	 * @return <code>true</code> iff this key is for a boolean preference,
	 *               <code>false</code> otherwise.
	 */
	boolean isBooleanPreference(String key);

	/**
	 * Is this preference key for a double preference?
	 * 
	 * @param key
	 *                  The preference key to query its type
	 * @return <code>true</code> iff this key is for a double preference,
	 *               <code>false</code> otherwise.
	 */
	boolean isDoublePreference(String key);

	/**
	 * Is this preference key for a float preference?
	 * 
	 * @param key
	 *                  The preference key to query its type
	 * @return <code>true</code> iff this key is for a float preference,
	 *               <code>false</code> otherwise.
	 */
	boolean isFloatPreference(String key);

	/**
	 * Is this preference key for an integer preference?
	 * 
	 * @param key
	 *                  The preference key to query its type
	 * @return <code>true</code> iff this key is for an integer preference,
	 *               <code>false</code> otherwise.
	 */
	boolean isIntegerPreference(String key);

	/**
	 * Is this preference key for a long preference?
	 * 
	 * @param key
	 *                  The preference key to query its type
	 * @return <code>true</code> iff this key is for a long preference,
	 *               <code>false</code> otherwise.
	 */
	boolean isLongPreference(String key);

	/**
	 * Is this preference key for a string preference?
	 * 
	 * @param key
	 *                  The preference key to query its type
	 * @return <code>true</code> iff this key is for a string preference,
	 *               <code>false</code> otherwise.
	 */
	boolean isStringPreference(String key);

	/**
	 * Stores the preferences from a map to a preference store.
	 * <p>
	 * Note that the preference keys returned by
	 * {@link #getPreferenceKeys()} must not be used in the preference store.
	 * Otherwise the preferences are overwritten.
	 * </p>
	 * 
	 * @param map
	 *                  Map to retrieve the preferences from
	 * @param store
	 *                  Preference store to store the preferences in
	 */
	void mapToStore(Map map, IPreferenceStore store);

	/**
	 * Stores the property <code>key</code> in the formatting context.
	 * 
	 * @param key
	 *                  Key of the property to store in the context
	 * @param property
	 *                  Property to store in the context. If already present, the new
	 *                  property overwrites the present one.
	 */
	void setProperty(Object key, Object property);

	/**
	 * Retrieves the preferences from a preference store in a map.
	 * <p>
	 * Note that the preference keys returned by
	 * {@link #getPreferenceKeys()} must not be used in the map. Otherwise the
	 * preferences are overwritten.
	 * </p>
	 * 
	 * @param store
	 *                  Preference store to retrieve the preferences from
	 * @param map
	 *                  Map to store the preferences in
	 * @param useDefault
	 *                  <code>true</code> if the default preferences should be
	 *                  used, <code>false</code> otherwise
	 */
	void storeToMap(IPreferenceStore store, Map map, boolean useDefault);
}

Back to the top