Package org.eclipse.handly.snapshot
Class TextFileSnapshot
java.lang.Object
org.eclipse.handly.snapshot.Snapshot
org.eclipse.handly.snapshot.TextFileSnapshot
- All Implemented Interfaces:
ISnapshot
A snapshot of a text
IFile. Thread-safe.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies whether the snapshot is to be taken directly from the file system, bypassing the workspace. -
Constructor Summary
ConstructorsConstructorDescriptionTextFileSnapshot(org.eclipse.core.resources.IFile file, TextFileSnapshot.Layer layer) Constructs a new snapshot of the given textIFile. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists()Returns whether the file existed at the moment this snapshot was taken.A snapshot returns the same contents until it expires.org.eclipse.core.runtime.IStatusReturns whether an I/O error was encountered while reading the file.protected BooleanpredictEquality(Snapshot other)
-
Constructor Details
-
TextFileSnapshot
Constructs a new snapshot of the given textIFile.The workspace may be out of sync with the file system. The
layerargument controls how to deal with that. IfLayer.FILESYSTEMis specified, the snapshot will be taken directly from the file system, bypassing the workspace. IfLayer.WORKSPACEis specified, the snapshot will expire if the workspace is not in sync with the corresponding location in the file system.- Parameters:
file- notnulllayer- controls whether the snapshot is to be taken directly from the file system, bypassing the workspace
-
-
Method Details
-
getContents
Description copied from interface:ISnapshotA snapshot returns the same contents until it expires. This is the contents of the underlying resource or buffer at the moment the snapshot was taken. Expired snapshots returnnull.Protractedly holding on to the returned contents is not recommended, as it may potentially consume significant amount of space.
- Returns:
- the contents of the snapshot, or
nullif the snapshot has expired
-
getStatus
public org.eclipse.core.runtime.IStatus getStatus()Returns whether an I/O error was encountered while reading the file.- Returns:
- an error status if an I/O error was encountered, or OK status otherwise
-
exists
public boolean exists()Returns whether the file existed at the moment this snapshot was taken.- Returns:
trueif the file existed at the moment this snapshot was taken, andfalseotherwise
-
predictEquality
Description copied from class:SnapshotPredicts whether this snapshot isequalto the given snapshot without actually obtaining snapshotcontents. Must returnnullif cannot tell for sure. Any non-null result must meet the contract ofISnapshot.isEqualTo(ISnapshot).- Overrides:
predictEqualityin classSnapshot- Parameters:
other- the other snapshot (notnulland not identical to the receiver)- Returns:
trueif the snapshots are predicted to be equal,falseif the snapshots are predicted to be unequal, andnullif there is no prediction
-