Class PlainJavaResource
- java.lang.Object
-
- org.faktorips.devtools.abstraction.AWrapper<java.io.File>
-
- org.faktorips.devtools.abstraction.plainjava.internal.PlainJavaResource
-
- All Implemented Interfaces:
java.lang.Comparable<AResource>,AAbstraction,AResource
- Direct Known Subclasses:
PlainJavaContainer,PlainJavaFile
public abstract class PlainJavaResource extends AWrapper<java.io.File> implements AResource
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.faktorips.devtools.abstraction.AResource
AResource.AResourceTreeTraversalDepth, AResource.AResourceType
-
-
Field Summary
-
Fields inherited from interface org.faktorips.devtools.abstraction.AResource
COMPARING_BY_NAME
-
-
Constructor Summary
Constructors Constructor Description PlainJavaResource(java.io.File wrapped)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.voiddeleteMarker(PlainJavaMarker plainJavaMarker)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.PlainJavaWorkspacegetWorkspace()Returns the workspace containing this resource.java.nio.file.PathgetWorkspaceRelativePath()Returns the relative location of this resource in the containing workspace.booleanisAccessible()An accessible resourceAResource.exists()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.protected booleanisSynchronizedInternal()voidmove(java.nio.file.Path destination, org.eclipse.core.runtime.IProgressMonitor monitor)Moves this resource to the given destination.protected voidrecursive(java.util.function.Consumer<PlainJavaResource> consumer, AResource.AResourceTreeTraversalDepth depth)Executes the givenConsumerfor this resource and, according to the given depth, its children.protected voidrecursive(java.util.function.Consumer<PlainJavaResource> consumer, AResource.AResourceTreeTraversalDepth depth, org.eclipse.core.runtime.IProgressMonitor monitor, java.lang.String taskName)Executes the givenConsumerfor this resource and, according to the given depth, its children, notifying the given monitor of progress of the given task.protected voidrefreshInternal()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 class org.faktorips.devtools.abstraction.AWrapper
equals, hashCode, toString, unwrap
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.faktorips.devtools.abstraction.AAbstraction
unwrap
-
-
-
-
Method Detail
-
isAccessible
public boolean isAccessible()
Description copied from interface:AResourceAn accessible resourceAResource.exists()and can be used. For example a project in Eclipse needs to be open to be accessible.- Specified by:
isAccessiblein interfaceAResource- Returns:
- whether this resource is accessible
-
exists
public boolean exists()
Description copied from interface:AResourceA resource exists if its file-system equivalent exists (the path corresponds to an actual file/folder).
-
getParent
public AContainer getParent()
Description copied from interface:AResourceA 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.
-
getName
public java.lang.String getName()
Description copied from interface:AResourceThe local name of this resource inside itsparent.
-
getLocation
public java.nio.file.Path getLocation()
Description copied from interface:AResourceReturns the absolute location of this resource in the file system.- Specified by:
getLocationin interfaceAResource- Returns:
- this resource's location
-
getProjectRelativePath
public java.nio.file.Path getProjectRelativePath()
Description copied from interface:AResourceReturns the relative location of this resource in the containing project.- Specified by:
getProjectRelativePathin interfaceAResource- Returns:
- this resource's location relative to its project or an empty path if the resource is not contained in a project
-
getWorkspaceRelativePath
public java.nio.file.Path getWorkspaceRelativePath()
Description copied from interface:AResourceReturns the relative location of this resource in the containing workspace.- Specified by:
getWorkspaceRelativePathin interfaceAResource- Returns:
- this resource's location relative to its project or an empty path if the resource is not contained in a workspace
-
delete
public void delete(org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface:AResourceDeletes the resource from the file system.- Specified by:
deletein interfaceAResource- 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.
-
getModificationStamp
public long getModificationStamp()
Description copied from interface:AResourceReturns the corresponding file's modification stamp. This may correspond to theAResource.getLocalTimeStamp()from the file system or be more fine-grained.- Specified by:
getModificationStampin interfaceAResource- Returns:
- the file's modification time stamp, or
-1if the file does not exist
-
getLocalTimeStamp
public long getLocalTimeStamp()
Description copied from interface:AResourceReturns the corresponding file's last modification as milliseconds since the epoch (1970-1-1).- Specified by:
getLocalTimeStampin interfaceAResource- Returns:
- the file's time stamp, or
-1if the file does not exist
-
findMarkers
public java.util.Set<AMarker> findMarkers(java.lang.String type, boolean includeSubtypes, AResource.AResourceTreeTraversalDepth depth)
Description copied from interface:AResourceReturns 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).- Specified by:
findMarkersin interfaceAResource- 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
-
recursive
protected void recursive(java.util.function.Consumer<PlainJavaResource> consumer, AResource.AResourceTreeTraversalDepth depth)
Executes the givenConsumerfor this resource and, according to the given depth, its children.- Parameters:
depth- is ignored if this resource is notAContainer.
-
recursive
protected void recursive(java.util.function.Consumer<PlainJavaResource> consumer, AResource.AResourceTreeTraversalDepth depth, @CheckForNull org.eclipse.core.runtime.IProgressMonitor monitor, java.lang.String taskName)
Executes the givenConsumerfor this resource and, according to the given depth, its children, notifying the given monitor of progress of the given task.- Parameters:
depth- is ignored if this resource is notAContainer.monitor- a progress monitor that is notified about this process. When processing a directory, 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.taskName- the name of the task, to be reported to the progress monitor
-
createMarker
public AMarker createMarker(java.lang.String markerType)
Description copied from interface:AResourceCreates a new marker of the given type for this resource.- Specified by:
createMarkerin interfaceAResource- Parameters:
markerType- themarker type- Returns:
- the created marker
-
deleteMarkers
public void deleteMarkers(java.lang.String type, boolean includeSubtypes, AResource.AResourceTreeTraversalDepth depth)Description copied from interface:AResourceDeletes 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.- Specified by:
deleteMarkersin interfaceAResource- 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...)
-
deleteMarker
public void deleteMarker(PlainJavaMarker plainJavaMarker)
-
isDerived
public boolean isDerived()
Description copied from interface:AResourceReturns whether this resource is derived (can be recreated from source files).
-
setDerived
public void setDerived(boolean isDerived, org.eclipse.core.runtime.IProgressMonitor monitor)Description copied from interface:AResourceSets this resource (and, in case this isa container, its children) as derived.- Specified by:
setDerivedin interfaceAResource- 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.
-
getProject
public AProject getProject()
Description copied from interface:AResourceReturns the project containing this resource.- Specified by:
getProjectin interfaceAResource- Returns:
- the project containing this resource; the project itself if this resource is a
projectandnullif this resource is theworkspace.
-
refreshLocal
public void refreshLocal(AResource.AResourceTreeTraversalDepth depth, org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface:AResourceSynchronizes this resource with its corresponding file-system objects.- Specified by:
refreshLocalin interfaceAResource- 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.
-
refreshInternal
protected void refreshInternal()
-
getWorkspace
public PlainJavaWorkspace getWorkspace()
Description copied from interface:AResourceReturns the workspace containing this resource.- Specified by:
getWorkspacein interfaceAResource- Returns:
- the workspace containing this resource; the workspace itself if this resource is a
workspace.
-
copy
public void copy(java.nio.file.Path destination, org.eclipse.core.runtime.IProgressMonitor monitor)Description copied from interface:AResourceCopies this resource to the given destination.- Specified by:
copyin interfaceAResource- 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
public void move(java.nio.file.Path destination, org.eclipse.core.runtime.IProgressMonitor monitor)Description copied from interface:AResourceMoves this resource to the given destination.- Specified by:
movein interfaceAResource- 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.
-
touch
public void touch(org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface:AResourceMarks this resource as modified, updating thelocal time stampandmodification stamp.
-
isSynchronized
public boolean isSynchronized(AResource.AResourceTreeTraversalDepth depth)
Description copied from interface:AResourceChecks 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
- Specified by:
isSynchronizedin interfaceAResource- 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)
-
isSynchronizedInternal
protected boolean isSynchronizedInternal()
-
-