001: /*******************************************************************************
002: * Copyright (c) 2000, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jface.text.formatter;
011:
012: import java.util.Map;
013:
014: import org.eclipse.jface.preference.IPreferenceStore;
015:
016: /**
017: * Formatting context used in formatting strategies implementing interface
018: * <code>IFormattingStrategyExtension</code>.
019: *
020: * @see IFormattingStrategyExtension
021: * @since 3.0
022: */
023: public interface IFormattingContext {
024:
025: /**
026: * Dispose of the formatting context.
027: * <p>
028: * Must be called after the formatting context has been used in a
029: * formatting process.
030: */
031: void dispose();
032:
033: /**
034: * Returns the preference keys used for the retrieval of formatting
035: * preferences.
036: *
037: * @return The preference keys for formatting
038: */
039: String[] getPreferenceKeys();
040:
041: /**
042: * Retrieves the property <code>key</code> from the formatting context
043: *
044: * @param key
045: * Key of the property to store in the context
046: * @return The property <code>key</code> if available, <code>null</code>
047: * otherwise
048: */
049: Object getProperty(Object key);
050:
051: /**
052: * Is this preference key for a boolean preference?
053: *
054: * @param key
055: * The preference key to query its type
056: * @return <code>true</code> iff this key is for a boolean preference,
057: * <code>false</code> otherwise.
058: */
059: boolean isBooleanPreference(String key);
060:
061: /**
062: * Is this preference key for a double preference?
063: *
064: * @param key
065: * The preference key to query its type
066: * @return <code>true</code> iff this key is for a double preference,
067: * <code>false</code> otherwise.
068: */
069: boolean isDoublePreference(String key);
070:
071: /**
072: * Is this preference key for a float preference?
073: *
074: * @param key
075: * The preference key to query its type
076: * @return <code>true</code> iff this key is for a float preference,
077: * <code>false</code> otherwise.
078: */
079: boolean isFloatPreference(String key);
080:
081: /**
082: * Is this preference key for an integer preference?
083: *
084: * @param key
085: * The preference key to query its type
086: * @return <code>true</code> iff this key is for an integer preference,
087: * <code>false</code> otherwise.
088: */
089: boolean isIntegerPreference(String key);
090:
091: /**
092: * Is this preference key for a long preference?
093: *
094: * @param key
095: * The preference key to query its type
096: * @return <code>true</code> iff this key is for a long preference,
097: * <code>false</code> otherwise.
098: */
099: boolean isLongPreference(String key);
100:
101: /**
102: * Is this preference key for a string preference?
103: *
104: * @param key
105: * The preference key to query its type
106: * @return <code>true</code> iff this key is for a string preference,
107: * <code>false</code> otherwise.
108: */
109: boolean isStringPreference(String key);
110:
111: /**
112: * Stores the preferences from a map to a preference store.
113: * <p>
114: * Note that the preference keys returned by
115: * {@link #getPreferenceKeys()} must not be used in the preference store.
116: * Otherwise the preferences are overwritten.
117: * </p>
118: *
119: * @param map
120: * Map to retrieve the preferences from
121: * @param store
122: * Preference store to store the preferences in
123: */
124: void mapToStore(Map map, IPreferenceStore store);
125:
126: /**
127: * Stores the property <code>key</code> in the formatting context.
128: *
129: * @param key
130: * Key of the property to store in the context
131: * @param property
132: * Property to store in the context. If already present, the new
133: * property overwrites the present one.
134: */
135: void setProperty(Object key, Object property);
136:
137: /**
138: * Retrieves the preferences from a preference store in a map.
139: * <p>
140: * Note that the preference keys returned by
141: * {@link #getPreferenceKeys()} must not be used in the map. Otherwise the
142: * preferences are overwritten.
143: * </p>
144: *
145: * @param store
146: * Preference store to retrieve the preferences from
147: * @param map
148: * Map to store the preferences in
149: * @param useDefault
150: * <code>true</code> if the default preferences should be
151: * used, <code>false</code> otherwise
152: */
153: void storeToMap(IPreferenceStore store, Map map, boolean useDefault);
154: }
|