CloneSet50


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
140260.960class_body_declarations[8]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
114036
plugins/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/Resources.java
214143
plugins/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Resources.java
Clone Instance
1
Line Count
140
Source Line
36
Source File
plugins/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/Resources.java

        private Resources() {
        }

        /**
         * Checks if the given resource is in sync with the underlying file system.
         * 
         * @param resource the resource to be checked
         * @return IStatus status describing the check's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the resource is in sync
         */
        public static IStatus checkInSync(IResource resource) {
                return checkInSync(new IResource[] {
                                                    resource
                                                   } );
        }

        /**
         * Checks if the given resources are in sync with the underlying file
         * system.
         * 
         * @param resources the resources to be checked
         * @return IStatus status describing the check's result. If <code>status.
         *  isOK() </code> returns <code>true</code> then the resources are in sync
         */
        public static IStatus checkInSync(IResource[] resources) {
                IStatus result = null;
                for (int i = 0; i < resources.length; i++) {
                        IResource resource = resources[i];
                        if ( !resource.isSynchronized(IResource.DEPTH_INFINITE)) {
                                result = addOutOfSync(result, resource);
                        }
                }
                if (result != null)
                        return result;
                return new Status(IStatus.OK, JUnitPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$           
        }

        /**
         * Makes the given resource committable. Committable means that it is
         * writeable and that its content hasn't changed by calling
         * <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
         * 
         * @param resource the resource to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return IStatus status describing the method's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the resource are committable
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.
         * resources.IFile[], java.lang.Object)
         */
        public static IStatus makeCommittable(IResource resource, Object context) {
                return makeCommittable(new IResource[] {
                                                         resource
                                                       },            context);
        }

        /**
         * Makes the given resources committable. Committable means that all
         * resources are writeable and that the content of the resources hasn't
         * changed by calling <code>validateEdit</code> for a given file on
         * <tt>IWorkspace</tt>.
         * 
         * @param resources the resources to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return IStatus status describing the method's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the add resources are
         * committable
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
         */
        public static IStatus makeCommittable(IResource[] resources, Object context) {
                List readOnlyFiles = new ArrayList();
                for (int i = 0; i < resources.length; i++) {
                        IResource resource = resources[i];
                        if (resource.getType() == IResource.FILE && resource.getResourceAttributes().isReadOnly())
                                readOnlyFiles.add(resource);
                }
                if (readOnlyFiles.size() == 0)
                        return new Status(IStatus.OK, JUnitPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$

                Map oldTimeStamps = createModificationStampMap(readOnlyFiles);
                IStatus status = ResourcesPlugin.getWorkspace().validateEdit(
                         (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
                if ( !status.isOK())
                        return status;

                IStatus modified = null;
                Map newTimeStamps = createModificationStampMap(readOnlyFiles);
                for (Iterator iter = oldTimeStamps.keySet().iterator(); iter.hasNext();) {
                        IFile file = (IFile) iter.next();
                        if ( !oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
                                modified = addModified(modified, file);
                }
                if (modified != null)
                        return modified;
                return new Status(IStatus.OK, JUnitPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
        }

        private static Map createModificationStampMap(List files) {
                Map map = new HashMap();
                for (Iterator iter = files.iterator(); iter.hasNext();) {
                        IFile file = (IFile) iter.next();
                        map.put(file, new Long(file.getModificationStamp()));
                }
                return map;
        }

        private static IStatus addModified(IStatus status, IFile file) {
                IStatus entry = JUnitStatus.createError(Messages.format(JUnitMessages.Resources_fileModified, file.getFullPath().toString()));
                if (status == null) {
                        return entry;
                }
                else   if (status.isMultiStatus()) {
                        ((MultiStatus) status).add(entry);
                        return status;
                       }
                       else {
                        MultiStatus result = new MultiStatus(JUnitPlugin.getPluginId(), 
                                 IJUnitStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, 
                         JUnitMessages.Resources_modifiedResources, null);
                        result.add(status);
                        result.add(entry);
                        return result;
                       }
        }

        private static IStatus addOutOfSync(IStatus status, IResource resource) {
                IStatus entry = new Status(
                         IStatus.ERROR, 
                         ResourcesPlugin.PI_RESOURCES, 
                         IResourceStatus.OUT_OF_SYNC_LOCAL, 
                 Messages.format(JUnitMessages.Resources_outOfSync, resource.getFullPath().toString()), 
                         null             );
                if (status == null) {
                        return entry;
                }
                else   if (status.isMultiStatus()) {
                        ((MultiStatus) status).add(entry);
                        return status;
                       }
                       else {
                        MultiStatus result = new MultiStatus(
                                 ResourcesPlugin.PI_RESOURCES, 
                                 IResourceStatus.OUT_OF_SYNC_LOCAL, 
                         JUnitMessages.Resources_outOfSyncResources, null);
                        result.add(status);
                        result.add(entry);
                        return result;
                       }
        }


Clone Instance
2
Line Count
141
Source Line
43
Source File
plugins/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Resources.java

        private Resources() {
        }

        /**
         * Checks if the given resource is in sync with the underlying file system.
         * 
         * @param resource the resource to be checked
         * @return IStatus status describing the check's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the resource is in sync
         */
        public static IStatus checkInSync(IResource resource) {
                return checkInSync(new IResource[] {
                                                    resource
                                                   } );
        }

        /**
         * Checks if the given resources are in sync with the underlying file
         * system.
         * 
         * @param resources the resources to be checked
         * @return IStatus status describing the check's result. If <code>status.
         *  isOK() </code> returns <code>true</code> then the resources are in sync
         */
        public static IStatus checkInSync(IResource[] resources) {
                IStatus result = null;
                for (int i = 0; i < resources.length; i++) {
                        IResource resource = resources[i];
                        if ( !resource.isSynchronized(IResource.DEPTH_INFINITE)) {
                                result = addOutOfSync(result, resource);
                        }
                }
                if (result != null)
                        return result;
                return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$            
        }

        /**
         * Makes the given resource committable. Committable means that it is
         * writeable and that its content hasn't changed by calling
         * <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
         * 
         * @param resource the resource to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return status describing the method's result. If <code>status.isOK()</code> returns <code>true</code> then the resources are committable.
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
         */
        public static IStatus makeCommittable(IResource resource, Object context) {
                return makeCommittable(new IResource[] {
                                                         resource
                                                       },            context);
        }

        /**
         * Makes the given resources committable. Committable means that all
         * resources are writeable and that the content of the resources hasn't
         * changed by calling <code>validateEdit</code> for a given file on
         * <tt>IWorkspace</tt>.
         * 
         * @param resources the resources to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return IStatus status describing the method's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the add resources are
         * committable
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
         */
        public static IStatus makeCommittable(IResource[] resources, Object context) {
                List readOnlyFiles = new ArrayList();
                for (int i = 0; i < resources.length; i++) {
                        IResource resource = resources[i];
                        if (resource.getType() == IResource.FILE && isReadOnly(resource))
                                readOnlyFiles.add(resource);
                }
                if (readOnlyFiles.size() == 0)
                        return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$

                Map oldTimeStamps = createModificationStampMap(readOnlyFiles);
                IStatus status = ResourcesPlugin.getWorkspace().validateEdit(
                         (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
                if ( !status.isOK())
                        return status;

                IStatus modified = null;
                Map newTimeStamps = createModificationStampMap(readOnlyFiles);
                for (Iterator iter = oldTimeStamps.keySet().iterator(); iter.hasNext();) {
                        IFile file = (IFile) iter.next();
                        if ( !oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
                                modified = addModified(modified, file);
                }
                if (modified != null)
                        return modified;
                return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
        }

        private static Map createModificationStampMap(List files) {
                Map map = new HashMap();
                for (Iterator iter = files.iterator(); iter.hasNext();) {
                        IFile file = (IFile) iter.next();
                        map.put(file, new Long(file.getModificationStamp()));
                }
                return map;
        }

        private static IStatus addModified(IStatus status, IFile file) {
                IStatus entry = JavaUIStatus.createError(
                         IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, 
                         Messages.format(CorextMessages.Resources_fileModified, file.getFullPath().toString()), 
                         null                           );
                if (status == null) {
                        return entry;
                }
                else   if (status.isMultiStatus()) {
                        ((MultiStatus) status).add(entry);
                        return status;
                       }
                       else {
                        MultiStatus result = new MultiStatus(JavaPlugin.getPluginId(), 
                                 IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, 
                                 CorextMessages.Resources_modifiedResources, null);
                        result.add(status);
                        result.add(entry);
                        return result;
                       }
        }

        private static IStatus addOutOfSync(IStatus status, IResource resource) {
                IStatus entry = new Status(
                         IStatus.ERROR, 
                         ResourcesPlugin.PI_RESOURCES, 
                         IResourceStatus.OUT_OF_SYNC_LOCAL, 
                         Messages.format(CorextMessages.Resources_outOfSync, resource.getFullPath().toString()), 
                         null             );
                if (status == null) {
                        return entry;
                }
                else   if (status.isMultiStatus()) {
                        ((MultiStatus) status).add(entry);
                        return status;
                       }
                       else {
                        MultiStatus result = new MultiStatus(
                                 ResourcesPlugin.PI_RESOURCES, 
                                 IResourceStatus.OUT_OF_SYNC_LOCAL, 
                                 CorextMessages.Resources_outOfSyncResources, null);
                        result.add(status);
                        result.add(entry);
                        return result;
                       }
        }


Clone AbstractionParameter Count: 6Parameter Bindings

private Resources() {
}

/**
         * Checks if the given resource is in sync with the underlying file system.
         * 
         * @param resource the resource to be checked
         * @return IStatus status describing the check's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the resource is in sync
         */
public static IStatus checkInSync(IResource resource) {
  return checkInSync(new IResource[] {
                                       resource
                                     } );
}

/**
         * Checks if the given resources are in sync with the underlying file
         * system.
         * 
         * @param resources the resources to be checked
         * @return IStatus status describing the check's result. If <code>status.
         *  isOK() </code> returns <code>true</code> then the resources are in sync
         */
public static IStatus checkInSync(IResource[] resources) {
  IStatus result = null;
  for (int i = 0; i < resources.length; i++) {
    IResource resource = resources[i];
    if ( !resource.isSynchronized(IResource.DEPTH_INFINITE)) {
      result = addOutOfSync(result, resource);
    }
  }
  if (result != null)
    return result;
  return new Status(IStatus.OK,  [[#variable94203d60]].getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$           
}

/**
         * Makes the given resource committable. Committable means that it is
         * writeable and that its content hasn't changed by calling
         * <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
         * 
         * @param resource the resource to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return IStatus status describing the method's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the resource are committable
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.
         * resources.IFile[], java.lang.Object)
         */
/**
         * Makes the given resource committable. Committable means that it is
         * writeable and that its content hasn't changed by calling
         * <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
         * 
         * @param resource the resource to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return status describing the method's result. If <code>status.isOK()</code> returns <code>true</code> then the resources are committable.
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
         */
public static IStatus makeCommittable(IResource resource, Object context) {
  return makeCommittable(new IResource[] {
                                           resource
                                         }, context);
}

/**
         * Makes the given resources committable. Committable means that all
         * resources are writeable and that the content of the resources hasn't
         * changed by calling <code>validateEdit</code> for a given file on
         * <tt>IWorkspace</tt>.
         * 
         * @param resources the resources to be checked
         * @param context the context passed to <code>validateEdit</code> 
         * @return IStatus status describing the method's result. If <code>status.
         * isOK()</code> returns <code>true</code> then the add resources are
         * committable
         * 
         * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
         */
public static IStatus makeCommittable(IResource[] resources, Object context) {
  List readOnlyFiles = new ArrayList();
  for (int i = 0; i < resources.length; i++) {
    IResource resource = resources[i];
    if (resource.getType() == IResource.FILE && [[#variable94203cc0]])
      readOnlyFiles.add(resource);
  }
  if (readOnlyFiles.size() == 0)
    return new Status(IStatus.OK,  [[#variable94203d60]].getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
  Map oldTimeStamps = createModificationStampMap(readOnlyFiles);
  IStatus status = ResourcesPlugin.getWorkspace().validateEdit((IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
  if ( !status.isOK())
    return status;
  IStatus modified = null;
  Map newTimeStamps = createModificationStampMap(readOnlyFiles);
  for (Iterator iter = oldTimeStamps.keySet().iterator(); iter.hasNext();) {
    IFile file = (IFile) iter.next();
    if ( !oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
      modified = addModified(modified, file);
  }
  if (modified != null)
    return modified;
  return new Status(IStatus.OK,  [[#variable94203d60]].getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
}

private static Map createModificationStampMap(List files) {
  Map map = new HashMap();
  for (Iterator iter = files.iterator(); iter.hasNext();) {
    IFile file = (IFile) iter.next();
    map.put(file, new Long(file.getModificationStamp()));
  }
  return map;
}

private static IStatus addModified(IStatus status, IFile file) {
  IStatus entry = [[#variable94203b40]].createError( [[#variableb29dcba0]]);
  if (status == null) {
    return entry;
  }
  else
    if (status.isMultiStatus()) {
      ((MultiStatus) status).add(entry);
      return status;
    }
    else {
      MultiStatus result = new MultiStatus( [[#variable94203d60]].getPluginId(),  [[#variable94203bc0]].VALIDATE_EDIT_CHANGED_CONTENT,  [[#variable942039a0]].Resources_modifiedResources, null);
      result.add(status);
      result.add(entry);
      return result;
    }
}

private static IStatus addOutOfSync(IStatus status, IResource resource) {
  IStatus entry = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.OUT_OF_SYNC_LOCAL, Messages.format( [[#variable942039a0]].Resources_outOfSync, resource.getFullPath().toString()), null);
  if (status == null) {
    return entry;
  }
  else
    if (status.isMultiStatus()) {
      ((MultiStatus) status).add(entry);
      return status;
    }
    else {
      MultiStatus result = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.OUT_OF_SYNC_LOCAL,  [[#variable942039a0]].Resources_outOfSyncResources, null);
      result.add(status);
      result.add(entry);
      return result;
    }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#94203d60]]
JUnitPlugin 
12[[#94203d60]]
JavaPlugin 
21[[#94203cc0]]
resource.getResourceAttributes().isReadOnly() 
22[[#94203cc0]]
isReadOnly(resource) 
31[[#94203b40]]
JUnitStatus 
32[[#94203b40]]
JavaUIStatus 
41[[#b29dcba0]]
Messages.format(JUnitMessages.Resources_fileModified, file.getFullPath().toString()) 
42[[#b29dcba0]]
IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, Messages.format(CorextMessages.Resources_fileModified, file.getFullPath().toString()), null 
51[[#94203bc0]]
IJUnitStatusConstants 
52[[#94203bc0]]
IJavaStatusConstants 
61[[#942039a0]]
JUnitMessages 
62[[#942039a0]]
CorextMessages