001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core;
011:
012: import org.eclipse.core.runtime.IProgressMonitor;
013:
014: /**
015: * Common protocol for Java elements that support source code manipulations such
016: * as copy, move, rename, and delete.
017: * <p>
018: * This interface is not intended to be implemented by clients.
019: * </p>
020: */
021: public interface ISourceManipulation {
022: /**
023: * Copies this element to the given container.
024: *
025: * @param container the container
026: * @param sibling the sibling element before which the copy should be inserted,
027: * or <code>null</code> if the copy should be inserted as the last child of
028: * the container
029: * @param rename the new name for the element, or <code>null</code> if the copy
030: * retains the name of this element
031: * @param replace <code>true</code> if any existing child in the container with
032: * the target name should be replaced, and <code>false</code> to throw an
033: * exception in the event of a name collision
034: * @param monitor a progress monitor
035: * @exception JavaModelException if this element could not be copied. Reasons include:
036: * <ul>
037: * <li> This Java element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
038: * <li> A <code>CoreException</code> occurred while updating an underlying resource
039: * <li> The container is of an incompatible type (INVALID_DESTINATION)
040: * <li> The sibling is not a child of the given container (INVALID_SIBLING)
041: * <li> The new name is invalid (INVALID_NAME)
042: * <li> A child in the container already exists with the same name (NAME_COLLISION)
043: * and <code>replace</code> has been specified as <code>false</code>
044: * <li> The container or this element is read-only (READ_ONLY)
045: * </ul>
046: *
047: * @exception IllegalArgumentException if container is <code>null</code>
048: */
049: void copy(IJavaElement container, IJavaElement sibling,
050: String rename, boolean replace, IProgressMonitor monitor)
051: throws JavaModelException;
052:
053: /**
054: * Deletes this element, forcing if specified and necessary.
055: *
056: * @param force a flag controlling whether underlying resources that are not
057: * in sync with the local file system will be tolerated (same as the force flag
058: * in IResource operations).
059: * @param monitor a progress monitor
060: * @exception JavaModelException if this element could not be deleted. Reasons include:
061: * <ul>
062: * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
063: * <li> A <code>CoreException</code> occurred while updating an underlying resource (CORE_EXCEPTION)</li>
064: * <li> This element is read-only (READ_ONLY)</li>
065: * </ul>
066: */
067: void delete(boolean force, IProgressMonitor monitor)
068: throws JavaModelException;
069:
070: /**
071: * Moves this element to the given container.
072: *
073: * @param container the container
074: * @param sibling the sibling element before which the element should be inserted,
075: * or <code>null</code> if the element should be inserted as the last child of
076: * the container
077: * @param rename the new name for the element, or <code>null</code> if the
078: * element retains its name
079: * @param replace <code>true</code> if any existing child in the container with
080: * the target name should be replaced, and <code>false</code> to throw an
081: * exception in the event of a name collision
082: * @param monitor a progress monitor
083: * @exception JavaModelException if this element could not be moved. Reasons include:
084: * <ul>
085: * <li> This Java element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
086: * <li> A <code>CoreException</code> occurred while updating an underlying resource
087: * <li> The container is of an incompatible type (INVALID_DESTINATION)
088: * <li> The sibling is not a child of the given container (INVALID_SIBLING)
089: * <li> The new name is invalid (INVALID_NAME)
090: * <li> A child in the container already exists with the same name (NAME_COLLISION)
091: * and <code>replace</code> has been specified as <code>false</code>
092: * <li> The container or this element is read-only (READ_ONLY)
093: * </ul>
094: *
095: * @exception IllegalArgumentException if container is <code>null</code>
096: */
097: void move(IJavaElement container, IJavaElement sibling,
098: String rename, boolean replace, IProgressMonitor monitor)
099: throws JavaModelException;
100:
101: /**
102: * Renames this element to the given name.
103: *
104: * @param name the new name for the element
105: * @param replace <code>true</code> if any existing element with the target name
106: * should be replaced, and <code>false</code> to throw an exception in the
107: * event of a name collision
108: * @param monitor a progress monitor
109: * @exception JavaModelException if this element could not be renamed. Reasons include:
110: * <ul>
111: * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
112: * <li> A <code>CoreException</code> occurred while updating an underlying resource
113: * <li> The new name is invalid (INVALID_NAME)
114: * <li> A child in the container already exists with the same name (NAME_COLLISION)
115: * and <code>replace</code> has been specified as <code>false</code>
116: * <li> This element is read-only (READ_ONLY)
117: * </ul>
118: */
119: void rename(String name, boolean replace, IProgressMonitor monitor)
120: throws JavaModelException;
121: }
|