Interface AResource
-
- All Superinterfaces:
AAbstraction,java.lang.Comparable<AResource>
- All Known Subinterfaces:
AContainer,AFile,AFolder,AProject,AWorkspaceRoot
- All Known Implementing Classes:
EclipseContainer,EclipseFile,EclipseFolder,EclipseProject,EclipseResource,EclipseWorkspaceRoot,PlainJavaContainer,PlainJavaFile,PlainJavaFolder,PlainJavaProject,PlainJavaResource,PlainJavaWorkspaceRoot
public interface AResource extends AAbstraction, java.lang.Comparable<AResource>
A resource is a file or folder, possibly with a special role like a project or workspace.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classAResource.AResourceTreeTraversalDepthstatic classAResource.AResourceTypeThe type ofa resourcecan be used instead of checking forinstanceofwith concrete implementations.
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<AResource>COMPARING_BY_NAMEAComparatorcomparing resources by name.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intcompareTo(AResource o)voidcopy(java.nio.file.Path destination, org.eclipse.core.runtime.IProgressMonitor monitor)Copies this resource to the given destination.AMarkercreateMarker(java.lang.String markerType)Creates a new marker of the given type for this resource.voiddelete(org.eclipse.core.runtime.IProgressMonitor monitor)Deletes the resource from the file system.voiddeleteMarkers(java.lang.String type, boolean includeSubtypes, AResource.AResourceTreeTraversalDepth depth)Deletes all markers of the given type from this resource.booleanexists()A resource exists if its file-system equivalent exists (the path corresponds to an actual file/folder).java.util.Set<AMarker>findMarkers(java.lang.String type, boolean includeSubtypes, AResource.AResourceTreeTraversalDepth depth)Returns all markers of the given type on this resource.longgetLocalTimeStamp()Returns the corresponding file's last modification as milliseconds since the epoch (1970-1-1).java.nio.file.PathgetLocation()Returns the absolute location of this resource in the file system.longgetModificationStamp()Returns the corresponding file's modification stamp.java.lang.StringgetName()The local name of this resource inside itsparent.AContainergetParent()A resource's parent ist the resource representing the containing folder.AProjectgetProject()Returns the project containing this resource.java.nio.file.PathgetProjectRelativePath()Returns the relative location of this resource in the containing project.AResource.AResourceTypegetType()A resource type can be used instead of checking forinstanceofwith concrete implementations.AWorkspacegetWorkspace()Returns the workspace containing this resource.java.nio.file.PathgetWorkspaceRelativePath()Returns the relative location of this resource in the containing workspace.booleanisAccessible()An accessible resourceexists()and can be used.booleanisDerived()Returns whether this resource is derived (can be recreated from source files).booleanisSynchronized(AResource.AResourceTreeTraversalDepth depth)Checks whether this resource is in sync with its corresponding file-system resource.voidmove(java.nio.file.Path destination, org.eclipse.core.runtime.IProgressMonitor monitor)Moves this resource to the given destination.voidrefreshLocal(AResource.AResourceTreeTraversalDepth depth, org.eclipse.core.runtime.IProgressMonitor monitor)Synchronizes this resource with its corresponding file-system objects.voidsetDerived(boolean isDerived, org.eclipse.core.runtime.IProgressMonitor monitor)Sets this resource (and, in case this isa container, its children) as derived.voidtouch(org.eclipse.core.runtime.IProgressMonitor monitor)Marks this resource as modified, updating thelocal time stampandmodification stamp.-
Methods inherited from interface org.faktorips.devtools.abstraction.AAbstraction
unwrap
-
-
-
-
Field Detail
-
COMPARING_BY_NAME
static final java.util.Comparator<AResource> COMPARING_BY_NAME
AComparatorcomparing resources by name.
-
-
Method Detail
-
getName
java.lang.String getName()
The local name of this resource inside itsparent.- Returns:
- this resource's name
-
getType
AResource.AResourceType getType()
A resource type can be used instead of checking forinstanceofwith concrete implementations.- Returns:
- the resource's
type
-
exists
boolean exists()
A resource exists if its file-system equivalent exists (the path corresponds to an actual file/folder).- Returns:
- whether this resource exists
-
isAccessible
boolean isAccessible()
An accessible resourceexists()and can be used. For example a project in Eclipse needs to be open to be accessible.- Returns:
- whether this resource is accessible
-
isDerived
boolean isDerived()
Returns whether this resource is derived (can be recreated from source files).
-
setDerived
void setDerived(boolean isDerived, @CheckForNull org.eclipse.core.runtime.IProgressMonitor monitor)Sets this resource (and, in case this isa container, its children) as derived.- Parameters:
isDerived- whether to mark this resource as derivedmonitor- a progress monitor that is notified about this process. When marking a directory as (not) derived, individual file processing is reported to the monitor to allow fine-grained progress reporting. The monitor may benullwhen progress does not need to be reported.
-
getParent
@CheckForNull AContainer getParent()
A resource's parent ist the resource representing the containing folder. Not all resources have a parent, for example a workspace only contains other resources but has not parent.- Returns:
- this resource's parent, or
nullif it has no parent
-
getProject
@CheckForNull AProject getProject()
Returns the project containing this resource.
-
getWorkspace
AWorkspace getWorkspace()
Returns the workspace containing this resource.- Returns:
- the workspace containing this resource; the workspace itself if this resource is a
workspace.
-
getLocation
java.nio.file.Path getLocation()
Returns the absolute location of this resource in the file system.- Returns:
- this resource's location
-
getProjectRelativePath
java.nio.file.Path getProjectRelativePath()
Returns the relative location of this resource in the containing project.- Returns:
- this resource's location relative to its project or an empty path if the resource is not contained in a project
-
getWorkspaceRelativePath
java.nio.file.Path getWorkspaceRelativePath()
Returns the relative location of this resource in the containing workspace.- Returns:
- this resource's location relative to its project or an empty path if the resource is not contained in a workspace
-
getModificationStamp
long getModificationStamp()
Returns the corresponding file's modification stamp. This may correspond to thegetLocalTimeStamp()from the file system or be more fine-grained.- Returns:
- the file's modification time stamp, or
-1if the file does not exist
-
getLocalTimeStamp
long getLocalTimeStamp()
Returns the corresponding file's last modification as milliseconds since the epoch (1970-1-1).- Returns:
- the file's time stamp, or
-1if the file does not exist
-
refreshLocal
void refreshLocal(AResource.AResourceTreeTraversalDepth depth, @CheckForNull org.eclipse.core.runtime.IProgressMonitor monitor)
Synchronizes this resource with its corresponding file-system objects.- Parameters:
depth- whether to synchronize only this resource, or also its children (and their children...)monitor- a progress monitor that is notified about this process. When synchronizing a directory, individual file synchronization is reported to the monitor to allow fine-grained progress reporting. The monitor may benullwhen progress does not need to be reported.
-
isSynchronized
boolean isSynchronized(AResource.AResourceTreeTraversalDepth depth)
Checks whether this resource is in sync with its corresponding file-system resource. Both need toexistnot)- have the same
time stamp - be of the same
type
- Parameters:
depth- whether to check only this resource, or also its children (and their children...)- Returns:
- whether this resource (and its children) is/are in sync with its/their corresponding file-system resource(s)
-
touch
void touch(org.eclipse.core.runtime.IProgressMonitor monitor)
Marks this resource as modified, updating thelocal time stampandmodification stamp.- Parameters:
monitor- a progress monitor that is notified about this process. The monitor may benullwhen progress does not need to be reported.
-
findMarkers
java.util.Set<AMarker> findMarkers(java.lang.String type, boolean includeSubtypes, AResource.AResourceTreeTraversalDepth depth)
Returns all markers of the given type on this resource. IfincludeSubtypesistrue, then markers of types that are subtypes of the given type are also returned. Thedepthdetermines whether only markers from this resource are returned or also from its children (if this resource isa container).- Parameters:
type- amarker typeincludeSubtypes- whether to include subtypes of the given marker typedepth- whether to scan only this resource, or also its children (and their children...)- Returns:
- all markers matching the given type and search depth
-
createMarker
AMarker createMarker(java.lang.String markerType)
Creates a new marker of the given type for this resource.- Parameters:
markerType- themarker type- Returns:
- the created marker
-
deleteMarkers
void deleteMarkers(java.lang.String type, boolean includeSubtypes, AResource.AResourceTreeTraversalDepth depth)Deletes all markers of the given type from this resource. IfincludeSubtypesistrue, then markers of types that are subtypes of the given type are also deleted. Thedepthdetermines whether only markers from this resource are deleted or also from its children.- Parameters:
type- amarker typeincludeSubtypes- whether to include subtypes of the given marker typedepth- whether to clean only this resource, or also its children (and their children...)
-
delete
void delete(@CheckForNull org.eclipse.core.runtime.IProgressMonitor monitor)Deletes the resource from the file system.- Parameters:
monitor- a progress monitor that is notified about the deletion process. When deleting a directory, individual file deletions are reported to the monitor to allow fine-grained progress reporting. The monitor may benullwhen progress does not need to be reported.
-
copy
void copy(java.nio.file.Path destination, @CheckForNull org.eclipse.core.runtime.IProgressMonitor monitor)Copies this resource to the given destination.- Parameters:
destination- an existing resource of the sametypeas this resourcemonitor- a progress monitor that is notified about the copy process. When copying a directory, individual file copies are reported to the monitor to allow fine-grained progress reporting. The monitor may benullwhen progress does not need to be reported.
-
move
void move(java.nio.file.Path destination, @CheckForNull org.eclipse.core.runtime.IProgressMonitor monitor)Moves this resource to the given destination.- Parameters:
destination- an existing resource of the sametypeas this resourcemonitor- a progress monitor that is notified about the move process. When moving a directory, individual file copies are reported to the monitor to allow fine-grained progress reporting. The monitor may benullwhen progress does not need to be reported.
-
-