FileObject.getMIMEType(String... withinMIMETypes)
--- a/openide.filesystems/manifest.mf
+++ a/openide.filesystems/manifest.mf
@@ -2,5 +2,5 @@
OpenIDE-Module: org.openide.filesystems
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
-OpenIDE-Module-Specification-Version: 7.54
+OpenIDE-Module-Specification-Version: 7.55
--- a/openide.filesystems/src/org/openide/filesystems/FileObject.java
+++ a/openide.filesystems/src/org/openide/filesystems/FileObject.java
@@ -60,6 +60,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
+import java.util.concurrent.Callable;
import java.util.logging.Level;
import org.openide.util.Enumerations;
import org.openide.util.UserQuestionException;
@@ -1058,6 +1059,42 @@
return true;
}
+ static final String REMOVE_WRITABLES_ATTR = "removeWritables";
+
+ /**
+ * Checks whether this file can be reverted to a pristine state.
+ * @return whether {@link #revert} might do something
+ * @since 7.55
+ */
+ public final boolean canRevert() {
+ return getAttribute(REMOVE_WRITABLES_ATTR) instanceof Callable>;
+ }
+
+ /**
+ * Revert this file to a pristine state.
+ * Generally only meaningful for files on the system filesystem (layers + user directory):
+ * if the file is defined in a layer but modified in the user directory, it is reset;
+ * if it is defined only in the user directory, it is deleted.
+ * If {@link #canRevert} is false, does nothing.
+ * Note that while content can be reset, it may not be possible to reset attributes.
+ * Implementors: for historical reasons this method checks {@link #getAttribute}
+ * for a special attribute named {@code removeWritables} which must be of type
+ * {@link Callable Callable}. If present, the file is considered modified.
+ * @since 7.55
+ */
+ public final void revert() throws IOException {
+ Object v = getAttribute(REMOVE_WRITABLES_ATTR);
+ if (v instanceof Callable>) {
+ try {
+ ((Callable>) v).call();
+ } catch (IOException x) {
+ throw x;
+ } catch (Exception x) {
+ throw new IOException(x);
+ }
+ }
+ }
+
/** Should check for external modifications. For folders it should reread
* the content of disk, for data file it should check for the last
* time the file has been modified.
--- a/openide.filesystems/src/org/openide/filesystems/MultiFileObject.java
+++ a/openide.filesystems/src/org/openide/filesystems/MultiFileObject.java
@@ -792,7 +792,7 @@
}
/** Special attributes which should not be checked for weight. See RemoveWritablesTest. */
- private static final Set SPECIAL_ATTR_NAMES = new HashSet(Arrays.asList("removeWritables", WEIGHT_ATTRIBUTE, "java.io.File")); // NOI18N
+ private static final Set SPECIAL_ATTR_NAMES = new HashSet(Arrays.asList(FileObject.REMOVE_WRITABLES_ATTR, WEIGHT_ATTRIBUTE, "java.io.File")); // NOI18N
private final Object getAttribute(String attrName, String path) {
// Look for attribute in any file system starting at the front.
// Additionally, look for attribute in root folder, where
--- a/openide.loaders/nbproject/project.xml
+++ a/openide.loaders/nbproject/project.xml
@@ -122,7 +122,7 @@
- 7.52
+ 7.55