org.eclipse.core.internal.resources
Class FileState

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.core.internal.resources.FileState
All Implemented Interfaces:
IEncodedStorage, IFileState, IStorage, org.eclipse.core.runtime.IAdaptable

public class FileState
extends org.eclipse.core.runtime.PlatformObject
implements IFileState


Constructor Summary
FileState(IHistoryStore store, org.eclipse.core.runtime.IPath fullPath, long lastModified, UniversalUniqueIdentifier uuid)
           
 
Method Summary
 boolean exists()
          Returns whether this file state still exists in the local history.
 java.lang.String getCharset()
          Returns the name of a charset encoding to be used when decoding this storage's contents into characters.
 java.io.InputStream getContents()
          Returns an open input stream on the contents of this file state.
 org.eclipse.core.runtime.IPath getFullPath()
          Returns the full path of this file state.
 long getModificationTime()
          Returns the modification time of the file.
 java.lang.String getName()
          Returns the name of this file state.
 UniversalUniqueIdentifier getUUID()
           
 boolean isReadOnly()
          Returns whether this file state is read-only.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Constructor Detail

FileState

public FileState(IHistoryStore store,
                 org.eclipse.core.runtime.IPath fullPath,
                 long lastModified,
                 UniversalUniqueIdentifier uuid)
Method Detail

exists

public boolean exists()
Description copied from interface: IFileState
Returns whether this file state still exists in the local history.

Specified by:
exists in interface IFileState
Returns:
true if this state exists, and false if it does not

getCharset

public java.lang.String getCharset()
                            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IEncodedStorage
Returns the name of a charset encoding to be used when decoding this storage's contents into characters. Returns null if a proper encoding cannot be determined.

Note that this method does not check whether the result is a supported charset name. Callers should be prepared to handle UnsupportedEncodingException where this charset is used.

Specified by:
getCharset in interface IEncodedStorage
Returns:
the name of a charset, or null
Throws:
org.eclipse.core.runtime.CoreException - if an error happens while determining the charset. See any refinements for more information.
See Also:
IStorage.getContents()

getContents

public java.io.InputStream getContents()
                                throws org.eclipse.core.runtime.CoreException
Description copied from interface: IFileState
Returns an open input stream on the contents of this file state. This refinement of the corresponding IStorage method returns an open input stream on the contents this file state represents. The client is responsible for closing the stream when finished.

Specified by:
getContents in interface IFileState
Specified by:
getContents in interface IStorage
Returns:
an input stream containing the contents of the file
Throws:
org.eclipse.core.runtime.CoreException - if this method fails. Reasons include:
  • This state does not exist.

getFullPath

public org.eclipse.core.runtime.IPath getFullPath()
Description copied from interface: IFileState
Returns the full path of this file state. This refinement of the corresponding IStorage method specifies that IFileStates always have a path and that path is the full workspace path of the file represented by this state.

Specified by:
getFullPath in interface IFileState
Specified by:
getFullPath in interface IStorage
Returns:
the path related to the data represented by this storage or null if none.
See Also:
IResource.getFullPath(), IStorage.getFullPath()

getModificationTime

public long getModificationTime()
Description copied from interface: IFileState
Returns the modification time of the file. If you create a file at 9:00 and modify it at 11:00, the file state added to the history at 11:00 will have 9:00 as its modification time.

Note that is used only to give the user a general idea of how old this file state is.

Specified by:
getModificationTime in interface IFileState
Returns:
the time of last modification, in milliseconds since January 1, 1970, 00:00:00 GMT.

getName

public java.lang.String getName()
Description copied from interface: IFileState
Returns the name of this file state. This refinement of the corresponding IStorage method specifies that IFileStates always have a name and that name is equivalent to the last segment of the full path of the resource represented by this state.

Specified by:
getName in interface IFileState
Specified by:
getName in interface IStorage
Returns:
the name of the data represented by this storage, or null if this storage has no name
See Also:
IResource.getName(), IStorage.getName()

getUUID

public UniversalUniqueIdentifier getUUID()

isReadOnly

public boolean isReadOnly()
Description copied from interface: IFileState
Returns whether this file state is read-only. This refinement of the corresponding IStorage method restricts IFileStates to always be read-only.

Specified by:
isReadOnly in interface IFileState
Specified by:
isReadOnly in interface IStorage
Returns:
true if this storage is read-only
See Also:
IStorage

toString

public java.lang.String toString()
Returns a string representation of this object. Used for debug only.

Overrides:
toString in class java.lang.Object