|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Files are leaf resources which contain data. The contents of a file resource is stored as a file in the local file system.
Files, like folders, may exist in the workspace but not be local; non-local file resources serve as placeholders for files whose content and properties have not yet been fetched from a repository.
This interface is not intended to be implemented by clients.
Files implement the IAdaptable
interface;
extensions are managed by the platform's adapter manager.
Platform.getAdapterManager()
Field Summary | |
static int |
ENCODING_ISO_8859_1
Character encoding constant (value 2) which identifies files that are encoded with the ISO-8859-1 character encoding scheme, also known as ISO-LATIN-1. |
static int |
ENCODING_UNKNOWN
Character encoding constant (value 0) which identifies files that have an unknown character encoding scheme. |
static int |
ENCODING_US_ASCII
Character encoding constant (value 1) which identifies files that are encoded with the US-ASCII character encoding scheme. |
static int |
ENCODING_UTF_16
Character encoding constant (value 6) which identifies files that are encoded with the UTF-16 character encoding scheme. |
static int |
ENCODING_UTF_16BE
Character encoding constant (value 4) which identifies files that are encoded with the UTF-16BE character encoding scheme. |
static int |
ENCODING_UTF_16LE
Character encoding constant (value 5) which identifies files that are encoded with the UTF-16LE character encoding scheme. |
static int |
ENCODING_UTF_8
Character encoding constant (value 3) which identifies files that are encoded with the UTF-8 character encoding scheme. |
Fields inherited from interface org.eclipse.core.resources.IResource |
ALWAYS_DELETE_PROJECT_CONTENT, DEPTH_INFINITE, DEPTH_ONE, DEPTH_ZERO, FILE, FOLDER, FORCE, KEEP_HISTORY, NEVER_DELETE_PROJECT_CONTENT, NONE, NULL_STAMP, PROJECT, ROOT |
Method Summary | |
void |
appendContents(InputStream source,
boolean force,
boolean keepHistory,
IProgressMonitor monitor)
Appends the entire contents of the given stream to this file. |
void |
appendContents(InputStream source,
int updateFlags,
IProgressMonitor monitor)
Appends the entire contents of the given stream to this file. |
void |
create(InputStream source,
boolean force,
IProgressMonitor monitor)
Creates a new file resource as a member of this handle's parent resource. |
void |
create(InputStream source,
int updateFlags,
IProgressMonitor monitor)
Creates a new file resource as a member of this handle's parent resource. |
void |
delete(boolean force,
boolean keepHistory,
IProgressMonitor monitor)
Deletes this file from the workspace. |
InputStream |
getContents()
Returns an open input stream on the contents of this file. |
InputStream |
getContents(boolean force)
This refinement of the corresponding IStorage method
returns an open input stream on the contents of this file. |
int |
getEncoding()
Returns a constant identifying the character encoding of this file, or ENCODING_UNKNOWN if it could not be determined. |
IPath |
getFullPath()
Returns the full path of this file. |
IFileState[] |
getHistory(IProgressMonitor monitor)
Returns a list of past states of this file known to this workspace. |
String |
getName()
Returns the name of this file. |
boolean |
isReadOnly()
Returns whether this file is read-only. |
void |
move(IPath destination,
boolean force,
boolean keepHistory,
IProgressMonitor monitor)
Moves this resource to be at the given location. |
void |
setContents(IFileState source,
boolean force,
boolean keepHistory,
IProgressMonitor monitor)
Sets the contents of this file to the bytes in the given file state. |
void |
setContents(IFileState source,
int updateFlags,
IProgressMonitor monitor)
Sets the contents of this file to the bytes in the given file state. |
void |
setContents(InputStream source,
boolean force,
boolean keepHistory,
IProgressMonitor monitor)
Sets the contents of this file to the bytes in the given input stream. |
void |
setContents(InputStream source,
int updateFlags,
IProgressMonitor monitor)
Sets the contents of this file to the bytes in the given input stream. |
Methods inherited from interface org.eclipse.core.resources.IResource |
accept, accept, accept, clearHistory, copy, copy, copy, copy, createMarker, delete, delete, deleteMarkers, equals, exists, findMarker, findMarkers, getFileExtension, getLocation, getMarker, getModificationStamp, getParent, getPersistentProperty, getProject, getProjectRelativePath, getSessionProperty, getType, getWorkspace, isAccessible, isDerived, isLocal, isPhantom, isSynchronized, isTeamPrivateMember, move, move, move, move, refreshLocal, setDerived, setLocal, setPersistentProperty, setReadOnly, setSessionProperty, setTeamPrivateMember, touch |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
getAdapter |
Field Detail |
public static final int ENCODING_UNKNOWN
getEncoding()
,
Constant Field Valuespublic static final int ENCODING_US_ASCII
getEncoding()
,
Constant Field Valuespublic static final int ENCODING_ISO_8859_1
getEncoding()
,
Constant Field Valuespublic static final int ENCODING_UTF_8
getEncoding()
,
Constant Field Valuespublic static final int ENCODING_UTF_16BE
getEncoding()
,
Constant Field Valuespublic static final int ENCODING_UTF_16LE
getEncoding()
,
Constant Field Valuespublic static final int ENCODING_UTF_16
getEncoding()
,
Constant Field ValuesMethod Detail |
public void appendContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException
This is a convenience method, fully equivalent to:
appendContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file's content have been changed.
This method is long-running; progress and cancelation are provided by the given progress monitor.
source
- an input stream containing the new contents of the fileforce
- a flag controlling how to deal with resources that
are not in sync with the local file systemkeepHistory
- a flag indicating whether or not to store
the current contents in the local historymonitor
- a progress monitor, or null
if progress
reporting and cancelation are not desired
CoreException
- if this method fails. Reasons include:
force
is false
.appendContents(java.io.InputStream,int,IProgressMonitor)
public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException
null
, will get closed
whether this method succeeds or fails.
The FORCE
update flag controls how this method deals with
cases where the workspace is not completely in sync with the local file
system. If FORCE
is not specified, the method will only attempt
to overwrite a corresponding file in the local file system provided
it is in sync with the workspace. This option ensures there is no
unintended data loss; it is the recommended setting.
However, if FORCE
is specified, an attempt will be made
to write a corresponding file in the local file system, overwriting any
existing one if need be. In either case, if this method succeeds, the
resource will be marked as being local (even if it wasn't before).
If this file is non-local then this method will always fail. The only exception
is when FORCE
is specified and the file exists in the local
file system. In this case the file is made local and the given contents are appended.
The KEEP_HISTORY
update flag controls whether or not a copy of
current contents of this file should be captured in the workspace's local
history (properties are not recorded in the local history). The local history
mechanism serves as a safety net to help the user recover from mistakes that
might otherwise result in data loss. Specifying KEEP_HISTORY
is recommended except in circumstances where past states of the files are of
no conceivable interested to the user. Note that local history is maintained
with each individual project, and gets discarded when a project is deleted
from the workspace.
Update flags other than FORCE
and KEEP_HISTORY
are ignored.
Prior to modifying the contents of this file, the file modification validator (if provided
by the VCM plug-in), will be given a chance to perform any last minute preparations. Validation
is performed by calling IFileModificationValidator.validateSave
on this file.
If the validation fails, then this operation will fail.
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file's content have been changed.
This method is long-running; progress and cancelation are provided by the given progress monitor.
source
- an input stream containing the new contents of the fileupdateFlags
- bit-wise or of update flag constants
(FORCE
and KEEP_HISTORY
)monitor
- a progress monitor, or null
if progress
reporting and cancelation are not desired
CoreException
- if this method fails. Reasons include:
FORCE
is not specified.public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException
This is a convenience method, fully equivalent to:
create(source, (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that the file has been added to its parent.
This method is long-running; progress and cancellation are provided by the given progress monitor.
source
- an input stream containing the initial contents of the file,
or null
if the file should be marked as not localforce
- a flag controlling how to deal with resources that
are not in sync with the local file systemmonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
IWorkspace.validateName
).force
is false
.public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException
null
then a file is not created in the local
file system and the created file is marked as being non-local.
The FORCE
update flag controls how this method deals with
cases where the workspace is not completely in sync with the local file
system. If FORCE
is not specified, the method will only attempt
to write a file in the local file system if it does not already exist.
This option ensures there is no unintended data loss; it is the recommended
setting. However, if FORCE
is specified, this method will
attempt to write a corresponding file in the local file system,
overwriting any existing one if need be.
Update flags other than FORCE
are ignored.
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that the file has been added to its parent.
This method is long-running; progress and cancellation are provided by the given progress monitor.
source
- an input stream containing the initial contents of the file,
or null
if the file should be marked as not localupdateFlags
- bit-wise or of update flag constants
(only FORCE
is relevant here)monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
IWorkspace.validateName
).FORCE
is not specified.public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException
This is a convenience method, fully equivalent to:
delete((keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this folder has been removed from its parent.
This method is long-running; progress and cancellation are provided by the given progress monitor.
force
- a flag controlling whether resources that are not
in sync with the local file system will be toleratedkeepHistory
- a flag controlling whether files under this folder
should be stored in the workspace's local historymonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
force
is false
.IResource.delete(int,IProgressMonitor)
public InputStream getContents() throws CoreException
IStorage
method
returns an open input stream on the contents of this file.
The client is responsible for closing the stream when finished.
getContents
in interface IStorage
CoreException
- if this method fails. Reasons include:
public InputStream getContents(boolean force) throws CoreException
IStorage
method
returns an open input stream on the contents of this file.
The client is responsible for closing the stream when finished.
If force is true
the file is opened and an input
stream returned regardless of the sync state of the file. The file
is not synchronized with the workspace.
If force is false
the method fails if not in sync.
force
- a flag controlling how to deal with resources that
are not in sync with the local file system
CoreException
- if this method fails. Reasons include:
false
.public int getEncoding() throws CoreException
CoreException
- if this method fails. Reasons include:
public IPath getFullPath()
IStorage
and IResource
methods links the semantics of resource and storage object paths such that
IFile
s always have a path and that path is relative to the
containing workspace.
getFullPath
in interface IResource
IResource.getFullPath()
,
IStorage.getFullPath()
public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException
This method is long-running; progress and cancellation are provided by the given progress monitor.
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails.public String getName()
IStorage
and IResource
methods links the semantics of resource and storage object names such that
IFile
s always have a name and that name equivalent to the
last segment of its full path.
getName
in interface IResource
IResource.getName()
,
IStorage.getName()
public boolean isReadOnly()
IStorage
and IResource
methods links the semantics of read-only resources and read-only storage objects.
isReadOnly
in interface IResource
true
if this resource is read-only,
false
otherwiseIResource.isReadOnly()
,
IStorage.isReadOnly()
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException
This is a convenience method, fully equivalent to:
move(destination, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file has been removed from its parent and a new file has been added to the parent of the destination.
This method is long-running; progress and cancellation are provided by the given progress monitor.
destination
- the destination pathforce
- a flag controlling whether resources that are not
in sync with the local file system will be toleratedkeepHistory
- a flag controlling whether files under this folder
should be stored in the workspace's local historymonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this resource could not be moved. Reasons include:
force
is false
.IResource.move(IPath,int,IProgressMonitor)
public void setContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException
This is a convenience method, fully equivalent to:
setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file's content have been changed.
This method is long-running; progress and cancellation are provided by the given progress monitor.
source
- an input stream containing the new contents of the fileforce
- a flag controlling how to deal with resources that
are not in sync with the local file systemkeepHistory
- a flag indicating whether or not store
the current contents in the local historymonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
force
is false
.setContents(java.io.InputStream,int,IProgressMonitor)
public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException
This is a convenience method, fully equivalent to:
setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file's content have been changed.
This method is long-running; progress and cancellation are provided by the given progress monitor.
source
- a previous state of this resourceforce
- a flag controlling how to deal with resources that
are not in sync with the local file systemkeepHistory
- a flag indicating whether or not store
the current contents in the local historymonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
force
is false
.setContents(IFileState,int,IProgressMonitor)
public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException
null
then the content is set to be the
empty sequence of bytes.
The FORCE
update flag controls how this method deals with
cases where the workspace is not completely in sync with the local file
system. If FORCE
is not specified, the method will only attempt
to overwrite a corresponding file in the local file system provided
it is in sync with the workspace. This option ensures there is no
unintended data loss; it is the recommended setting.
However, if FORCE
is specified, an attempt will be made
to write a corresponding file in the local file system, overwriting any
existing one if need be. In either case, if this method succeeds, the
resource will be marked as being local (even if it wasn't before).
The KEEP_HISTORY
update flag controls whether or not a copy of
current contents of this file should be captured in the workspace's local
history (properties are not recorded in the local history). The local history
mechanism serves as a safety net to help the user recover from mistakes that
might otherwise result in data loss. Specifying KEEP_HISTORY
is recommended except in circumstances where past states of the files are of
no conceivable interested to the user. Note that local history is maintained
with each individual project, and gets discarded when a project is deleted
from the workspace.
Update flags other than FORCE
and KEEP_HISTORY
are ignored.
Prior to modifying the contents of this file, the file modification validator (if provided
by the VCM plug-in), will be given a chance to perform any last minute preparations. Validation
is performed by calling IFileModificationValidator.validateSave
on this file.
If the validation fails, then this operation will fail.
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file's content have been changed.
This method is long-running; progress and cancellation are provided by the given progress monitor.
source
- an input stream containing the new contents of the fileupdateFlags
- bit-wise or of update flag constants
(FORCE
and KEEP_HISTORY
)monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
FORCE
is not specified.public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) throws CoreException
The FORCE
update flag controls how this method deals with
cases where the workspace is not completely in sync with the local file
system. If FORCE
is not specified, the method will only attempt
to overwrite a corresponding file in the local file system provided
it is in sync with the workspace. This option ensures there is no
unintended data loss; it is the recommended setting.
However, if FORCE
is specified, an attempt will be made
to write a corresponding file in the local file system, overwriting any
existing one if need be. In either case, if this method succeeds, the
resource will be marked as being local (even if it wasn't before).
The KEEP_HISTORY
update flag controls whether or not a copy of
current contents of this file should be captured in the workspace's local
history (properties are not recorded in the local history). The local history
mechanism serves as a safety net to help the user recover from mistakes that
might otherwise result in data loss. Specifying KEEP_HISTORY
is recommended except in circumstances where past states of the files are of
no conceivable interested to the user. Note that local history is maintained
with each individual project, and gets discarded when a project is deleted
from the workspace.
Update flags other than FORCE
and KEEP_HISTORY
are ignored.
Prior to modifying the contents of this file, the file modification validator (if provided
by the VCM plug-in), will be given a chance to perform any last minute preparations. Validation
is performed by calling IFileModificationValidator.validateSave
on this file.
If the validation fails, then this operation will fail.
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this file's content have been changed.
This method is long-running; progress and cancellation are provided by the given progress monitor.
source
- a previous state of this resourceupdateFlags
- bit-wise or of update flag constants
(FORCE
and KEEP_HISTORY
)monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
CoreException
- if this method fails. Reasons include:
FORCE
is not specified.
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |