org.eclipse.jdt.core.manipulation_1.4.0.v20110928-1453

l String PARAMETER_NAME = "parameter_name";
  private static final String SETTERS = "setters";
  private static final String TOP_LEVEL = "top_level";
  public static final int PARAMETER_OBJECT_IDX = -1;
  
  public static class Parameter
  {
    private boolean fCreateField = false;
    private String fFieldName = null;
    private final int fIndex;
    
    public Parameter(int index)
    {
      fIndex = index;
    }
    
    public String getFieldName()
    {
      return fFieldName;
    }
    
    public int getIndex()
    {
      return fIndex;
    }
    
    public boolean isCreateField()
    {
      return fCreateField;
    }
    
    public void setCreateField(boolean createField)
    {
      if (fIndex == -1) {
        throw new IllegalArgumentException("You can not set create field for the parameter object");
      }
      fCreateField = createField;
    }
    
    public void setFieldName(String fieldName)
    {
      if (fIndex == -1) {
        throw new IllegalArgumentException("You can not set the field name of the parameter object");
      }
      fFieldName = fieldName;
    }
  }
  
  public static final Parameter PARAMETER_OBJECT = new Parameter(-1);
  private String fClassName;
  
  public static Parameter[] createParameters(IMethod method)
  {
    int length = method.getNumberOfParameters();
    Parameter[] result = new Parameter[length + 1];
    result[0] = PARAMETER_OBJECT;
    for (int i = 0; i < length; i++)
    {
      result[(i + 1)] = new Parameter(i);
      result[(i + 1)].setCreateField(true);
    }
    return result;
  }
  
  private boolean fDelegate = false;
  private boolean fDeprecateDelegate = true;
  private boolean fGetters = false;
  private IMethod fMethod;
  private String fPackageName;
  private String fParameterName;
  private Parameter[] fParameters;
  private boolean fSetters = false;
  private boolean fTopLevel = true;
  
  public IntroduceParameterObjectDescriptor()
  {
    super("org.eclipse.jdt.ui.introduce.parameter.object");
  }
  
  public IntroduceParameterObjectDescriptor(String project, String description, String comment, Map arguments, int flags)
    throws IllegalArgumentException
  {
    super("org.eclipse.jdt.ui.introduce.parameter.object", project, description, comment, arguments, flags);
    initializeFromMap(arguments);
  }
  
  public String getClassName()
  {
    return fClassName;
  }
  
  public IMethod getMethod()
  {
    return fMethod;
  }
  
  public String getPackageName()
  {
    if ((fPackageName == null) && (fMethod != null))
    {
      IType type = fMethod.getDeclaringType();
      if (type != null) {
        return type.getPackageFragment().getElementName();
      }
    }
    return fPackageName;
  }
  
  public String getParameterName()
  {
    return fParameterName;
  }
  
  public Parameter[] getParameters()
  {
    return fParameters;
  }
  
  public boolean isDelegate()
  {
    return fDelegate;
  }
  
  public boolean isDeprecateDelegate()
  {
    return fDeprecateDelegate;
  }
  
  public boolean isGetters()
  {
    return fGetters;
  }
  
  public boolean isSetters()
  {
    return fSetters;
  }
  
  public boolean isTopLevel()
  {
    return fTopLevel;
  }
  
  protected void populateArgumentMap()
  {
    super.populateArgumentMap();
    JavaRefactoringDescriptorUtil.setJavaElement(fArguments, "input", getProject(), fMethod);
    Parameter[] parameters = fParameters;
    if (parameters == null) {
      parameters = createParameters(fMethod);
    }
    JavaRefactoringDescriptorUtil.setInt(fArguments, "PARAMETER_COUNT", parameters.length);
    for (int i = 0; i < parameters.length; i++)
    {
      Parameter param = parameters[i];
      JavaRefactoringDescriptorUtil.setInt(fArguments, JavaRefactoringDescriptorUtil.getAttributeName("PARAMETER_IDX", i), param.getIndex());
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, JavaRefactoringDescriptorUtil.getAttributeName("PARAMETER_CREATE_FIELD", i), param.isCreateField());
      if (param.isCreateField()) {
        JavaRefactoringDescriptorUtil.setString(fArguments, JavaRefactoringDescriptorUtil.getAttributeName("PARAMETER_FIELD_NAME", i), param.getFieldName());
      }
    }
    JavaRefactoringDescriptorUtil.setString(fArguments, "class_name", fClassName);
    JavaRefactoringDescriptorUtil.setString(fArguments, "package_name", fPackageName);
    JavaRefactoringDescriptorUtil.setString(fArguments, "parameter_name", fParameterName);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "delegate", fDelegate);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "deprecate_delegate", fDeprecateDelegate);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "getters", fGetters);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "setters", fSetters);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "top_level", fTopLevel);
  }
  
  private void initializeFromMap(Map map)
    throws IllegalArgumentException
  {
    IMethod method = (IMethod)JavaRefactoringDescriptorUtil.getJavaElement(map, "input", getProject());
    setMethod(method);
    initializeParameter(map);
    setClassName(JavaRefactoringDescriptorUtil.getString(map, "class_name", true));
    setPackageName(JavaRefactoringDescriptorUtil.getString(map, "package_name", true));
    setParameterName(JavaRefactoringDescriptorUtil.getString(map, "parameter_name", true));
    setDelegate(JavaRefactoringDescriptorUtil.getBoolean(map, "delegate", fDelegate));
    setDeprecateDelegate(JavaRefactoringDescriptorUtil.getBoolean(map, "deprecate_delegate", fDeprecateDelegate));
    setGetters(JavaRefactoringDescriptorUtil.getBoolean(map, "getters", fGetters));
    setSetters(JavaRefactoringDescriptorUtil.getBoolean(map, "setters", fSetters));
    setTopLevel(JavaRefactoringDescriptorUtil.getBoolean(map, "top_level", fTopLevel));
  }
  
  private void initializeParameter(Map map)
    throws IllegalArgumentException
  {
    int[] idx = JavaRefactoringDescriptorUtil.getIntArray(map, "PARAMETER_COUNT", "PARAMETER_IDX");
    boolean[] createField = JavaRefactoringDescriptorUtil.getBooleanArray(map, "PARAMETER_COUNT", "PARAMETER_CREATE_FIELD", 0);
    Parameter[] result = new Parameter[idx.length];
    for (int i = 0; i < idx.length; i++)
    {
      int index = idx[i];
      if (index == -1)
      {
        result[i] = new Parameter(-1);
      }
      else
      {
        Parameter parameter = new Parameter(index);
        result[i] = parameter;
        parameter.setCreateField(createField[i]);
        if (createField[i] != 0) {
          parameter.setFieldName(JavaRefactoringDescriptorUtil.getString(map, JavaRefactoringDescriptorUtil.getAttributeName("PARAMETER_FIELD_NAME", i)));
        }
      }
    }
    setParameters(result);
  }
  
  public void setClassName(String className)
  {
    fClassName = className;
  }
  
  public void setDelegate(boolean delegate)
  {
    fDelegate = delegate;
  }
  
  public void setDeprecateDelegate(boolean deprecateDelegate)
  {
    fDeprecateDelegate = deprecateDelegate;
  }
  
  public void setGetters(boolean getters)
  {
    fGetters = getters;
  }
  
  public void setMethod(IMethod method)
  {
    if (method == null) {
      throw new IllegalArgumentException("The method must not be null");
    }
    if (!method.exists()) {
      throw new IllegalArgumentException("The method must exist");
    }
    if (method.getJavaProject() == null) {
      throw new IllegalArgumentException("The method has to be in a Java project");
    }
    fMethod = method;
  }
  
  public void setPackageName(String packageName)
  {
    fPackageName = packageName;
  }
  
  public void setParameterName(String parameterName)
  {
    fParameterName = parameterName;
  }
  
  public void setParameters(Parameter[] parameters)
  {
    fParameters = parameters;
  }
  
  public void setSetters(boolean setters)
  {
    fSetters = setters;
  }
  
  public void setTopLevel(boolean topLevel)
  {
    fTopLevel = topLevel;
  }
  
  public RefactoringStatus validateDescriptor()
  {
    RefactoringStatus result = super.validateDescriptor();
    if (!result.isOK()) {
      return result;
    }
    if (fMethod == null)
    {
      result.addFatalError("The method must not be null");
      return result;
    }
    IJavaProject javaProject = fMethod.getJavaProject();
    if (javaProject == null)
    {
      result.addFatalError("Can not derive Java project from method");
      return result;
    }
    String sourceLevel = javaProject.getOption("org.eclipse.jdt.core.compiler.source", true);
    String complianceLevel = javaProject.getOption("org.eclipse.jdt.core.compiler.compliance", true);
    if (fParameters != null)
    {
      if (fParameters.length - 1 != fMethod.getNumberOfParameters()) {
        result.addFatalError("The number of parameters does not match the number of parameters of the method");
      }
      boolean hasParameterObject = false;
      for (int i = 0; i < fParameters.length; i++)
      {
        Parameter parameter = fParameters[i];
        if (parameter.isCreateField())
        {
          String fieldName = parameter.getFieldName();
          if (fieldName == null) {
            result.addError("The parameter " + parameter.getIndex() + " is marked for field creation but does not have a field name");
          } else {
            result.merge(RefactoringStatus.create(JavaConventions.validateFieldName(fieldName, sourceLevel, complianceLevel)));
          }
        }
        if (parameter == PARAMETER_OBJECT) {
          if (hasParameterObject) {
            result.addError("Can not have more than one parameter object");
          } else {
            hasParameterObject = true;
          }
        }
      }
    }
    if (fClassName != null) {
      result.merge(RefactoringStatus.create(JavaConventions.validateIdentifier(fClassName, sourceLevel, complianceLevel)));
    }
    if (fParameterName != null) {
      result.merge(RefactoringStatus.create(JavaConventions.validateIdentifier(fParameterName, sourceLevel, complianceLevel)));
    }
    if ((fPackageName != null) && (!"".equals(fPackageName))) {
      result.merge(RefactoringStatus.create(JavaConventions.validatePackageName(fPackageName, sourceLevel, complianceLevel)));
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.IntroduceParameterObjectDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringContribution;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;

public abstract class JavaRefactoringContribution
  extends RefactoringContribution
{
  public final Map retrieveArgumentMap(RefactoringDescriptor descriptor)
  {
    Assert.isNotNull(descriptor);
    if ((descriptor instanceof JavaRefactoringDescriptor)) {
      return ((JavaRefactoringDescriptor)descriptor).getArguments();
    }
    return super.retrieveArgumentMap(descriptor);
  }
  
  public abstract Refactoring createRefactoring(JavaRefactoringDescriptor paramJavaRefactoringDescriptor, RefactoringStatus paramRefactoringStatus)
    throws CoreException;
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringContribution
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin;
import org.eclipse.jdt.internal.core.refactoring.descriptors.DescriptorMessages;
import org.eclipse.jdt.internal.core.refactoring.descriptors.JavaRefactoringDescriptorUtil;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringContribution;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;

public abstract class JavaRefactoringDescriptor
  extends RefactoringDescriptor
{
  protected static final String ATTRIBUTE_ELEMENT = "element";
  protected static final String ATTRIBUTE_INPUT = "input";
  protected static final String ATTRIBUTE_NAME = "name";
  protected static final String ATTRIBUTE_REFERENCES = "references";
  protected static final String ATTRIBUTE_SELECTION = "selection";
  protected static final String ATTRIBUTE_VERSION = "version";
  public static final int JAR_MIGRATION = 65536;
  public static final int JAR_REFACTORING = 524288;
  public static final int JAR_SOURCE_ATTACHMENT = 262144;
  protected static final String VALUE_VERSION_1_0 = "1.0";
  protected final Map fArguments;
  
  protected static String elementToHandle(String project, IJavaElement element)
  {
    return JavaRefactoringDescriptorUtil.elementToHandle(project, element);
  }
  
  protected static IJavaElement handleToElement(String project, String handle)
  {
    return handleToElement(project, handle, true);
  }
  
  protected static IJavaElement handleToElement(String project, String handle, boolean check)
  {
    return handleToElement(null, project, handle, check);
  }
  
  protected static IJavaElement handleToElement(WorkingCopyOwner owner, String project, String handle, boolean check)
  {
    return JavaRefactoringDescriptorUtil.handleToElement(owner, project, handle, check);
  }
  
  protected static IResource handleToResource(String project, String handle)
  {
    return JavaRefactoringDescriptorUtil.handleToResource(project, handle);
  }
  
  protected static String resourceToHandle(String project, IResource resource)
  {
    return JavaRefactoringDescriptorUtil.resourcePathToHandle(project, resource.getFullPath());
  }
  
  protected JavaRefactoringDescriptor(String id)
  {
    this(id, null, DescriptorMessages.JavaRefactoringDescriptor_not_available, null, new HashMap(), 6);
  }
  
  public JavaRefactoringDescriptor(String id, String project, String description, String comment, Map arguments, int flags)
  {
    super(id, project, description, comment, flags);
    fArguments = arguments;
    fArguments.put("version", "1.0");
  }
  
  public Refactoring createRefactoring(RefactoringStatus status)
    throws CoreException
  {
    Refactoring refactoring = null;
    String id = getID();
    RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(id);
    if (contribution != null) {
      if ((contribution instanceof JavaRefactoringContribution))
      {
        JavaRefactoringContribution javaContribution = (JavaRefactoringContribution)contribution;
        refactoring = javaContribution.createRefactoring(this, status);
      }
      else
      {
        JavaManipulationPlugin.log(new Status(4, JavaManipulationPlugin.getPluginId(), 0, MessageFormat.format(DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor, new Object[] { id }), null));
      }
    }
    return refactoring;
  }
  
  protected Map getArguments()
  {
    populateArgumentMap();
    return new HashMap(fArguments);
  }
  
  protected void populateArgumentMap()
  {
    RefactoringStatus status = validateDescriptor();
    if (status.hasFatalError()) {
      throw new RuntimeException("Validation returns a fatal error status", new CoreException(status.getEntryWithHighestSeverity().toStatus()));
    }
  }
  
  public void setComment(String comment)
  {
    super.setComment(comment);
  }
  
  public void setDescription(String description)
  {
    super.setDescription(description);
  }
  
  public void setFlags(int flags)
  {
    super.setFlags(flags);
  }
  
  public void setProject(String project)
  {
    super.setProject(project);
  }
  
  public RefactoringStatus validateDescriptor()
  {
    RefactoringStatus status = new RefactoringStatus();
    String description = getDescription();
    if ((description == null) || ("".equals(description))) {
      status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.JavaRefactoringDescriptor_no_description));
    }
    return status;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.core.refactoring.descriptors.DescriptorMessages;
import org.eclipse.jdt.internal.core.refactoring.descriptors.JavaRefactoringDescriptorUtil;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;

public final class MoveDescriptor
  extends JavaRefactoringDescriptor
{
  private static final String ATTRIBUTE_DESTINATION = "destination";
  private static final String ATTRIBUTE_FILES = "files";
  private static final String ATTRIBUTE_FOLDERS = "folders";
  private static final String ATTRIBUTE_FRAGMENTS = "fragments";
  private static final String ATTRIBUTE_MEMBERS = "members";
  private static final String ATTRIBUTE_PATTERNS = "patterns";
  private static final String ATTRIBUTE_POLICY = "policy";
  private static final String ATTRIBUTE_QUALIFIED = "qualified";
  private static final String ATTRIBUTE_ROOTS = "roots";
  private static final String ATTRIBUTE_TARGET = "target";
  private static final String ATTRIBUTE_UNITS = "units";
  private static final String POLICY_MOVE_MEMBERS = "org.eclipse.jdt.ui.moveMembers";
  private static final String POLICY_MOVE_PACKAGES = "org.eclipse.jdt.ui.movePackages";
  private static final String POLICY_MOVE_RESOURCES = "org.eclipse.jdt.ui.moveResources";
  private static final String POLICY_MOVE_ROOTS = "org.eclipse.jdt.ui.moveRoots";
  private Object fDestination;
  private IPath[] fFiles;
  private IPath[] fFolders;
  private IPackageFragment[] fFragments;
  private IMember[] fMembers;
  private String fMovePolicy = null;
  private String fPatterns = null;
  private boolean fQualified = false;
  private boolean fReferences = false;
  private IPackageFragmentRoot[] fRoots;
  private ICompilationUnit[] fUnits;
  
  public MoveDescriptor()
  {
    super("org.eclipse.jdt.ui.move");
  }
  
  public MoveDescriptor(String project, String description, String comment, Map arguments, int flags)
  {
    super("org.eclipse.jdt.ui.move", project, description, comment, arguments, flags);
    fMovePolicy = JavaRefactoringDescriptorUtil.getString(fArguments, "policy");
    
    fDestination = JavaRefactoringDescriptorUtil.getJavaElement(fArguments, "destination", project, true);
    if (fDestination == null) {
      fDestination = JavaRefactoringDescriptorUtil.getResourcePath(fArguments, "target", project);
    }
    if ("org.eclipse.jdt.ui.moveResources".equals(fMovePolicy))
    {
      fReferences = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "references", fReferences);
      fQualified = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "qualified", fQualified);
      fPatterns = JavaRefactoringDescriptorUtil.getString(fArguments, "patterns", true);
      int offset = 1;
      fFiles = JavaRefactoringDescriptorUtil.getResourcePathArray(fArguments, "files", "element", offset, project);
      offset += fFiles.length;
      fFolders = JavaRefactoringDescriptorUtil.getResourcePathArray(fArguments, "folders", "element", offset, project);
      offset += fFolders.length;
      fUnits = ((ICompilationUnit[])JavaRefactoringDescriptorUtil.getJavaElementArray(fArguments, "units", "element", offset, project, ICompilationUnit.class));
    }
    else if ("org.eclipse.jdt.ui.moveRoots".equals(fMovePolicy))
    {
      fRoots = ((IPackageFragmentRoot[])JavaRefactoringDescriptorUtil.getJavaElementArray(fArguments, "roots", "element", 1, project, IPackageFragmentRoot.class));
    }
    else if ("org.eclipse.jdt.ui.movePackages".equals(fMovePolicy))
    {
      fFragments = ((IPackageFragment[])JavaRefactoringDescriptorUtil.getJavaElementArray(fArguments, "fragments", "element", 1, project, IPackageFragment.class));
    }
    else if ("org.eclipse.jdt.ui.moveMembers".equals(fMovePolicy))
    {
      fMembers = ((IMember[])JavaRefactoringDescriptorUtil.getJavaElementArray(fArguments, "members", "element", 1, project, IMember.class));
    }
  }
  
  protected void populateArgumentMap()
  {
    super.populateArgumentMap();
    JavaRefactoringDescriptorUtil.setString(fArguments, "policy", fMovePolicy);
    String project = getProject();
    if ((fDestination instanceof IJavaElement)) {
      JavaRefactoringDescriptorUtil.setJavaElement(fArguments, "destination", project, (IJavaElement)fDestination);
    } else if ((fDestination instanceof IPath)) {
      JavaRefactoringDescriptorUtil.setResourcePath(fArguments, "target", project, (IPath)fDestination);
    }
    if ("org.eclipse.jdt.ui.moveResources".equals(fMovePolicy))
    {
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "references", fReferences);
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "qualified", fQualified);
      JavaRefactoringDescriptorUtil.setString(fArguments, "patterns", fPatterns);
      int offset = 1;
      JavaRefactoringDescriptorUtil.setResourcePathArray(fArguments, "files", "element", project, fFiles, offset);
      offset += fFiles.length;
      JavaRefactoringDescriptorUtil.setResourcePathArray(fArguments, "folders", "element", project, fFolders, offset);
      offset += fFolders.length;
      JavaRefactoringDescriptorUtil.setJavaElementArray(fArguments, "units", "element", project, fUnits, offset);
    }
    else if ("org.eclipse.jdt.ui.moveRoots".equals(fMovePolicy))
    {
      JavaRefactoringDescriptorUtil.setJavaElementArray(fArguments, "roots", "element", project, fRoots, 1);
    }
    else if ("org.eclipse.jdt.ui.movePackages".equals(fMovePolicy))
    {
      JavaRefactoringDescriptorUtil.setJavaElementArray(fArguments, "fragments", "element", project, fFragments, 1);
    }
    else if ("org.eclipse.jdt.ui.moveMembers".equals(fMovePolicy))
    {
      JavaRefactoringDescriptorUtil.setJavaElementArray(fArguments, "members", "element", project, fMembers, 1);
    }
  }
  
  public void setDestination(IJavaElement element)
  {
    Assert.isNotNull(element);
    fDestination = element;
  }
  
  public void setDestination(IResource resource)
  {
    Assert.isNotNull(resource);
    fDestination = resource.getFullPath();
  }
  
  public void setFileNamePatterns(String patterns)
  {
    Assert.isNotNull(patterns);
    Assert.isLegal(!"".equals(patterns), "Pattern must not be empty");
    fPatterns = patterns;
  }
  
  public void setMoveMembers(IMember[] members)
  {
    Assert.isNotNull(members);
    Assert.isTrue(fMovePolicy == null, "Clients must only call one of the 'setMoveXXX' methods.");
    fMembers = members;
    fMovePolicy = "org.eclipse.jdt.ui.moveMembers";
  }
  
  public void setMovePackageFragmentRoots(IPackageFragmentRoot[] roots)
  {
    Assert.isNotNull(roots);
    Assert.isTrue(fMovePolicy == null, "Clients must only call one of the 'setMoveXXX' methods.");
    fRoots = roots;
    fMovePolicy = "org.eclipse.jdt.ui.moveRoots";
  }
  
  public void setMovePackages(IPackageFragment[] fragments)
  {
    Assert.isNotNull(fragments);
    Assert.isTrue(fMovePolicy == null, "Clients must only call one of the 'setMoveXXX' methods.");
    fFragments = fragments;
    fMovePolicy = "org.eclipse.jdt.ui.movePackages";
  }
  
  public void setMoveResources(IFile[] files, IFolder[] folders, ICompilationUnit[] units)
  {
    Assert.isNotNull(files);
    Assert.isNotNull(folders);
    Assert.isNotNull(units);
    Assert.isTrue(fMovePolicy == null, "Clients must only call one of the 'setMoveXXX' methods.");
    fFiles = new IPath[files.length];
    for (int i = 0; i < files.length; i++) {
      fFiles[i] = files[i].getFullPath();
    }
    fFolders = new IPath[folders.length];
    for (int i = 0; i < folders.length; i++) {
      fFolders[i] = folders[i].getFullPath();
    }
    fUnits = units;
    fMovePolicy = "org.eclipse.jdt.ui.moveResources";
  }
  
  public void setUpdateQualifiedNames(boolean update)
  {
    fQualified = update;
  }
  
  public void setUpdateReferences(boolean update)
  {
    fReferences = update;
  }
  
  public RefactoringStatus validateDescriptor()
  {
    RefactoringStatus status = super.validateDescriptor();
    if (!status.hasFatalError())
    {
      if (fMovePolicy == null) {
        status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.MoveDescriptor_no_elements_set));
      }
      if (fDestination == null) {
        status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.MoveDescriptor_no_destination_set));
      }
    }
    return status;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.MoveDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;

public final class MoveMethodDescriptor
  extends JavaRefactoringDescriptor
{
  public MoveMethodDescriptor()
  {
    super("org.eclipse.jdt.ui.move.method");
  }
  
  public MoveMethodDescriptor(String project, String description, String comment, Map arguments, int flags)
  {
    super("org.eclipse.jdt.ui.move.method", project, description, comment, arguments, flags);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.MoveMethodDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.internal.core.refactoring.descriptors.DescriptorMessages;
import org.eclipse.jdt.internal.core.refactoring.descriptors.JavaRefactoringDescriptorUtil;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;

public final class MoveStaticMembersDescriptor
  extends JavaRefactoringDescriptor
{
  private static final String ATTRIBUTE_DELEGATE = "delegate";
  private static final String ATTRIBUTE_DEPRECATE = "deprecate";
  private boolean fDelegate = false;
  private boolean fDeprecate = false;
  private IMember[] fMembers;
  private IType fType = null;
  
  public MoveStaticMembersDescriptor()
  {
    super("org.eclipse.jdt.ui.move.static");
  }
  
  public MoveStaticMembersDescriptor(String project, String description, String comment, Map arguments, int flags)
  {
    super("org.eclipse.jdt.ui.move.static", project, description, comment, arguments, flags);
    fType = ((IType)JavaRefactoringDescriptorUtil.getJavaElement(fArguments, "input", project));
    fDelegate = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "delegate", fDelegate);
    fDeprecate = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "deprecate", fDeprecate);
    fMembers = ((IMember[])JavaRefactoringDescriptorUtil.getJavaElementArray(fArguments, null, "element", 1, project, IMember.class));
  }
  
  protected void populateArgumentMap()
  {
    super.populateArgumentMap();
    String project = getProject();
    JavaRefactoringDescriptorUtil.setJavaElement(fArguments, "input", project, fType);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "delegate", fDelegate);
    JavaRefactoringDescriptorUtil.setBoolean(fArguments, "deprecate", fDeprecate);
    JavaRefactoringDescriptorUtil.setJavaElementArray(fArguments, null, "element", project, fMembers, 1);
  }
  
  public void setDeprecateDelegate(boolean deprecate)
  {
    fDeprecate = deprecate;
  }
  
  public void setDestinationType(IType type)
  {
    Assert.isNotNull(type);
    fType = type;
  }
  
  public void setKeepOriginal(boolean delegate)
  {
    fDelegate = delegate;
  }
  
  public void setMembers(IMember[] members)
  {
    Assert.isNotNull(members);
    fMembers = members;
  }
  
  public RefactoringStatus validateDescriptor()
  {
    RefactoringStatus status = super.validateDescriptor();
    if (fType == null) {
      status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.MoveStaticMembersDescriptor_no_type));
    }
    if (fMembers == null) {
      status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.MoveStaticMembersDescriptor_no_members));
    } else {
      for (int index = 0; index < fMembers.length; index++) {
        if (fMembers[index] == null)
        {
          status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.MoveStaticMembersDescriptor_invalid_members));
          break;
        }
      }
    }
    return status;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.MoveStaticMembersDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;

public final class PullUpDescriptor
  extends JavaRefactoringDescriptor
{
  public PullUpDescriptor()
  {
    super("org.eclipse.jdt.ui.pull.up");
  }
  
  public PullUpDescriptor(String project, String description, String comment, Map arguments, int flags)
  {
    super("org.eclipse.jdt.ui.pull.up", project, description, comment, arguments, flags);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.PullUpDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;

public final class PushDownDescriptor
  extends JavaRefactoringDescriptor
{
  public PushDownDescriptor()
  {
    super("org.eclipse.jdt.ui.push.down");
  }
  
  public PushDownDescriptor(String project, String description, String comment, Map arguments, int flags)
  {
    super("org.eclipse.jdt.ui.push.down", project, description, comment, arguments, flags);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.core.refactoring.descriptors.PushDownDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.core.refactoring.descriptors;

import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeParameter;
import org.eclipse.jdt.internal.core.refactoring.descriptors.DescriptorMessages;
import org.eclipse.jdt.internal.core.refactoring.descriptors.JavaRefactoringDescriptorUtil;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;

public final class RenameJavaElementDescriptor
  extends JavaRefactoringDescriptor
{
  private static final String ATTRIBUTE_DELEGATE = "delegate";
  private static final String ATTRIBUTE_DEPRECATE = "deprecate";
  private static final String ATTRIBUTE_HIERARCHICAL = "hierarchical";
  private static final String ATTRIBUTE_MATCH_STRATEGY = "matchStrategy";
  private static final String ATTRIBUTE_PARAMETER = "parameter";
  private static final String ATTRIBUTE_PATTERNS = "patterns";
  private static final String ATTRIBUTE_QUALIFIED = "qualified";
  private static final String ATTRIBUTE_RENAME_GETTER = "getter";
  private static final String ATTRIBUTE_RENAME_SETTER = "setter";
  private static final String ATTRIBUTE_SIMILAR_DECLARATIONS = "similarDeclarations";
  private static final String ATTRIBUTE_TEXTUAL_MATCHES = "textual";
  public static final int STRATEGY_EMBEDDED = 2;
  public static final int STRATEGY_EXACT = 1;
  public static final int STRATEGY_SUFFIX = 3;
  /**
   * @deprecated
   */
  private static final String RENAME_RESOURCE = "org.eclipse.jdt.ui.rename.resource";
  private boolean fDelegate = false;
  private boolean fDeprecate = false;
  private boolean fHierarchical = false;
  private IJavaElement fJavaElement = null;
  private int fMatchStrategy = 1;
  private String fName = null;
  private String fPatterns = null;
  private boolean fQualified = false;
  private boolean fReferences = false;
  private boolean fRenameGetter = false;
  private boolean fRenameSetter = false;
  private boolean fSimilarDeclarations = false;
  private boolean fTextual = false;
  
  public RenameJavaElementDescriptor(String id)
  {
    super(id);
    Assert.isLegal(checkId(id), "Refactoring id is not a rename refactoring id");
  }
  
  public RenameJavaElementDescriptor(String id, String project, String description, String comment, Map arguments, int flags)
  {
    super(id, project, description, comment, arguments, flags);
    Assert.isLegal(checkId(id), "Refactoring id is not a rename refactoring id");
    fName = JavaRefactoringDescriptorUtil.getString(fArguments, "name");
    if (getID().equals("org.eclipse.jdt.ui.rename.type.parameter"))
    {
      fJavaElement = JavaRefactoringDescriptorUtil.getJavaElement(fArguments, "input", getProject());
      String parameterName = JavaRefactoringDescriptorUtil.getString(fArguments, "parameter");
      if ((fJavaElement instanceof IType)) {
        fJavaElement = ((IType)fJavaElement).getTypeParameter(parameterName);
      }
      if ((fJavaElement instanceof IMethod)) {
        fJavaElement = ((IMethod)fJavaElement).getTypeParameter(parameterName);
      }
    }
    else
    {
      fJavaElement = JavaRefactoringDescriptorUtil.getJavaElement(fArguments, "input", getProject());
    }
    int type = fJavaElement.getElementType();
    if (type != 3) {
      fReferences = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "references", fReferences);
    }
    if (type == 8)
    {
      fRenameGetter = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "getter", fRenameGetter);
      fRenameSetter = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "setter", fRenameSetter);
    }
    switch (type)
    {
    case 4: 
    case 7: 
    case 8: 
      fTextual = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "textual", fTextual);
      break;
    }
    switch (type)
    {
    case 8: 
    case 9: 
      fDeprecate = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "deprecate", fDeprecate);
      fDelegate = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "delegate", fDelegate);
      break;
    }
    switch (type)
    {
    case 4: 
    case 7: 
      fQualified = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "qualified", fQualified);
      fPatterns = JavaRefactoringDescriptorUtil.getString(fArguments, "patterns", true);
      break;
    }
    switch (type)
    {
    case 7: 
      fSimilarDeclarations = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "similarDeclarations", fSimilarDeclarations);
      fMatchStrategy = JavaRefactoringDescriptorUtil.getInt(fArguments, "matchStrategy", fMatchStrategy);
      break;
    }
    switch (type)
    {
    case 4: 
      fHierarchical = JavaRefactoringDescriptorUtil.getBoolean(fArguments, "hierarchical", fHierarchical);
      break;
    }
  }
  
  private boolean checkId(String id)
  {
    Assert.isNotNull(id);
    if (id.equals("org.eclipse.jdt.ui.rename.compilationunit")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.enum.constant")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.field")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.java.project")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.local.variable")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.method")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.package")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.resource")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.source.folder")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.type")) {
      return true;
    }
    if (id.equals("org.eclipse.jdt.ui.rename.type.parameter")) {
      return true;
    }
    return false;
  }
  
  protected void populateArgumentMap()
  {
    super.populateArgumentMap();
    JavaRefactoringDescriptorUtil.setString(fArguments, "name", fName);
    if (getID().equals("org.eclipse.jdt.ui.rename.type.parameter"))
    {
      ITypeParameter parameter = (ITypeParameter)fJavaElement;
      JavaRefactoringDescriptorUtil.setJavaElement(fArguments, "input", getProject(), parameter.getDeclaringMember());
      JavaRefactoringDescriptorUtil.setString(fArguments, "parameter", parameter.getElementName());
    }
    else
    {
      JavaRefactoringDescriptorUtil.setJavaElement(fArguments, "input", getProject(), fJavaElement);
    }
    int type = fJavaElement.getElementType();
    if (type != 3) {
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "references", fReferences);
    }
    if (type == 8)
    {
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "getter", fRenameGetter);
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "setter", fRenameSetter);
    }
    switch (type)
    {
    case 4: 
    case 7: 
    case 8: 
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "textual", fTextual);
      break;
    }
    switch (type)
    {
    case 8: 
    case 9: 
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "deprecate", fDeprecate);
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "delegate", fDelegate);
      break;
    }
    switch (type)
    {
    case 4: 
    case 7: 
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "qualified", fQualified);
      JavaRefactoringDescriptorUtil.setString(fArguments, "patterns", fPatterns);
      break;
    }
    switch (type)
    {
    case 7: 
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "similarDeclarations", fSimilarDeclarations);
      JavaRefactoringDescriptorUtil.setInt(fArguments, "matchStrategy", fMatchStrategy);
      break;
    }
    switch (type)
    {
    case 4: 
      JavaRefactoringDescriptorUtil.setBoolean(fArguments, "hierarchical", fHierarchical);
      break;
    }
  }
  
  public void setDeprecateDelegate(boolean deprecate)
  {
    fDeprecate = deprecate;
  }
  
  public void setFileNamePatterns(String patterns)
  {
    Assert.isNotNull(patterns);
    Assert.isLegal(!"".equals(patterns), "Pattern must not be empty");
    fPatterns = patterns;
  }
  
  public void setJavaElement(IJavaElement element)
  {
    Assert.isNotNull(element);
    fJavaElement = element;
  }
  
  public void setKeepOriginal(boolean delegate)
  {
    fDelegate = delegate;
  }
  
  public void setMatchStrategy(int strategy)
  {
    Assert.isLegal((strategy == 1) || (strategy == 2) || (strategy == 3), "Wrong match strategy argument");
    fMatchStrategy = strategy;
  }
  
  public void setNewName(String name)
  {
    Assert.isNotNull(name);
    Assert.isLegal(!"".equals(name), "Name must not be empty");
    fName = name;
  }
  
  public void setProject(String project)
  {
    super.setProject(project);
  }
  
  public void setRenameGetters(boolean rename)
  {
    fRenameGetter = rename;
  }
  
  public void setRenameSetters(boolean rename)
  {
    fRenameSetter = rename;
  }
  
  public void setUpdateHierarchy(boolean update)
  {
    fHierarchical =
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd